diff --git a/CHANGELOG.md b/CHANGELOG.md index 2647f02..2cae61f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,9 @@ multiple modules. For detailed information, please refer to the * `imcflibs.imagej.misc.run_imarisconvert`: * Now allows to select an output folder. * Adds pixel calibration to the converted file. +* `imcflibs.imagej.misc.save_script_parameters` skips only parameters whose + whole name is in the skip list (`fusion_format` was skipped because it + contains `RM`). * `imcflibs.imagej.misc.subtract_images` now validates the slice count is equal for both images. * `imcflibs.imagej.misc.save_image_with_extension`: fix issue with java path diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 045301d..b1771ee 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -843,8 +843,9 @@ def save_script_parameters( 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): + # Skip if the key is in the skip list (whole name, not a substring: + # e.g. "FUSION_FORMAT" contains "RM") + if key.upper() in skip_keys: log.info("Skipping parameter from skip-list: %s", key) skipped += 1 continue diff --git a/tests/test_misc.py b/tests/test_misc.py index 9f137cb..346fe55 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -51,6 +51,24 @@ def _is_password_style(item): assert contents == "AAA: aaa\nBBB: bbb\n" +def test_save_script_parameters_skip_whole_names(tmp_path, monkeypatch, caplog): + """Only whole names are skipped, case insensitive, not substrings.""" + caplog.set_level(logging.DEBUG) + caplog.clear() + monkeypatch.setattr(imcflibs.imagej.misc, "_is_password_style", lambda item: False) + + script_module = ScriptModule( + input_names=["rm", "fusion_format", "commander"], + inputs={"rm": "roimanager", "fusion_format": "TIFF", "commander": "x"}, + ) + script_globals = {"org.scijava.script.ScriptModule": script_module} + save_script_parameters(script_globals, destination=tmp_path) + + with open(str(tmp_path) + "/script_parameters.txt", "r") as f: + contents = f.read() + assert contents == "fusion_format: TIFF\ncommander: x\n" + + def test_bytes_to_human_readable_simple(): """Ensure common sizes are formatted into human-readable strings.""" assert bytes_to_human_readable(500) == "500.0 bytes"