diff --git a/localizer/lib/ai_decoupling.py b/localizer/lib/ai_decoupling.py index 13ee35e..9ac38f4 100644 --- a/localizer/lib/ai_decoupling.py +++ b/localizer/lib/ai_decoupling.py @@ -62,16 +62,16 @@ def decouple_image(self, input_node, modality, **kwargs): tmp_path = str(self.plugin_path / "tmp.nii") slicer.util.saveNode(input_node, tmp_path) - # Build command using new subcommand format + # Build command using the current ADAD subcommand. cmd = [ str(self.executable_path), - "decouple", + "adad", "--input", tmp_path, "--output", str(self.plugin_path / "Normalized.nii"), "--modality", normalized_modality ] - print(f"Running decouple command: {' '.join(cmd)}") + print(f"Running ADAD command: {' '.join(cmd)}") try: result = subprocess.run(cmd, capture_output=True, text=True, cwd=self.plugin_path) except Exception as e: diff --git a/localizer/src/CMakeLists.txt b/localizer/src/CMakeLists.txt index 92ec770..38745b5 100644 --- a/localizer/src/CMakeLists.txt +++ b/localizer/src/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeList.txt: DCCCcore Refactored Version cmake_minimum_required(VERSION 3.21) -project(DCCCcore VERSION 4.2.5) +project(DCCCcore VERSION 4.2.6) set(DCCCCORE_VERSION_SUFFIX "") set(DCCCCORE_SOFTWARE_VERSION "${PROJECT_VERSION}${DCCCCORE_VERSION_SUFFIX}") diff --git a/localizer/src/conanfile.py b/localizer/src/conanfile.py index a558a7e..59f22f3 100644 --- a/localizer/src/conanfile.py +++ b/localizer/src/conanfile.py @@ -4,7 +4,7 @@ class AppConan(ConanFile): name = "DCCCcore" - version = "4.2.5" + version = "4.2.6" settings = "os", "arch", "compiler", "build_type" generators = "CMakeDeps", "CMakeToolchain" diff --git a/localizer/src/core/config/Version.h b/localizer/src/core/config/Version.h index 9248faf..3ff495e 100644 --- a/localizer/src/core/config/Version.h +++ b/localizer/src/core/config/Version.h @@ -1,4 +1,4 @@ #pragma once #include -const std::string SOFTWARE_VERSION = "4.2.5"; +const std::string SOFTWARE_VERSION = "4.2.6"; diff --git a/localizer/src/tests/test_ui_ai_decoupling.py b/localizer/src/tests/test_ui_ai_decoupling.py new file mode 100644 index 0000000..1a99ff7 --- /dev/null +++ b/localizer/src/tests/test_ui_ai_decoupling.py @@ -0,0 +1,47 @@ +import importlib +import sys +import types +from pathlib import Path + + +def _load_ai_decoupling_logic(): + if "slicer" not in sys.modules: + sys.modules["slicer"] = types.SimpleNamespace( + util=types.SimpleNamespace(saveNode=lambda *_args: True) + ) + else: + slicer_module = sys.modules["slicer"] + if not hasattr(slicer_module, "util"): + slicer_module.util = types.SimpleNamespace() + slicer_module.util.saveNode = lambda *_args: True + + repo_root = Path(__file__).resolve().parents[3] + sys.path.insert(0, str(repo_root / "localizer" / "lib")) + module = importlib.import_module("ai_decoupling") + return module, module.AIDecouplingLogic + + +def test_decouple_image_uses_adad_subcommand(monkeypatch): + module, logic_type = _load_ai_decoupling_logic() + logic = logic_type("/tmp/plugin") + captured = {} + + def fake_run(command, **kwargs): + captured["command"] = command + captured["kwargs"] = kwargs + return types.SimpleNamespace(returncode=0, stdout="ADAD score: 1", stderr="") + + monkeypatch.setattr(module.subprocess, "run", fake_run) + monkeypatch.setattr( + logic, + "_load_result_volumes", + lambda: (object(), object(), object()), + ) + + input_node = types.SimpleNamespace(GetName=lambda: "PET") + success, *_ = logic.decouple_image(input_node, "Abeta") + + assert success + assert captured["command"][:2] == [str(logic.executable_path), "adad"] + assert captured["command"][-2:] == ["--modality", "abeta"] + assert captured["kwargs"]["cwd"] == Path("/tmp/plugin")