pyRadPlan 0.0.2__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyradplan-0.0.2 → pyradplan-0.1.0}/LICENSE +28 -28
- pyradplan-0.1.0/PKG-INFO +140 -0
- pyradplan-0.1.0/README.md +96 -0
- pyradplan-0.1.0/docs/conf.py +55 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/examples/carbon_pencilbeam.py +92 -87
- {pyradplan-0.0.2 → pyradplan-0.1.0}/examples/helium_pencilbeam.py +84 -80
- {pyradplan-0.0.2 → pyradplan-0.1.0}/examples/import_matrad_patient.py +106 -102
- pyradplan-0.1.0/examples/photon_pencilbeam.py +98 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/examples/proton_pencilbeam.py +94 -80
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/__init__.py +37 -34
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/__init__.py +15 -15
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/_exceptions.py +9 -9
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/_grids.py +231 -231
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/datamodel.py +70 -68
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/np2sitk.py +146 -147
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/core/resample.py +130 -130
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/cst/__init__.py +15 -15
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/cst/_cst.py +360 -307
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/cst/_voi.py +620 -603
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/ct/__init__.py +4 -4
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/ct/_ct.py +519 -525
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/ct/_hlut.py +27 -27
- pyradplan-0.1.0/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dij/__init__.py +5 -4
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dij/_dij.py +434 -410
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/__init__.py +6 -6
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/_calc_dose.py +83 -64
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/__init__.py +17 -17
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/_base.py +613 -591
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/_base_pencilbeam.py +844 -806
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +1006 -1015
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/_factory.py +107 -108
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/dose/engines/_hongpb.py +75 -75
- pyradplan-0.1.0/pyRadPlan/dose/engines/_svdpb.py +357 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/geometry/__init__.py +7 -7
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/geometry/lps.py +122 -122
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/io/__init__.py +3 -3
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/io/matLabFileHandler.py +25 -25
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/io/matRad.py +22 -22
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/io/readHLUT.py +16 -17
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/__init__.py +19 -19
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/_base.py +163 -164
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/_ions.py +527 -528
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/_load.py +55 -48
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/_photons.py +219 -220
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/machines/_validate.py +61 -61
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/matRad/__init__.py +18 -18
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/matRad/_engine.py +36 -36
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/matRad/_matlab.py +26 -26
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/matRad/_octave.py +51 -51
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/optimization/__init__.py +12 -12
- pyradplan-0.1.0/pyRadPlan/optimization/_fluence_optimization.py +48 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/__init__.py +37 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_eud.py +50 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_factory.py +92 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_max_dvh.py +54 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_mean.py +50 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_min_dvh.py +54 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_objective.py +176 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_squared_dev.py +43 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_squared_over.py +45 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_squared_under.py +45 -0
- pyradplan-0.1.0/pyRadPlan/optimization/objectives/_std.py +36 -0
- pyradplan-0.1.0/pyRadPlan/optimization/problems/__init__.py +16 -0
- pyradplan-0.1.0/pyRadPlan/optimization/problems/_factory.py +144 -0
- pyradplan-0.1.0/pyRadPlan/optimization/problems/_nonlin_fluence.py +229 -0
- pyradplan-0.1.0/pyRadPlan/optimization/problems/_optiprob.py +293 -0
- pyradplan-0.1.0/pyRadPlan/optimization/problems/_simple_least_squares.py +118 -0
- pyradplan-0.1.0/pyRadPlan/optimization/solvers/__init__.py +27 -0
- pyradplan-0.1.0/pyRadPlan/optimization/solvers/_base_solvers.py +130 -0
- pyradplan-0.1.0/pyRadPlan/optimization/solvers/_factory.py +74 -0
- pyradplan-0.1.0/pyRadPlan/optimization/solvers/_ipopt.py +109 -0
- pyradplan-0.1.0/pyRadPlan/optimization/solvers/_scipy_solver.py +73 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/plan/__init__.py +3 -3
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/plan/_plans.py +361 -360
- pyradplan-0.1.0/pyRadPlan/quantities/__init__.py +42 -0
- pyradplan-0.1.0/pyRadPlan/quantities/_base.py +186 -0
- pyradplan-0.1.0/pyRadPlan/quantities/_dose.py +31 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/raytracer/__init__.py +4 -4
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/raytracer/_base.py +287 -289
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/raytracer/_perf.py +227 -227
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/raytracer/_siddon.py +429 -428
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/scenarios/__init__.py +119 -102
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/scenarios/_base.py +380 -374
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/scenarios/_nominal.py +126 -126
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/__init__.py +29 -29
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_base.py +220 -226
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_beam.py +194 -195
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_beamlet.py +113 -106
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_exceptions.py +14 -14
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_externalbeam.py +182 -162
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_generate_stf.py +28 -23
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_ions.py +263 -255
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_photons.py +171 -125
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_rangeshifter.py +40 -40
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_ray.py +223 -201
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/_steeringinformation.py +185 -181
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/base_matrad.py +9 -6
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/stf/loadHLUT.py +62 -63
- pyradplan-0.1.0/pyRadPlan/util/__init__.py +8 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/util/helpers.py +257 -209
- pyradplan-0.1.0/pyRadPlan.egg-info/PKG-INFO +140 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan.egg-info/SOURCES.txt +31 -30
- pyradplan-0.1.0/pyRadPlan.egg-info/requires.txt +34 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan.egg-info/top_level.txt +0 -1
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyproject.toml +165 -123
- {pyradplan-0.0.2 → pyradplan-0.1.0}/setup.cfg +4 -4
- pyradplan-0.1.0/test/conftest.py +14 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/core/test_coordinates.py +50 -46
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/core/test_np2sitk.py +176 -178
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/core/test_resample.py +45 -45
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/cst/conftest.py +61 -57
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/cst/test_VOI.py +422 -422
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/cst/test_cst.py +253 -144
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/ct/test_ct.py +218 -218
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/ct/test_hlut.py +10 -10
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/dose/test_dose_particle.py +231 -234
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/dose/test_dose_photon.py +20 -22
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/geometry/test_lps.py +96 -96
- pyradplan-0.1.0/test/optimization/test_fluence_optiprob.py +23 -0
- pyradplan-0.1.0/test/optimization/test_ipopt_solver.py +39 -0
- pyradplan-0.1.0/test/optimization/test_objectives.py +251 -0
- pyradplan-0.1.0/test/optimization/test_problem_factory.py +59 -0
- pyradplan-0.1.0/test/optimization/test_scipy_solver.py +33 -0
- pyradplan-0.1.0/test/optimization/test_solver_factory.py +31 -0
- pyradplan-0.1.0/test/quantities/test_dose_quantity.py +108 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/stf/test_beamlet.py +53 -53
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/stf/test_stf.py +209 -205
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/stf/test_stf_gen.py +295 -295
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_dij.py +241 -238
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_fileHandling.py +39 -37
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_grid.py +148 -148
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_helpers.py +93 -65
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_machine_model.py +155 -155
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_matlabEngine.py +28 -30
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_octaveEngine.py +28 -30
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_plan.py +157 -158
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_raytracersiddon.py +104 -104
- {pyradplan-0.0.2 → pyradplan-0.1.0}/test/test_scenarios.py +204 -198
- pyradplan-0.0.2/.gitignore +0 -175
- pyradplan-0.0.2/.gitlab-ci.yml +0 -80
- pyradplan-0.0.2/.gitmodules +0 -4
- pyradplan-0.0.2/.pre-commit-config.yaml +0 -16
- pyradplan-0.0.2/CONTRIBUTING.md +0 -19
- pyradplan-0.0.2/PKG-INFO +0 -67
- pyradplan-0.0.2/README.md +0 -30
- pyradplan-0.0.2/examples/photon_pencilbeam.py +0 -66
- pyradplan-0.0.2/pyRadPlan/dose/engines/_svdpb.py +0 -275
- pyradplan-0.0.2/pyRadPlan/io/.gitkeep +0 -0
- pyradplan-0.0.2/pyRadPlan/io/temp_files/cst.mat +0 -0
- pyradplan-0.0.2/pyRadPlan/io/temp_files/ct.mat +0 -0
- pyradplan-0.0.2/pyRadPlan/io/temp_files/pln.mat +0 -0
- pyradplan-0.0.2/pyRadPlan/io/temp_files/stf_with_separate_rays.mat +0 -0
- pyradplan-0.0.2/pyRadPlan/matRad/.gitkeep +0 -0
- pyradplan-0.0.2/pyRadPlan/optimization/_fluenceOptimizer.py +0 -312
- pyradplan-0.0.2/pyRadPlan/optimization/_fluence_optimization.py +0 -57
- pyradplan-0.0.2/pyRadPlan/optimization/components/__init__.py +0 -3
- pyradplan-0.0.2/pyRadPlan/optimization/components/_optimizationProblem.py +0 -162
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_EUD.py +0 -93
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/__init__.py +0 -19
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_doseUniformity.py +0 -81
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_maxDVH.py +0 -92
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_meanDose.py +0 -80
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_minDVH.py +0 -92
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_objectiveClass.py +0 -98
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_squaredDeviation.py +0 -82
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_squaredOverdosing.py +0 -84
- pyradplan-0.0.2/pyRadPlan/optimization/components/objectives/_squaredUnderdosing.py +0 -84
- pyradplan-0.0.2/pyRadPlan/optimization/projections/__init__.py +0 -5
- pyradplan-0.0.2/pyRadPlan/optimization/projections/_backProjection.py +0 -59
- pyradplan-0.0.2/pyRadPlan/optimization/projections/_constantRBEProjection.py +0 -26
- pyradplan-0.0.2/pyRadPlan/optimization/projections/_doseProjection.py +0 -25
- pyradplan-0.0.2/pyRadPlan/optimization/solvers/__init__.py +0 -18
- pyradplan-0.0.2/pyRadPlan/optimization/solvers/_ipopt.py +0 -89
- pyradplan-0.0.2/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -120
- pyradplan-0.0.2/pyRadPlan/stf/hlutLibrary/matRad_default.hlut +0 -10
- pyradplan-0.0.2/pyRadPlan/util/__init__.py +0 -0
- pyradplan-0.0.2/pyRadPlan.egg-info/PKG-INFO +0 -67
- pyradplan-0.0.2/pyRadPlan.egg-info/requires.txt +0 -27
- pyradplan-0.0.2/test/test_objectives.py +0 -371
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan/data/stf/matRad_stf.mat +0 -0
- /pyradplan-0.0.2/pyRadPlan/data/stf/matrad_stf_onebeam.mat → /pyradplan-0.1.0/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.1.0}/pyRadPlan.egg-info/dependency_links.txt +0 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024, DKFZ
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
-
this list of conditions and the following disclaimer in the documentation
|
|
13
|
-
and/or other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from
|
|
17
|
-
this software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, DKFZ
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pyradplan-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pyRadPlan
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A python interface and reimplementation to matRad
|
|
5
|
+
Author-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Lina Bucher <lina.bucher@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Antonios Kontopoulos <antonios.kontopoulos@dkfz-heidelberg.de>
|
|
6
|
+
Maintainer-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Tobias Becher <t.becher@dkfz-heidelberg.de>
|
|
7
|
+
Project-URL: Homepage, https://git.dkfz.de
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: scipy>=1.13.0
|
|
15
|
+
Requires-Dist: numpy>=1.26.0
|
|
16
|
+
Requires-Dist: pymatreader>=1.0.0
|
|
17
|
+
Requires-Dist: h5py>=3.11.0
|
|
18
|
+
Requires-Dist: regex>=2024.5.15
|
|
19
|
+
Requires-Dist: pydicom>=2.4.4
|
|
20
|
+
Requires-Dist: numba>=0.60.0
|
|
21
|
+
Requires-Dist: matplotlib>=3.9.2
|
|
22
|
+
Requires-Dist: pydantic>=2.10
|
|
23
|
+
Requires-Dist: numpydantic>=1.6.0
|
|
24
|
+
Requires-Dist: SimpleITK>=2.4.0
|
|
25
|
+
Requires-Dist: tqdm>=4.0.0
|
|
26
|
+
Requires-Dist: pint>=0.24.0
|
|
27
|
+
Provides-Extra: matlab
|
|
28
|
+
Requires-Dist: matlabengine; extra == "matlab"
|
|
29
|
+
Provides-Extra: octave
|
|
30
|
+
Requires-Dist: oct2py; extra == "octave"
|
|
31
|
+
Provides-Extra: gui
|
|
32
|
+
Requires-Dist: PyQt5; extra == "gui"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest; extra == "dev"
|
|
35
|
+
Requires-Dist: coverage; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
38
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
39
|
+
Requires-Dist: numpydoc; extra == "dev"
|
|
40
|
+
Requires-Dist: pydata-sphinx-theme; extra == "dev"
|
|
41
|
+
Requires-Dist: sphinx-design; extra == "dev"
|
|
42
|
+
Requires-Dist: autodoc_pydantic; extra == "dev"
|
|
43
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
|
|
44
|
+
|
|
45
|
+
# pyRadPlan
|
|
46
|
+
pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
|
|
47
|
+
|
|
48
|
+
Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
|
|
49
|
+
|
|
50
|
+
## Concept and Goals
|
|
51
|
+
pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
|
|
52
|
+
|
|
53
|
+
### Data Structures
|
|
54
|
+
pyRadPlan uses a similar datastructure and workflow concept as in matRad, while trying to ensure that the corresponding datastructures can be easily imported and exported from/to matRad. This facilitates the application of either algortihms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
55
|
+
|
|
56
|
+
To enforce valid datastructures, we perform validation and serialization with [`pydantic`](https://docs.pydantic.dev/latest/).
|
|
57
|
+
Datastructures and algorithms rely mostly on [`SimpleITK`](https://simpleitk.readthedocs.io), [`numpy`](https://numpy.org/), and [`scipy`](https://scipy.org/) for internal data representation and processing.
|
|
58
|
+
|
|
59
|
+
### Scripting and API
|
|
60
|
+
|
|
61
|
+
#### Minimal Script using the Top-Level API
|
|
62
|
+
A minimal script is very similar to matRad's example [`matRad.m`](https://github.com/e0404/matRad) script:
|
|
63
|
+
```python
|
|
64
|
+
from importlib import resources
|
|
65
|
+
import pymatreader
|
|
66
|
+
from pyRadPlan import IonPlan, validate_ct, validate_cst, generate_stf, calc_dose_influence, fluence_optimization
|
|
67
|
+
|
|
68
|
+
# Read patient from provided TG119.mat file and validate data
|
|
69
|
+
phantom = pymatreader.read_mat(resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat"))
|
|
70
|
+
ct = validate_ct(phantom["ct"])
|
|
71
|
+
cst = validate_cst(phantom["cst"], ct=ct)
|
|
72
|
+
|
|
73
|
+
# Create a plan object
|
|
74
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
75
|
+
|
|
76
|
+
# Generate Steering Geometry ("stf")
|
|
77
|
+
stf = generate_stf(ct, cst, pln)
|
|
78
|
+
|
|
79
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
80
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
81
|
+
|
|
82
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
83
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
84
|
+
|
|
85
|
+
# Result
|
|
86
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This script uses the top-level API exposed when importing pyRadPlan. The top-level functions are designed to take the main data structures as input and configure the corresponding workflow step via the `Plan` using the attribute dictionaries `pln.prop*`:
|
|
90
|
+
|
|
91
|
+
| Plan property | API function | Description | ID |
|
|
92
|
+
| -------- | ------- | ------ | ------- |
|
|
93
|
+
| `prop_stf` | `generate_stf` | Create beam Geometry | generator |
|
|
94
|
+
| `prop_dose_calc` | `calc_dose_influence`, `calc_dose_forward` | Calculate dose matrix / distribution | engine |
|
|
95
|
+
| `prop_opt` | `fluence_optimization` | Optimization of beam fluences | problem
|
|
96
|
+
|
|
97
|
+
The Plan properties are dictionaries. Based on their content, the top-level-api will choose the correct implementation and configure the corresponding settings. The ID can be used in the corresponding `pln.prop*` dictionary to identify a specific implementation. E.g., `pln.prop_stf = {"generator": "IMPT"}` will select the IMPT Geometry Generator if compatible to the plan. pyRadPlan will try to set all provided configuration parameters in the dictionary and use default parameters and implementations if no keys are provided.
|
|
98
|
+
|
|
99
|
+
The top level api is designed to require minimal programming experience and to run the same planning workflows with different configurations by just changing the corresponding plan object.
|
|
100
|
+
|
|
101
|
+
#### Low-level API
|
|
102
|
+
Instead of using above top-level workflow functions and a central plan configuration, one can also built custom workflows instantiating the necessary algorithm objects directly, for example:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
...
|
|
106
|
+
from pyRadPlan.stf import StfGeneratorIMPT
|
|
107
|
+
# Create a plan object
|
|
108
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
109
|
+
|
|
110
|
+
# Equivalent Top Level API configuration
|
|
111
|
+
# pln.prop_stf = {"gantry_angles": [90, 270], "couch_angles": [0, 0], "generator": "IMPT"}
|
|
112
|
+
# stf = generate_stf(ct,cst,pln)
|
|
113
|
+
|
|
114
|
+
# Low level:
|
|
115
|
+
stf_gen = StfGeneratorIMPT()
|
|
116
|
+
stf_gen.gantry_angles = [90, 270]
|
|
117
|
+
stf_gen.couch_angles = [0, 0]
|
|
118
|
+
stf = stf_gen.generate(ct,cst)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If you are interested in helping with development, get in touch, read the contributing guidelines, and the developer note below.
|
|
122
|
+
|
|
123
|
+
## Contributing & Notes for Developers
|
|
124
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
125
|
+
If you are a developer or want to contribute, make sure to clone the latest state via git. Then, we strongly suggest to create a virtual python environment with a suitable version and do an editable installation of pyRadPlan in dev mode: `pip install -e .[dev]`
|
|
126
|
+
|
|
127
|
+
> **Note**
|
|
128
|
+
> If you are using venv to create a virtual environment in the project's root folder, we suggest to name it `.venv` as this folder will be automatically excluded by all formatters and linters
|
|
129
|
+
|
|
130
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
131
|
+
- **pytest** is used to run unit tests before publishing the code. Run on the test folder via `pytest test`, or choose any test file following the pytest syntax. We encourage writing at least fundamental unit tests for new code. Will also install `coverage` and the pytest extension to monitor coverage.
|
|
132
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
133
|
+
|
|
134
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
135
|
+
Afterwards run `pre-commit install`. This reads the `.pre-commit_config.yaml` and adds a hook to your git repository, which whenever a commit is made the changed files are reformatted to ensure the PEP standards.
|
|
136
|
+
|
|
137
|
+
### Matlab / Octave Files & Engine
|
|
138
|
+
If you want to interface via matRad, the simplest way is to write mat files using scipy's `savemat` and load them in matRad. To save a datastructure such that it can be read into Matlab and interpreted by matRad, you can call `to_matrad` on the structure and then pass the resulting dictionary to `savemat`.
|
|
139
|
+
You can also install the matlab engine by appending `[matlab]` to the pip install command. However, as there is some compatibility matrix for what matlabengine version is suitable for your Matlab installation, it might be better to not install the latest version but instead install the correct matlabengine manually before.
|
|
140
|
+
To use Octave via oct2py, analogously append `[octave]`.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# pyRadPlan
|
|
2
|
+
pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
|
|
3
|
+
|
|
4
|
+
Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
|
|
5
|
+
|
|
6
|
+
## Concept and Goals
|
|
7
|
+
pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
|
|
8
|
+
|
|
9
|
+
### Data Structures
|
|
10
|
+
pyRadPlan uses a similar datastructure and workflow concept as in matRad, while trying to ensure that the corresponding datastructures can be easily imported and exported from/to matRad. This facilitates the application of either algortihms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
11
|
+
|
|
12
|
+
To enforce valid datastructures, we perform validation and serialization with [`pydantic`](https://docs.pydantic.dev/latest/).
|
|
13
|
+
Datastructures and algorithms rely mostly on [`SimpleITK`](https://simpleitk.readthedocs.io), [`numpy`](https://numpy.org/), and [`scipy`](https://scipy.org/) for internal data representation and processing.
|
|
14
|
+
|
|
15
|
+
### Scripting and API
|
|
16
|
+
|
|
17
|
+
#### Minimal Script using the Top-Level API
|
|
18
|
+
A minimal script is very similar to matRad's example [`matRad.m`](https://github.com/e0404/matRad) script:
|
|
19
|
+
```python
|
|
20
|
+
from importlib import resources
|
|
21
|
+
import pymatreader
|
|
22
|
+
from pyRadPlan import IonPlan, validate_ct, validate_cst, generate_stf, calc_dose_influence, fluence_optimization
|
|
23
|
+
|
|
24
|
+
# Read patient from provided TG119.mat file and validate data
|
|
25
|
+
phantom = pymatreader.read_mat(resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat"))
|
|
26
|
+
ct = validate_ct(phantom["ct"])
|
|
27
|
+
cst = validate_cst(phantom["cst"], ct=ct)
|
|
28
|
+
|
|
29
|
+
# Create a plan object
|
|
30
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
31
|
+
|
|
32
|
+
# Generate Steering Geometry ("stf")
|
|
33
|
+
stf = generate_stf(ct, cst, pln)
|
|
34
|
+
|
|
35
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
36
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
37
|
+
|
|
38
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
39
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
40
|
+
|
|
41
|
+
# Result
|
|
42
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This script uses the top-level API exposed when importing pyRadPlan. The top-level functions are designed to take the main data structures as input and configure the corresponding workflow step via the `Plan` using the attribute dictionaries `pln.prop*`:
|
|
46
|
+
|
|
47
|
+
| Plan property | API function | Description | ID |
|
|
48
|
+
| -------- | ------- | ------ | ------- |
|
|
49
|
+
| `prop_stf` | `generate_stf` | Create beam Geometry | generator |
|
|
50
|
+
| `prop_dose_calc` | `calc_dose_influence`, `calc_dose_forward` | Calculate dose matrix / distribution | engine |
|
|
51
|
+
| `prop_opt` | `fluence_optimization` | Optimization of beam fluences | problem
|
|
52
|
+
|
|
53
|
+
The Plan properties are dictionaries. Based on their content, the top-level-api will choose the correct implementation and configure the corresponding settings. The ID can be used in the corresponding `pln.prop*` dictionary to identify a specific implementation. E.g., `pln.prop_stf = {"generator": "IMPT"}` will select the IMPT Geometry Generator if compatible to the plan. pyRadPlan will try to set all provided configuration parameters in the dictionary and use default parameters and implementations if no keys are provided.
|
|
54
|
+
|
|
55
|
+
The top level api is designed to require minimal programming experience and to run the same planning workflows with different configurations by just changing the corresponding plan object.
|
|
56
|
+
|
|
57
|
+
#### Low-level API
|
|
58
|
+
Instead of using above top-level workflow functions and a central plan configuration, one can also built custom workflows instantiating the necessary algorithm objects directly, for example:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
...
|
|
62
|
+
from pyRadPlan.stf import StfGeneratorIMPT
|
|
63
|
+
# Create a plan object
|
|
64
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
65
|
+
|
|
66
|
+
# Equivalent Top Level API configuration
|
|
67
|
+
# pln.prop_stf = {"gantry_angles": [90, 270], "couch_angles": [0, 0], "generator": "IMPT"}
|
|
68
|
+
# stf = generate_stf(ct,cst,pln)
|
|
69
|
+
|
|
70
|
+
# Low level:
|
|
71
|
+
stf_gen = StfGeneratorIMPT()
|
|
72
|
+
stf_gen.gantry_angles = [90, 270]
|
|
73
|
+
stf_gen.couch_angles = [0, 0]
|
|
74
|
+
stf = stf_gen.generate(ct,cst)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If you are interested in helping with development, get in touch, read the contributing guidelines, and the developer note below.
|
|
78
|
+
|
|
79
|
+
## Contributing & Notes for Developers
|
|
80
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
81
|
+
If you are a developer or want to contribute, make sure to clone the latest state via git. Then, we strongly suggest to create a virtual python environment with a suitable version and do an editable installation of pyRadPlan in dev mode: `pip install -e .[dev]`
|
|
82
|
+
|
|
83
|
+
> **Note**
|
|
84
|
+
> If you are using venv to create a virtual environment in the project's root folder, we suggest to name it `.venv` as this folder will be automatically excluded by all formatters and linters
|
|
85
|
+
|
|
86
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
87
|
+
- **pytest** is used to run unit tests before publishing the code. Run on the test folder via `pytest test`, or choose any test file following the pytest syntax. We encourage writing at least fundamental unit tests for new code. Will also install `coverage` and the pytest extension to monitor coverage.
|
|
88
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
89
|
+
|
|
90
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
91
|
+
Afterwards run `pre-commit install`. This reads the `.pre-commit_config.yaml` and adds a hook to your git repository, which whenever a commit is made the changed files are reformatted to ensure the PEP standards.
|
|
92
|
+
|
|
93
|
+
### Matlab / Octave Files & Engine
|
|
94
|
+
If you want to interface via matRad, the simplest way is to write mat files using scipy's `savemat` and load them in matRad. To save a datastructure such that it can be read into Matlab and interpreted by matRad, you can call `to_matrad` on the structure and then pass the resulting dictionary to `savemat`.
|
|
95
|
+
You can also install the matlab engine by appending `[matlab]` to the pip install command. However, as there is some compatibility matrix for what matlabengine version is suitable for your Matlab installation, it might be better to not install the latest version but instead install the correct matlabengine manually before.
|
|
96
|
+
To use Octave via oct2py, analogously append `[octave]`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
# -- Project information -----------------------------------------------------
|
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
print(os.path.abspath("../pyRadPlan"))
|
|
12
|
+
sys.path.insert(0, os.path.abspath("../pyRadPlan")) # Adjust to your source folder
|
|
13
|
+
|
|
14
|
+
project = "pyRadPlan"
|
|
15
|
+
copyright = "2024, e0404"
|
|
16
|
+
author = "e0404"
|
|
17
|
+
release = "0.0.1"
|
|
18
|
+
|
|
19
|
+
# -- General configuration ---------------------------------------------------
|
|
20
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
21
|
+
|
|
22
|
+
extensions = [
|
|
23
|
+
"sphinx.ext.autodoc",
|
|
24
|
+
"sphinx.ext.viewcode",
|
|
25
|
+
"sphinx.ext.napoleon",
|
|
26
|
+
"numpydoc",
|
|
27
|
+
"sphinx_autodoc_typehints",
|
|
28
|
+
"sphinxcontrib.autodoc_pydantic",
|
|
29
|
+
"sphinx_design",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
templates_path = ["_templates"]
|
|
33
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
34
|
+
|
|
35
|
+
add_module_names = False
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# -- Options for HTML output -------------------------------------------------
|
|
39
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
40
|
+
|
|
41
|
+
html_theme = "pydata_sphinx_theme"
|
|
42
|
+
html_static_path = ["_static"]
|
|
43
|
+
|
|
44
|
+
autodoc_type_aliases = {
|
|
45
|
+
"npt.ArrayLike": "npt.ArrayLike",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
autodoc_default_options = {
|
|
49
|
+
"no-module": True, # Suppress the module/package labels
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
numpydoc_class_members_toctree = False
|
|
53
|
+
|
|
54
|
+
# disable show json as it otherwises crashes the documentation building at the moment
|
|
55
|
+
autodoc_pydantic_model_show_json = False
|
|
@@ -1,87 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from importlib import resources # Standard from Python 3.9+
|
|
5
|
+
except ImportError:
|
|
6
|
+
import importlib_resources as resources # Backport for older versions
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import SimpleITK as sitk
|
|
10
|
+
import pymatreader
|
|
11
|
+
import matplotlib.pyplot as plt
|
|
12
|
+
|
|
13
|
+
from pyRadPlan import (
|
|
14
|
+
IonPlan,
|
|
15
|
+
validate_ct,
|
|
16
|
+
validate_cst,
|
|
17
|
+
generate_stf,
|
|
18
|
+
calc_dose_influence,
|
|
19
|
+
fluence_optimization,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
logging.basicConfig(level=logging.INFO)
|
|
23
|
+
|
|
24
|
+
# Read patient from provided TG119.mat file and validate data
|
|
25
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
26
|
+
tmp = pymatreader.read_mat(path)
|
|
27
|
+
ct = validate_ct(tmp["ct"])
|
|
28
|
+
cst = validate_cst(tmp["cst"], ct=ct)
|
|
29
|
+
|
|
30
|
+
# Create a plan object
|
|
31
|
+
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
32
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
33
|
+
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
34
|
+
|
|
35
|
+
# Generate Steering Geometry ("stf")
|
|
36
|
+
stf = generate_stf(ct, cst, pln)
|
|
37
|
+
|
|
38
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
39
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
40
|
+
|
|
41
|
+
# Optimize
|
|
42
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
43
|
+
|
|
44
|
+
# Result
|
|
45
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
46
|
+
|
|
47
|
+
# Choose a slice to visualize
|
|
48
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
49
|
+
|
|
50
|
+
# Visualize
|
|
51
|
+
quantities = ["physical_dose", "effect"]
|
|
52
|
+
for quantity in quantities:
|
|
53
|
+
cube_hu = sitk.GetArrayViewFromImage(ct.cube_hu)
|
|
54
|
+
plt.imshow(cube_hu[view_slice, :, :], cmap="gray")
|
|
55
|
+
|
|
56
|
+
plt.tick_params(
|
|
57
|
+
axis="both",
|
|
58
|
+
which="both",
|
|
59
|
+
bottom=False,
|
|
60
|
+
top=False,
|
|
61
|
+
labelbottom=False,
|
|
62
|
+
left=False,
|
|
63
|
+
right=False,
|
|
64
|
+
labelleft=False,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Now let's visualize the VOIs from the StructureSet.
|
|
68
|
+
for v, voi in enumerate(cst.vois):
|
|
69
|
+
mask = sitk.GetArrayViewFromImage(voi.mask)
|
|
70
|
+
color = plt.cm.cool(v / len(cst.vois)) # Select color based on colormap 'cool'
|
|
71
|
+
plt.contour(
|
|
72
|
+
mask[view_slice, :, :],
|
|
73
|
+
levels=[0.5],
|
|
74
|
+
colors=[color],
|
|
75
|
+
linewidths=1,
|
|
76
|
+
)
|
|
77
|
+
dose_array = sitk.GetArrayViewFromImage(result[quantity])
|
|
78
|
+
plt.imshow(
|
|
79
|
+
dose_array[view_slice, :, :],
|
|
80
|
+
cmap="jet",
|
|
81
|
+
interpolation="nearest",
|
|
82
|
+
alpha=0.5 * (dose_array[view_slice, :, :] > 0.02),
|
|
83
|
+
)
|
|
84
|
+
if quantity == "physical_dose":
|
|
85
|
+
plt.colorbar(label="dose [Gy]")
|
|
86
|
+
plt.title(f"Carbon Dose Distribution (Slice z={view_slice})")
|
|
87
|
+
else:
|
|
88
|
+
plt.colorbar(label="effect [1]")
|
|
89
|
+
plt.title(f"Effect [-ln(S)] Distribution (Slice z={view_slice})")
|
|
90
|
+
plt.show()
|
|
91
|
+
plt.savefig(f"carbon_{quantity}.png")
|
|
92
|
+
plt.clf()
|