Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/imcflibs/imagej/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
dict_writer.writerows(content)


def save_image_in_format(imp, format, out_dir, series, pad_number, split_channels):
def save_image_in_format(imp, format, out_dir, series, pad_number, split_channels, suffix=""):
"""Save an ImagePlus object in the specified format.

This function provides flexible options for saving ImageJ images in various
Expand Down Expand Up @@ -552,6 +552,8 @@
If True, split channels and save them individually in separate folders
named "C1", "C2", etc. inside out_dir. If False, save all channels in a
single file.
suffix : str, optional
Text to be added to the filename, by default an empty string.

Notes
-----
Expand Down Expand Up @@ -616,20 +618,20 @@

out_path = os.path.join(
dir_to_save[index],
basename + "_series_" + str(series).zfill(pad_number),
basename + "_series_" + str(series).zfill(pad_number) + suffix,
)

if format == "ImageJ-TIF":
pathtools.create_directory(dir_to_save[index])
IJ.saveAs(current_imp, "Tiff", out_path + ".tif")
IJ.saveAs(current_imp, "Tiff", out_path + suffix + ".tif")

Check warning on line 626 in src/imcflibs/imagej/misc.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/misc.py#L626

Added line #L626 was not covered by tests

elif format == "BMP":
out_folder = os.path.join(out_dir, basename + os.path.sep)
pathtools.create_directory(out_folder)
StackWriter.save(current_imp, out_folder, "format=bmp")

else:
bf.export(current_imp, out_path + out_ext[format])
bf.export(current_imp, out_path + suffix + out_ext[format])

Check warning on line 634 in src/imcflibs/imagej/misc.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/misc.py#L634

Added line #L634 was not covered by tests

current_imp.close()

Expand Down
Loading