@@ -183,27 +183,36 @@ def process_files(files, outpath, model_file, fmt):
183183 model .close ()
184184
185185def simple_flatfield_correction (imp , sigma = 20.0 ):
186- """
187- Performs a simple flatfield correction to a given ImagePlus stack and returns a 32-bit corrected flatfield image.
186+ """Performs a simple flatfield correction to a given ImagePlus stack.
187+
188+ The function returns a 32-bit corrected flatfield image.
189+
188190 Parameters
189191 ----------
190192 imp : ij.ImagePlus
191193 The input stack to be projected.
192- sigma: double, default 20.0
193- The sigma value for the Gaussian blur, default = 20.0
194+ sigma: float, optional
195+ The sigma value for the Gaussian blur, default=20.0
196+
194197 Returns
195198 -------
196199 ij.ImagePlus
197- The 32-bit image result of the flatfield correction
200+ The 32-bit image result of flatfield correction
198201
199202 """
200203 flatfield = imp .duplicate ()
201204 sigma_str = "sigma=" + str (sigma )
202- IJ .run (flatfield , "Gaussian Blur..." , sigma_str ) # Apply a gaussian blur
205+
206+ IJ .run (flatfield , "Gaussian Blur..." , sigma_str )
203207 stats = StackStatistics (flatfield )
204- IJ .run (flatfield , "32-bit" , "" ) # Make a 32 bit version of the image
205- IJ .run (flatfield , "Divide..." , "value=" + str (stats .max )) # Normalize 32 bit image to the highest value of original
208+
209+ # Normalize image to the highest value of original (requires 32-bit image)
210+ IJ .run (flatfield , "32-bit" , "" )
211+ IJ .run (
212+ flatfield ,
213+ "Divide..." ,
214+ "value=" + str (stats .max ))
206215 ic = ImageCalculator ()
207216 flatfield_corrected = ic .run ("Divide create" , imp , flatfield )
208217
209- return flatfield_corrected
218+ return flatfield_corrected
0 commit comments