@@ -66,7 +66,7 @@ def rescale_across_channel(
6666 """
6767
6868 # Check that bit depth is valid before processing even begins
69- if not any ( bit_depth == b for b in [ 8 , 16 , 32 , 64 ] ):
69+ if bit_depth not in ( 8 , 16 , 32 , 64 ):
7070 raise_BitDepthError (bit_depth )
7171
7272 # Use shorter variable names
@@ -114,7 +114,7 @@ def rescale_to_bit_depth(
114114 bit_final = target_bit_depth
115115
116116 # Check that target bit depth is allowed
117- if not any ( bit_final == b for b in [ 8 , 16 , 32 , 64 ] ):
117+ if bit_final not in ( 8 , 16 , 32 , 64 ):
118118 raise_BitDepthError (bit_final )
119119
120120 # Rescale (DIVIDE BEFORE MULTIPLY)
@@ -142,7 +142,7 @@ def process_img_stk(
142142 bdi = initial_bit_depth
143143 bdt = target_bit_depth
144144
145- if not any ( bdi == b for b in [ 8 , 16 , 32 , 64 ] ):
145+ if bdi not in ( 8 , 16 , 32 , 64 ):
146146 logger .info (f"{ bdi } -bit is not supported by NumPy; converting to 16-bit" )
147147 arr = (
148148 rescale_to_bit_depth (array = arr , initial_bit_depth = bdi , target_bit_depth = 16 )
@@ -201,6 +201,10 @@ def write_to_tiff(
201201 axes : str ,
202202 image_labels : List [str ],
203203):
204+ """
205+ Writes the NumPy array as a calibrated greyscale TIFF image stack.
206+ """
207+
204208 # Use shorter aliases and calculate what is needed
205209 arr = array
206210 z_size = (1 / z_res ) if z_res > 0 else float (0 )
@@ -212,7 +216,7 @@ def write_to_tiff(
212216 save_name ,
213217 arr ,
214218 imagej = True , # ImageJ compatible
215- photometric = "minisblack" , # Grayscale image
219+ photometric = "minisblack" , # Greyscale image
216220 shape = np .shape (arr ),
217221 dtype = arr .dtype ,
218222 resolution = (x_res * 10 ** 6 / 10 ** 6 , y_res * 10 ** 6 / 10 ** 6 ),
0 commit comments