From 6155eddba447d87a33435cfca12ed7b883ed12bd Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Tue, 6 May 2025 15:02:09 +0200 Subject: [PATCH 1/7] Add option to save IMS file in a specified location --- src/imcflibs/imagej/misc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index dcf66f8a..f6a8ac32 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -669,7 +669,7 @@ def locate_latest_imaris(paths_to_check=None): return imaris_paths[-1] -def run_imarisconvert(file_path, pixel_calibration=None): +def run_imarisconvert(file_path, output_folder=None, pixel_calibration=None): """Convert a given file to Imaris format using ImarisConvert. Convert the input image file to Imaris format (Imaris5) using the @@ -680,6 +680,8 @@ def run_imarisconvert(file_path, pixel_calibration=None): ---------- file_path : str Absolute path to the input image file. + output_folder : str, optional + Folder where the newly created IMS file will be saved, by default None. pixel_calibration : tuple or list, optional Sequence of 3 values (x, y, z) representing voxel dimensions to be set during conversion, by default None. @@ -693,9 +695,12 @@ def run_imarisconvert(file_path, pixel_calibration=None): imaris_path = locate_latest_imaris() + if not output_folder: + output_folder = os.getcwd() + command = 'ImarisConvert.exe -i "%s" -of Imaris5 -o "%s"' % ( file_path, - file_path.replace(file_extension, ".ims"), + os.path.join(output_folder, file_path.replace(file_extension, ".ims")), ) if pixel_calibration: command = command + " --voxelsizex %s --voxelsizey %s --voxelsizez %s" % ( From f6804ee6081aad659902e9243655fa38be8e8972 Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 10:36:35 +0100 Subject: [PATCH 2/7] feat(misc): reorder parameters in run_imarisconvert function - Changed the order of parameters in the run_imarisconvert function to improve compatibility. - Updated docstring to reflect the new parameter order. --- src/imcflibs/imagej/misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index f6a8ac32..48ccdb84 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -669,7 +669,7 @@ def locate_latest_imaris(paths_to_check=None): return imaris_paths[-1] -def run_imarisconvert(file_path, output_folder=None, pixel_calibration=None): +def run_imarisconvert(file_path, pixel_calibration=None, output_folder=None): """Convert a given file to Imaris format using ImarisConvert. Convert the input image file to Imaris format (Imaris5) using the @@ -680,11 +680,11 @@ def run_imarisconvert(file_path, output_folder=None, pixel_calibration=None): ---------- file_path : str Absolute path to the input image file. - output_folder : str, optional - Folder where the newly created IMS file will be saved, by default None. pixel_calibration : tuple or list, optional Sequence of 3 values (x, y, z) representing voxel dimensions to be set during conversion, by default None. + output_folder : str, optional + Folder where the newly created IMS file will be saved, by default None. """ # in case the given file has the suffix `.ids` (meaning it is part of an # ICS-1 `.ics`+`.ids` pair), point ImarisConvert to the `.ics` file instead: From 61255957827af2bff005917274ed1f18130d2ba1 Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 10:54:02 +0100 Subject: [PATCH 3/7] fix(run_imarisconvert): set default output folder to file's directory * Updated the default output folder in run_imarisconvert function to the directory of the input file if not specified. * This change ensures that converted files are saved in a more intuitive location. --- src/imcflibs/imagej/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 48ccdb84..f53476d1 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -669,7 +669,7 @@ def locate_latest_imaris(paths_to_check=None): return imaris_paths[-1] -def run_imarisconvert(file_path, pixel_calibration=None, output_folder=None): +def run_imarisconvert(file_path, pixel_calibration=None, output_folder=""): """Convert a given file to Imaris format using ImarisConvert. Convert the input image file to Imaris format (Imaris5) using the @@ -696,7 +696,7 @@ def run_imarisconvert(file_path, pixel_calibration=None, output_folder=None): imaris_path = locate_latest_imaris() if not output_folder: - output_folder = os.getcwd() + output_folder = os.path.dirname(file_path) command = 'ImarisConvert.exe -i "%s" -of Imaris5 -o "%s"' % ( file_path, From 08d9976105a4e65f9333ce3681e3f45fd0f5e964 Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 14:46:05 +0100 Subject: [PATCH 4/7] feat(run_imarisconvert): enhance output folder handling - Add notes on output folder behavior in docstring. - Specify that if no output folder is provided, the IMS file will be saved in the input file's directory. - Clarify output filename construction from input filename. --- src/imcflibs/imagej/misc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index f53476d1..67774320 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -685,6 +685,16 @@ def run_imarisconvert(file_path, pixel_calibration=None, output_folder=""): conversion, by default None. output_folder : str, optional Folder where the newly created IMS file will be saved, by default None. + + Notes + ----- + - If `output_folder` is not provided (or is empty), the converted `.ims` + file will be written to the same directory as the input file. + - The output filename is constructed by taking the input filename and + replacing its extension with `.ims` (for example, + `/path/to/image.czi` -> `/path/to/image.ims`). + - If the input has an `.ids` extension (part of an ICS-1 pair), the + corresponding `.ics` file is used as the source before conversion. """ # in case the given file has the suffix `.ids` (meaning it is part of an # ICS-1 `.ics`+`.ids` pair), point ImarisConvert to the `.ics` file instead: From ac1e860facc4526b943e1513f62b47b9c25f3e43 Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 14:47:35 +0100 Subject: [PATCH 5/7] fix(run_imarisconvert): clarify output folder behavior - Update docstring to specify that if no output folder is provided, the IMS file will be saved in the same directory as the input file. --- src/imcflibs/imagej/misc.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 67774320..e51156ba 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -684,12 +684,11 @@ def run_imarisconvert(file_path, pixel_calibration=None, output_folder=""): Sequence of 3 values (x, y, z) representing voxel dimensions to be set during conversion, by default None. output_folder : str, optional - Folder where the newly created IMS file will be saved, by default None. + Folder where the newly created IMS file will be saved, by default None + which will result in the output file being saved in the same directory as the input file. Notes ----- - - If `output_folder` is not provided (or is empty), the converted `.ims` - file will be written to the same directory as the input file. - The output filename is constructed by taking the input filename and replacing its extension with `.ims` (for example, `/path/to/image.czi` -> `/path/to/image.ims`). From 2c604ed254068bde1965433ed36595a700f3336c Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 21 Jan 2026 12:00:52 +0100 Subject: [PATCH 6/7] Docstring formatting / conventions --- src/imcflibs/imagej/misc.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 1fe13606..10e32d5d 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -693,19 +693,18 @@ def run_imarisconvert(file_path, pixel_calibration=None, output_folder=""): file_path : str Absolute path to the input image file. pixel_calibration : tuple or list, optional - Sequence of 3 values (x, y, z) representing voxel dimensions to be set during - conversion, by default None. + Sequence of 3 values (x, y, z) representing voxel dimensions to be set + during conversion, by default None. output_folder : str, optional - Folder where the newly created IMS file will be saved, by default None - which will result in the output file being saved in the same directory as the input file. + Folder where the newly created IMS file will be saved. If empty (or not + supplied), the directory of the input file will be used. Notes ----- - - The output filename is constructed by taking the input filename and - replacing its extension with `.ims` (for example, - `/path/to/image.czi` -> `/path/to/image.ims`). + - The output filename is constructed by replacing extension of the input + filename with `.ims` (e.g. `/path/to/image.czi` -> `/path/to/image.ims`). - If the input has an `.ids` extension (part of an ICS-1 pair), the - corresponding `.ics` file is used as the source before conversion. + corresponding `.ics` file is used instead. """ # in case the given file has the suffix `.ids` (meaning it is part of an # ICS-1 `.ics`+`.ids` pair), point ImarisConvert to the `.ics` file instead: From 1a0f954a7bdc1a1621ed8212161b8e67fdf95d31 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 21 Jan 2026 12:01:06 +0100 Subject: [PATCH 7/7] Supply input file name in log messages --- src/imcflibs/imagej/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 10e32d5d..20b02540 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -733,9 +733,9 @@ def run_imarisconvert(file_path, pixel_calibration=None, output_folder=""): timed_log("Converting to Imaris5 .ims...") result = subprocess.call(command, shell=True, cwd=imaris_path) if result == 0: - timed_log("Conversion to .ims is finished.") + timed_log("Conversion to .ims is finished: %s" % file_path) else: - timed_log("Conversion failed with error code: %d" % result) + timed_log("Error converting [%s]: %d" % (file_path, result)) def save_script_parameters(destination, save_file_name="script_parameters.txt"):