Skip to content

Commit 7a57e3e

Browse files
committed
Merge branch 'photonTest' into 'develop'
photon Test See merge request e040/e0404/pyRadPlan!180
2 parents 18bc66b + ad7489d commit 7a57e3e

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ A minimal script is very similar to matRad's example [`matRad.m`](https://github
5353
```python
5454
from importlib import resources
5555
import pymatreader
56-
from pyRadPlan import load_patient, IonPlan, generate_stf, calc_dose_influence, fluence_optimization
56+
from pyRadPlan import (
57+
load_patient,
58+
IonPlan,
59+
generate_stf,
60+
calc_dose_influence,
61+
fluence_optimization,
62+
)
5763

5864
# Read patient from provided TG119.mat file and validate data
5965
tg119_path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
@@ -93,6 +99,7 @@ Instead of using above top-level workflow functions and a central plan configura
9399
```python
94100
...
95101
from pyRadPlan.stf import StfGeneratorIMPT
102+
96103
# Create a plan object
97104
pln = IonPlan(radiation_mode="protons", machine="Generic")
98105

@@ -104,7 +111,7 @@ pln = IonPlan(radiation_mode="protons", machine="Generic")
104111
stf_gen = StfGeneratorIMPT()
105112
stf_gen.gantry_angles = [90, 270]
106113
stf_gen.couch_angles = [0, 0]
107-
stf = stf_gen.generate(ct,cst)
114+
stf = stf_gen.generate(ct, cst)
108115
```
109116

110117
If you are interested in helping with development, get in touch, read the contributing guidelines, and the developer note below.

test/dose/test_hongpb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_protons_cd_forward(test_data_protons):
2222
result_py = calc_dose_forward(ct, cst, stf, pln, weights=None)
2323
result_py = sitk.GetArrayFromImage(result_py["physical_dose"])
2424

25-
result_matRad_rot = np.swapaxes(result["physicalDose"], 0, 1)
25+
result_matRad_rot = np.transpose(result["physicalDose"], (2, 0, 1))
2626
# only comparing to 1e-4 since matRad rounds to 4 digits
2727
assert np.allclose(result_py, result_matRad_rot, atol=1e-4)
2828

@@ -44,7 +44,7 @@ def test_helium_cd_forward(test_data_helium):
4444
result_py = calc_dose_forward(ct, cst, stf, pln, weights=None)
4545
result_py = sitk.GetArrayFromImage(result_py["physical_dose"])
4646

47-
result_matRad_rot = np.swapaxes(result["physicalDose"], 0, 1)
47+
result_matRad_rot = np.transpose(result["physicalDose"], (2, 0, 1))
4848
# only comparing to 1e-4 since matRad rounds to 4 digits
4949
assert np.allclose(result_py, result_matRad_rot, atol=1e-4)
5050

@@ -55,7 +55,7 @@ def test_carbon_cd_forward(test_data_carbon):
5555
result_py = calc_dose_forward(ct, cst, stf, pln)
5656
result_py = sitk.GetArrayFromImage(result_py["physical_dose"])
5757

58-
result_matRad_rot = np.swapaxes(result["physicalDose"], 0, 1)
58+
result_matRad_rot = np.transpose(result["physicalDose"], (2, 0, 1))
5959
# only comparing to 1e-4 since matRad rounds to 4 digits
6060
assert np.allclose(result_py, result_matRad_rot, atol=1e-4)
6161

@@ -66,7 +66,7 @@ def test_oxygen_cd_forward(test_data_oxygen):
6666
result_py = calc_dose_forward(ct, cst, stf, pln)
6767
result_py = sitk.GetArrayFromImage(result_py["physical_dose"])
6868

69-
result_matRad_rot = np.swapaxes(result["physicalDose"], 0, 1)
69+
result_matRad_rot = np.transpose(result["physicalDose"], (2, 0, 1))
7070
# only comparing to 1e-4 since matRad rounds to 4 digits
7171
assert np.allclose(result_py, result_matRad_rot, atol=1e-4)
7272

test/dose/test_svdpb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33

44
from pyRadPlan.dose import calc_dose_forward
5+
from pyRadPlan.visualization._plot_slice import plot_slice
56

67

78
# TODO: PhotonEngine does not yet have sub-sampling.
@@ -14,10 +15,9 @@ def test_photons(test_data_photons):
1415

1516
result_py = calc_dose_forward(ct, cst, stf, pln, weights=None)
1617
result_py = sitk.GetArrayFromImage(result_py["physical_dose"])
18+
result_matRad = np.transpose(result["physicalDose"], (2, 0, 1))
1719

18-
result_matRad_rot = np.swapaxes(result["physicalDose"], 0, 1)
19-
20-
# assert np.allclose(result_py, result_matRad_rot, atol=1e-4)
20+
assert np.allclose(result_py, result_matRad, atol=1e-2)
2121

2222
# Keeping this for debugging:
2323
# plot_slice(

0 commit comments

Comments
 (0)