From 0e19239eefe6eebff32e835d3fb9b8d8a33eba4d Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 29 Oct 2025 11:22:34 +0100 Subject: [PATCH 01/15] Add example to docstring for clarity --- src/imcflibs/imagej/omerotools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/imcflibs/imagej/omerotools.py b/src/imcflibs/imagej/omerotools.py index 31f4bdd4..7dad756f 100644 --- a/src/imcflibs/imagej/omerotools.py +++ b/src/imcflibs/imagej/omerotools.py @@ -47,6 +47,15 @@ def parse_url(client, omero_str): ------- list(fr.igred.omero.repository.ImageWrapper) List of ImageWrappers parsed from the string. + + Examples + -------- + >>> from fr.igred.omero import Client + >>> client = Client() + >>> OMERO_LINK = "123456" + >>> img_wrappers = omerotools.parse_url(client, OMERO_LINK) + >>> for wrapper in img_wrappers: + >>> imp = wpr.toImagePlus(client) """ image_ids = [] dataset_ids = [] From 7834a922ea2f61efc37096cdd5f45ceba9b2144a Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 29 Oct 2025 17:34:48 +0100 Subject: [PATCH 02/15] Add method to save Fiji script parameters to file Calls on scijava.script.ScriptModule through Python globals to access only the user-given parameters and not other variables at run-time. --- src/imcflibs/imagej/misc.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index edd4509e..7b972ba2 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -7,6 +7,7 @@ import subprocess import sys import time +from org.scijava.script import ScriptModule from ij import IJ # pylint: disable-msg=import-error from ij.plugin import Duplicator, ImageCalculator, StackWriter @@ -701,3 +702,35 @@ def run_imarisconvert(file_path): IJ.log("Conversion to .ims is finished.") else: IJ.log("Conversion failed with error code: %d" % result) + + +def save_script_parameters(destination, save_file_name="script_parameters.txt"): + """Save all Fiji script parameters to a text file. + + Parameters + ---------- + destination : str + Directory where the script parameters file will be saved. + save_file_name : str, optional + Name of the script parameters file, by default "script_parameters.txt". + """ + # Get the ScriptModule object from globals made by Fiji + module = globals().get("org.scijava.script.ScriptModule") + if module is None: + print("No ScriptModule found- skipping saving script parameters.") + return + + # Retrieve the input parameters from the scijava module + inputs = module.getInputs() + destination = str(destination) + out_path = os.path.join(destination, save_file_name) + + # Write the parameters to output file + with open(out_path, "w") as f: + for key in inputs.keySet(): + val = inputs.get(key) + f.write("%s: %s\n" % (key, str(val))) + + print("Saved script parameters to: %s" % out_path) + + From 02d84d8346eb9c1895e83d1d1652ffa83bb6eb1f Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Tue, 4 Nov 2025 14:40:05 +0100 Subject: [PATCH 03/15] Add keys to skip logging --- src/imcflibs/imagej/misc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 7b972ba2..1cbf9dac 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -726,8 +726,11 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): out_path = os.path.join(destination, save_file_name) # Write the parameters to output file + skip_keys = ["PASSWORD", "USERNAME", "SJLOG", "COMMAND", "RM"] with open(out_path, "w") as f: for key in inputs.keySet(): + if any(s in key.upper() for s in skip_keys): + continue val = inputs.get(key) f.write("%s: %s\n" % (key, str(val))) From c7c0d3e89befac5e6a00b605b071d195dbf59ba8 Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 5 Nov 2025 09:30:44 +0100 Subject: [PATCH 04/15] Update method to save Fiji script parameters The method now ignores password in a clean way, and skips some other non-essential runtime keys. --- src/imcflibs/imagej/misc.py | 44 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 1cbf9dac..1af50fcd 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -713,27 +713,51 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): Directory where the script parameters file will be saved. save_file_name : str, optional Name of the script parameters file, by default "script_parameters.txt". + + Notes + ---------- + This function records all input parameters defined in the Fiji script header + (e.g. #@ String) to a text file. + + The following parameters are excluded: + - Parameters explicitly declared with `style="password"` are ignored. + - Runtime keys (e.g. 'SJLOG', 'COMMAND', 'RM') are also skipped. """ # Get the ScriptModule object from globals made by Fiji module = globals().get("org.scijava.script.ScriptModule") if module is None: - print("No ScriptModule found- skipping saving script parameters.") + print("No ScriptModule found — skipping saving script parameters.") return - # Retrieve the input parameters from the scijava module - inputs = module.getInputs() destination = str(destination) out_path = os.path.join(destination, save_file_name) - - # Write the parameters to output file - skip_keys = ["PASSWORD", "USERNAME", "SJLOG", "COMMAND", "RM"] + + # Access script metadata and parameter map + script_info = module.getInfo() + inputs = module.getInputs() + + # Keys to skip explicitly (case-insensitive match) + skip_keys = ["USERNAME", "SJLOG", "COMMAND", "RM"] + with open(out_path, "w") as f: - for key in inputs.keySet(): - if any(s in key.upper() for s in skip_keys): + for item in script_info.inputs(): + key = item.getName() + + # Skip if any keys are in the skip list + if any(skip in key.upper() for skip in skip_keys): continue - val = inputs.get(key) - f.write("%s: %s\n" % (key, str(val))) + + # Skip if parameter is declared with style="password" + style = item.getWidgetStyle() + if style is not None and style.lower() == "password": + continue + + # Write all other parameters + if inputs.containsKey(key): + val = inputs.get(key) + f.write("%s: %s\n" % (key, str(val))) print("Saved script parameters to: %s" % out_path) + From cdda918932d3502d7695cdb49cc27594a0c776c1 Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 5 Nov 2025 09:35:23 +0100 Subject: [PATCH 05/15] Run black formatter --- src/imcflibs/imagej/misc.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 1af50fcd..7568d9e3 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -702,7 +702,7 @@ def run_imarisconvert(file_path): IJ.log("Conversion to .ims is finished.") else: IJ.log("Conversion failed with error code: %d" % result) - + def save_script_parameters(destination, save_file_name="script_parameters.txt"): """Save all Fiji script parameters to a text file. @@ -713,9 +713,9 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): Directory where the script parameters file will be saved. save_file_name : str, optional Name of the script parameters file, by default "script_parameters.txt". - + Notes - ---------- + ----- This function records all input parameters defined in the Fiji script header (e.g. #@ String) to a text file. @@ -758,6 +758,3 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): f.write("%s: %s\n" % (key, str(val))) print("Saved script parameters to: %s" % out_path) - - - From eed68d8bc109e5805329c0c8b121834f59040175 Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 5 Nov 2025 09:44:28 +0100 Subject: [PATCH 06/15] Remove redundant ScriptModule import --- src/imcflibs/imagej/misc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 7568d9e3..847c6dbf 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -7,7 +7,6 @@ import subprocess import sys import time -from org.scijava.script import ScriptModule from ij import IJ # pylint: disable-msg=import-error from ij.plugin import Duplicator, ImageCalculator, StackWriter From cd9795fe217ef7887cd3bcb1948cf21375f17cd4 Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 12 Nov 2025 11:23:00 +0100 Subject: [PATCH 07/15] Remove redundant comments --- 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 847c6dbf..7b9ec0a3 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -731,11 +731,11 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): destination = str(destination) out_path = os.path.join(destination, save_file_name) - # Access script metadata and parameter map + # Access script metadata and inputs script_info = module.getInfo() inputs = module.getInputs() - # Keys to skip explicitly (case-insensitive match) + # Keys to skip explicitly skip_keys = ["USERNAME", "SJLOG", "COMMAND", "RM"] with open(out_path, "w") as f: @@ -751,7 +751,6 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): if style is not None and style.lower() == "password": continue - # Write all other parameters if inputs.containsKey(key): val = inputs.get(key) f.write("%s: %s\n" % (key, str(val))) From 1b74c4e43807e7718c3cc3b5192f88030f73e367 Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 14 Jan 2026 14:09:36 +0100 Subject: [PATCH 08/15] Change from string literal to public constant --- src/imcflibs/imagej/misc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 7b9ec0a3..ab57f783 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -16,6 +16,9 @@ from . import bioformats as bf from . import prefs +from org.scijava.widget import WidgetStyle +from org.scijava.widget import TextWidget + def show_status(msg): """Update the ImageJ status bar and issue a log message. @@ -746,9 +749,8 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): if any(skip in key.upper() for skip in skip_keys): continue - # Skip if parameter is declared with style="password" - style = item.getWidgetStyle() - if style is not None and style.lower() == "password": + # Skip if parameter is declared with password style + if WidgetStyle.isStyle(item, TextWidget.PASSWORD_STYLE): continue if inputs.containsKey(key): From 38376ec6b04a73f0f972548710db3f3ea31981bc Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Thu, 15 Jan 2026 14:53:26 +0100 Subject: [PATCH 09/15] Change mocks version to 0.12.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c722202b..4d738101 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ version = "0.0.0" # - or: python = ">=3.10" [tool.poetry.dependencies] -imcf-fiji-mocks = ">=0.10.0" +imcf-fiji-mocks = ">=0.12.0" python = ">=2.7" python-micrometa = "^15.2.2" sjlogging = ">=0.5.2" From bf7fd7d5c651fe2f40e2b5bc9a3d45bd760888ff Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Thu, 15 Jan 2026 14:59:07 +0100 Subject: [PATCH 10/15] Update poetry.lock for mocks v0.12.0 --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 833588fd..861ac5ca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -105,13 +105,13 @@ test = ["pytest (>=6)"] [[package]] name = "imcf-fiji-mocks" -version = "0.10.0" +version = "0.12.0" description = "Mocks collection for Fiji-Python. Zero functional code." optional = false python-versions = ">=2.7" files = [ - {file = "imcf_fiji_mocks-0.10.0-py2.py3-none-any.whl", hash = "sha256:476927d82fa0e93b0b0b738f82cab60e180cf0da5b3dd09dc6a5336b08e18d2d"}, - {file = "imcf_fiji_mocks-0.10.0.tar.gz", hash = "sha256:d1f3302031cad5f1d15388bf337025bbfb59037a04e79a102de59093e643a5f5"}, + {file = "imcf_fiji_mocks-0.12.0-py2.py3-none-any.whl", hash = "sha256:00e746e1ecdfb9743ef0e6886b9234663aaf3c762a77c162c54bb02d95a53dac"}, + {file = "imcf_fiji_mocks-0.12.0.tar.gz", hash = "sha256:4e55836503fee0564aa7fbdd8c019504d1d3f4e9c06b1cd269242af2da3d7450"}, ] [[package]] @@ -271,4 +271,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10" -content-hash = "6b4a1828157bbddc15f61de0427a3d7970a61da1750f2cbf9e160f1b7546d7c9" +content-hash = "e107ad5e21140ce701c48b7f84654dc7dce045ca05550a06b6dc16f8f19136a7" From b7e32fb7d950794ddb5b3abda04ac53b627312c8 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 16 Jan 2026 12:08:13 +0100 Subject: [PATCH 11/15] Replace UTF-8 dash with an ASCII minus Using UTF-8 is still shaky in the Jython 2.7 environment, so if there is no strong need for it, simply stick to ASCII. --- src/imcflibs/imagej/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index ab57f783..2286dd6d 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -728,7 +728,7 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): # Get the ScriptModule object from globals made by Fiji module = globals().get("org.scijava.script.ScriptModule") if module is None: - print("No ScriptModule found — skipping saving script parameters.") + print("No ScriptModule found - skipping saving script parameters.") return destination = str(destination) From fc32cca74409fbd46096f2b2798969b70e37c454 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 16 Jan 2026 12:10:33 +0100 Subject: [PATCH 12/15] Use IJ.log() instead of print() Also see #45 --- src/imcflibs/imagej/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 2286dd6d..446c4cc3 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -728,7 +728,7 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): # Get the ScriptModule object from globals made by Fiji module = globals().get("org.scijava.script.ScriptModule") if module is None: - print("No ScriptModule found - skipping saving script parameters.") + IJ.log("No ScriptModule found - skipping saving script parameters.") return destination = str(destination) From 1be76257efda14aa78d107980532c5039d228177 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 16 Jan 2026 12:10:42 +0100 Subject: [PATCH 13/15] Minor syntax / rendering fix --- src/imcflibs/imagej/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 446c4cc3..adcd1821 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -719,7 +719,7 @@ def save_script_parameters(destination, save_file_name="script_parameters.txt"): Notes ----- This function records all input parameters defined in the Fiji script header - (e.g. #@ String) to a text file. + (e.g. `#@ String`) to a text file. The following parameters are excluded: - Parameters explicitly declared with `style="password"` are ignored. From d50577f946856eba2e2b24ae2ff030d04f91f84e Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 16 Jan 2026 13:46:28 +0100 Subject: [PATCH 14/15] Update mocks dependency to version to 0.13.0 --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index 861ac5ca..f3ab6e8e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -105,13 +105,13 @@ test = ["pytest (>=6)"] [[package]] name = "imcf-fiji-mocks" -version = "0.12.0" +version = "0.13.0" description = "Mocks collection for Fiji-Python. Zero functional code." optional = false python-versions = ">=2.7" files = [ - {file = "imcf_fiji_mocks-0.12.0-py2.py3-none-any.whl", hash = "sha256:00e746e1ecdfb9743ef0e6886b9234663aaf3c762a77c162c54bb02d95a53dac"}, - {file = "imcf_fiji_mocks-0.12.0.tar.gz", hash = "sha256:4e55836503fee0564aa7fbdd8c019504d1d3f4e9c06b1cd269242af2da3d7450"}, + {file = "imcf_fiji_mocks-0.13.0-py2.py3-none-any.whl", hash = "sha256:cb6be2b4af480a9340d182c2bccff78f996c0048abbf05380e214a91a2f89bf2"}, + {file = "imcf_fiji_mocks-0.13.0.tar.gz", hash = "sha256:c29f2dc82a0d4e94963a9f7a455f17012ee37aa8eda4d1c9e9565496df50b063"}, ] [[package]] @@ -271,4 +271,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10" -content-hash = "e107ad5e21140ce701c48b7f84654dc7dce045ca05550a06b6dc16f8f19136a7" +content-hash = "60258d00dfaba337eff7fb89a463d281320df110050c0360a3e87397a1ea3398" diff --git a/pyproject.toml b/pyproject.toml index 4d738101..409f8e88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ version = "0.0.0" # - or: python = ">=3.10" [tool.poetry.dependencies] -imcf-fiji-mocks = ">=0.12.0" +imcf-fiji-mocks = ">=0.13.0" python = ">=2.7" python-micrometa = "^15.2.2" sjlogging = ">=0.5.2" From 8145904b0e1e2544db86fb0c4f92d3159d2c0636 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 16 Jan 2026 13:56:12 +0100 Subject: [PATCH 15/15] Add instructions for working around poetry's stubborn cache --- poetry.lock.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/poetry.lock.md b/poetry.lock.md index 6bc2a1c5..8f55a0ae 100644 --- a/poetry.lock.md +++ b/poetry.lock.md @@ -12,5 +12,14 @@ rather the Poetry wrapper script has to be used like this: scripts/run-poetry.sh lock --no-update ``` +Sometimes poetry is refusing to update its cache for unknown reasons, resulting +in a message saying `doesn't match any versions, version solving failed` or +similar. To solve this, fully clear the cache and re-run the `lock` command: + +```bash +scripts/run-poetry.sh cache clear --all -- PyPI +scripts/run-poetry.sh lock --no-update +``` + [1]: https://pypi.org/project/imcf-fiji-mocks [2]: https://python-poetry.org/docs/basic-usage/#committing-your-poetrylock-file-to-version-control