Skip to content
Merged
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: 2 additions & 1 deletion .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions applications/pctdoublelut/pctdoublelut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand All @@ -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):
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion applications/pctweplfit/pctweplfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
44 changes: 22 additions & 22 deletions test/pct_application_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -84,33 +84,33 @@ 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)

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)
Expand Down Expand Up @@ -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))
Expand Down
Loading