Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/imcflibs/imagej/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading