@@ -43,9 +43,7 @@ def show_progress(cur, final):
4343 -----
4444 `ij.IJ.showProgress` internally increments the given `cur` value by 1.
4545 """
46- log .info (
47- "Progress: %s / %s (%s)" , cur + 1 , final , (1.0 + cur ) / final
48- )
46+ log .info ("Progress: %s / %s (%s)" , cur + 1 , final , (1.0 + cur ) / final )
4947 IJ .showProgress (cur , final )
5048
5149
@@ -82,9 +80,7 @@ def elapsed_time_since(start, end=None):
8280
8381 hours , rem = divmod (end - start , 3600 )
8482 minutes , seconds = divmod (rem , 60 )
85- return "{:0>2}:{:0>2}:{:05.2f}" .format (
86- int (hours ), int (minutes ), seconds
87- )
83+ return "{:0>2}:{:0>2}:{:05.2f}" .format (int (hours ), int (minutes ), seconds )
8884
8985
9086def percentage (part , whole ):
@@ -125,13 +121,9 @@ def calculate_mean_and_stdv(values_list, round_decimals=0):
125121 if not filtered_list :
126122 return 0 , 0
127123
128- mean = round (
129- sum (filtered_list ) / len (filtered_list ), round_decimals
130- )
131- variance = sum ((x - mean ) ** 2 for x in filtered_list ) / len (
132- filtered_list
133- )
134- std_dev = round (variance ** 0.5 , round_decimals )
124+ mean = round (sum (filtered_list ) / len (filtered_list ), round_decimals )
125+ variance = sum ((x - mean ) ** 2 for x in filtered_list ) / len (filtered_list )
126+ std_dev = round (variance ** 0.5 , round_decimals )
135127
136128 return mean , std_dev
137129
@@ -168,9 +160,7 @@ def find_focus(imp):
168160 # Check if more than 1 channel
169161 # FUTURE Could be improved for multi channel
170162 if imp_dimensions [2 ] != 1 :
171- sys .exit (
172- "Image has more than one channel, please reduce dimensionality"
173- )
163+ sys .exit ("Image has more than one channel, please reduce dimensionality" )
174164
175165 # Loop through each time point
176166 for plane in range (1 , imp_dimensions [4 ] + 1 ):
@@ -186,9 +176,7 @@ def find_focus(imp):
186176 # pix_array = pix_array*pix_array
187177
188178 sumpix_array = sum (pix_array )
189- var = sumpix_array / (
190- imp_dimensions [0 ] * imp_dimensions [1 ] * mean
191- )
179+ var = sumpix_array / (imp_dimensions [0 ] * imp_dimensions [1 ] * mean )
192180
193181 if var > norm_var :
194182 norm_var = var
@@ -217,14 +205,10 @@ def send_mail(job_name, recipient, filename, total_execution_time):
217205
218206 # Ensure the sender and server are configured from Prefs
219207 if not sender :
220- log .info (
221- "Sender email is not configured. Please check IJ_Prefs.txt."
222- )
208+ log .info ("Sender email is not configured. Please check IJ_Prefs.txt." )
223209 return
224210 if not server :
225- log .info (
226- "SMTP server is not configured. Please check IJ_Prefs.txt."
227- )
211+ log .info ("SMTP server is not configured. Please check IJ_Prefs.txt." )
228212 return
229213
230214 # Ensure the recipient is provided
@@ -305,12 +289,7 @@ def timed_log(message, as_string=False):
305289 Flag to request the formatted string to be returned instead of printing
306290 it to the log. By default False.
307291 """
308- formatted = (
309- time .strftime ("%H:%M:%S" , time .localtime ())
310- + ": "
311- + message
312- + " "
313- )
292+ formatted = time .strftime ("%H:%M:%S" , time .localtime ()) + ": " + message + " "
314293 if as_string :
315294 return formatted
316295 IJ .log (formatted )
@@ -497,23 +476,17 @@ def write_ordereddict_to_csv(out_file, content):
497476 if not os .path .exists (out_file ):
498477 # If the file does not exist, create it and write the header
499478 with open (out_file , "wb" ) as f :
500- dict_writer = csv .DictWriter (
501- f , content [0 ].keys (), delimiter = ";"
502- )
479+ dict_writer = csv .DictWriter (f , content [0 ].keys (), delimiter = ";" )
503480 dict_writer .writeheader ()
504481 dict_writer .writerows (content )
505482 else :
506483 # If the file exists, append the results
507484 with open (out_file , "ab" ) as f :
508- dict_writer = csv .DictWriter (
509- f , content [0 ].keys (), delimiter = ";"
510- )
485+ dict_writer = csv .DictWriter (f , content [0 ].keys (), delimiter = ";" )
511486 dict_writer .writerows (content )
512487
513488
514- def save_image_in_format (
515- imp , format , out_dir , series , pad_number , split_channels
516- ):
489+ def save_image_in_format (imp , format , out_dir , series , pad_number , split_channels ):
517490 """Save an ImagePlus object in the specified format.
518491
519492 This function provides flexible options for saving ImageJ images in various
@@ -596,9 +569,7 @@ def save_image_in_format(
596569 imp .getNFrames (),
597570 )
598571 )
599- dir_to_save .append (
600- os .path .join (out_dir , "C" + str (channel ))
601- )
572+ dir_to_save .append (os .path .join (out_dir , "C" + str (channel )))
602573 else :
603574 imp_to_use .append (imp )
604575 dir_to_save .append (out_dir )
0 commit comments