From e6c54a4dc5efedb57764db809fa7bea893b7bed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coussat?= Date: Mon, 28 Sep 2026 16:17:02 +0200 Subject: [PATCH 1/3] ENH: Test PCT against GATE 10.1.1 --- .github/workflows/build-test-package.yml | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index 94de739..b7de131 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -51,7 +51,8 @@ jobs: echo "Installing wheel: $wheel" pip install $wheel - pip install pytest uproot opengate hepunits + # Install dependencies for tests as specified in pyproject.toml + pip install --group test # Force the installation of Geant4 data, required by opengate opengate_info diff --git a/pyproject.toml b/pyproject.toml index 23be727..1333bee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ dependencies = [ "itk-rtk == 2.7.*" ] [dependency-groups] -test = ["pytest", "uproot", "opengate"] +test = ["pytest", "uproot", "opengate == 10.1.1"] [project.scripts] pctbinning = "itk.pctbinning:main" From 36382836c87bfa2b59967a7aaa39a52c46ea86bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coussat?= Date: Mon, 28 Sep 2026 16:17:45 +0200 Subject: [PATCH 2/3] BUG: Adapt PCT to GATE 10.1.1 --- applications/pctdoublelut/pctdoublelut.py | 12 +++---- applications/pctweplfit/pctweplfit.py | 2 +- test/pct_application_test.py | 40 +++++++++++------------ 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/applications/pctdoublelut/pctdoublelut.py b/applications/pctdoublelut/pctdoublelut.py index 1ed7189..974c241 100644 --- a/applications/pctdoublelut/pctdoublelut.py +++ b/applications/pctdoublelut/pctdoublelut.py @@ -108,6 +108,7 @@ def tof_fit_mc( # Geometry sim.world.material = "G4_AIR" sim.world.size = [4 * m, 4 * m, 4 * m] + sim.world.set_max_step_size(1.0 * mm) # Phantom if wepl > 0.0: @@ -119,7 +120,6 @@ def tof_fit_mc( ] phantom.material = material phantom.color = blue - phantom.set_max_step_size(1.0 * mm) # Beam source = sim.add_source("GenericSource", "mybeam") @@ -139,7 +139,7 @@ def tof_fit_mc( # Physics list sim.physics_manager.physics_list_name = "G4EmStandardPhysics_option4" - sim.physics_manager.set_user_limits_particles(["proton"]) + sim.physics_manager.user_limits_particles = "proton" # Phase spaces def add_detector(name, translation, attach_to_phantom=False): @@ -163,12 +163,8 @@ def add_detector(name, translation, attach_to_phantom=False): "LocalTime", "PostVelocity", ] - if int(gate.utility.version("opengate").split(".")[1]) > 0: - F = gate.actors.filters.GateFilterBuilder() - phase_space.filter = F.ParticleName == "proton" - else: - particle_filter = sim.add_filter("ParticleFilter", "Filter" + name) - particle_filter.particle = "proton" + F = gate.actors.filters.GateFilterBuilder() + phase_space.filter = F.ParticleName == "proton" add_detector("In", [0.0 * mm, 0.0 * mm, (-wepl / 2) * mm]) add_detector("Out", [0.0 * mm, 0.0 * mm, (wepl / 2) * mm]) diff --git a/applications/pctweplfit/pctweplfit.py b/applications/pctweplfit/pctweplfit.py index c4b8595..c20641f 100644 --- a/applications/pctweplfit/pctweplfit.py +++ b/applications/pctweplfit/pctweplfit.py @@ -90,7 +90,7 @@ def tof_fit_mc( # Physics list sim.physics_manager.physics_list_name = "G4EmStandardPhysics_option4" - sim.physics_manager.set_user_limits_particles(["proton"]) + sim.physics_manager.user_limits_particles = "proton" # Phase spaces def add_detector(name, translation, attach_to_phantom=False): diff --git a/test/pct_application_test.py b/test/pct_application_test.py index 9043d9c..602e952 100644 --- a/test/pct_application_test.py +++ b/test/pct_application_test.py @@ -84,16 +84,16 @@ def test_doublelut_application(tmp_path): tof_coeffs = np.loadtxt(output / "tof_coeffs_9.txt") tof_reference = np.array( [ - -1.290921042580240798e-19, - 1.351207981731195971e-16, - -5.963202845355236675e-14, - 1.443362133502381465e-11, - -2.084980429067098285e-09, - 1.829330424219974866e-07, - -9.443542359443581318e-06, - 2.631908622195730887e-04, - 2.921848578064085208e-03, - 2.715972855380448421e-03, + -1.304835138529633472e-19, + 1.356468922636278510e-16, + -5.942720434270841880e-14, + 1.427297715745322610e-11, + -2.045269455668975767e-09, + 1.780062155625161403e-07, + -9.118495781246014652e-06, + 2.525195871208434648e-04, + 3.058213313702242298e-03, + 2.589942534059123773e-03, ] ) assert np.allclose(tof_coeffs, tof_reference) @@ -101,16 +101,16 @@ def test_doublelut_application(tmp_path): vel_coeffs = np.loadtxt(output / "vel_coeffs_9.txt") vel_reference = np.array( [ - 5.023900900539231649e-18, - -5.304589281207117926e-15, - 2.358303897263661076e-12, - -5.748047473922940780e-10, - 8.360830241840195663e-08, - -7.391334678087265226e-06, - 3.842573655671269075e-04, - -1.096847900269657186e-02, - -1.773574286549965684e-02, - 1.696161111400466552e02, + 4.582905610876915593e-18, + -4.742816184714826704e-15, + 2.062923179381136339e-12, + -4.910573707663995126e-10, + 6.964091908878167104e-08, + -5.995324018840303797e-06, + 3.031542041296401437e-04, + -8.476856480304249125e-03, + -4.918237198608615968e-02, + 1.696467164517849255e02, ] ) assert np.allclose(vel_reference, vel_coeffs) From c639447b63aac491c8f641a24492ea61e3f83d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coussat?= Date: Tue, 29 Sep 2026 09:01:30 +0200 Subject: [PATCH 3/3] ENH: Decrease verbosity of tests --- test/pct_application_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pct_application_test.py b/test/pct_application_test.py index 602e952..3dcc6a0 100644 --- a/test/pct_application_test.py +++ b/test/pct_application_test.py @@ -50,7 +50,7 @@ def test_pairprotons_application( def test_weplfit_application(tmp_path): output = tmp_path / "weplfit" pct.pctweplfit( - f"-o {output} --path-type phantom_length -d 220 -e 200 -l 220 --seed 1234 -v" + f"-o {output} --path-type phantom_length -d 220 -e 200 -l 220 --seed 1234" ) with open(output / "tof_to_wepl_fit_deg3.json", encoding="utf-8") as f: @@ -193,7 +193,7 @@ def test_lomalinda_application( ): output = tmp_path_factory.getbasetemp() / "lomalinda.mhd" pct.pctlomalinda( - f"-i {lomalinda_data} -o {output} --plane-in -167.2 --plane-out 167.2 --ps recoENTRY -v" + f"-i {lomalinda_data} -o {output} --plane-in -167.2 --plane-out 167.2 --ps recoENTRY" ) output0000 = str(output).replace(".", "0000.") test_lomalinda = itk.array_from_image(itk.imread(output0000))