@@ -523,7 +523,7 @@ def write_ordereddict_to_csv(out_file, content):
523523 dict_writer .writerows (content )
524524
525525
526- def save_image_in_format (imp , format , out_dir , series , pad_number , split_channels ):
526+ def save_image_in_format (imp , format , out_dir , series , pad_number , split_channels , suffix = "" ):
527527 """Save an ImagePlus object in the specified format.
528528
529529 This function provides flexible options for saving ImageJ images in various
@@ -552,6 +552,8 @@ def save_image_in_format(imp, format, out_dir, series, pad_number, split_channel
552552 If True, split channels and save them individually in separate folders
553553 named "C1", "C2", etc. inside out_dir. If False, save all channels in a
554554 single file.
555+ suffix : str, optional
556+ Text to be added to the filename, by default an empty string.
555557
556558 Notes
557559 -----
@@ -616,20 +618,20 @@ def save_image_in_format(imp, format, out_dir, series, pad_number, split_channel
616618
617619 out_path = pathtools .join2 (
618620 dir_to_save [index ],
619- basename + "_series_" + str (series ).zfill (pad_number ),
621+ basename + "_series_" + str (series ).zfill (pad_number ) + suffix ,
620622 )
621623
622624 if format == "ImageJ-TIF" :
623625 pathtools .create_directory (dir_to_save [index ])
624- IJ .saveAs (current_imp , "Tiff" , out_path + ".tif" )
626+ IJ .saveAs (current_imp , "Tiff" , out_path + suffix + ".tif" )
625627
626628 elif format == "BMP" :
627629 out_folder = os .path .join (out_dir , basename + os .path .sep )
628630 pathtools .create_directory (out_folder )
629631 StackWriter .save (current_imp , out_folder , "format=bmp" )
630632
631633 else :
632- bf .export (current_imp , out_path + out_ext [format ])
634+ bf .export (current_imp , out_path + suffix + out_ext [format ])
633635
634636 current_imp .close ()
635637
0 commit comments