From 0e19239eefe6eebff32e835d3fb9b8d8a33eba4d Mon Sep 17 00:00:00 2001 From: Rohan Girish Date: Wed, 29 Oct 2025 11:22:34 +0100 Subject: [PATCH 1/2] 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 2/2] 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) + +