pyRadPlan 0.0.2__tar.gz → 0.2.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.2.0}/LICENSE +28 -28
- pyradplan-0.2.0/PKG-INFO +139 -0
- pyradplan-0.2.0/README.md +95 -0
- pyradplan-0.2.0/docs/conf.py +55 -0
- pyradplan-0.2.0/examples/carbon_pencilbeam.py +62 -0
- pyradplan-0.2.0/examples/helium_pencilbeam.py +51 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/examples/import_matrad_patient.py +97 -102
- pyradplan-0.2.0/examples/photon_pencilbeam.py +64 -0
- pyradplan-0.2.0/examples/proton_pencilbeam.py +60 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/__init__.py +43 -34
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/core/__init__.py +15 -15
- pyradplan-0.2.0/pyRadPlan/core/_exceptions.py +5 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/core/_grids.py +231 -231
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/core/datamodel.py +70 -68
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/core/np2sitk.py +146 -147
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/core/resample.py +130 -130
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/cst/__init__.py +15 -15
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/cst/_cst.py +360 -307
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/cst/_voi.py +620 -603
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/ct/__init__.py +4 -4
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/ct/_ct.py +516 -525
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/ct/_hlut.py +27 -27
- pyradplan-0.2.0/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dij/__init__.py +5 -4
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dij/_dij.py +373 -410
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/__init__.py +8 -6
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/_calc_dose.py +83 -64
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/__init__.py +17 -17
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/_base.py +607 -591
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/_base_pencilbeam.py +840 -806
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +997 -1015
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/_factory.py +107 -108
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/dose/engines/_hongpb.py +73 -75
- pyradplan-0.2.0/pyRadPlan/dose/engines/_svdpb.py +363 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/geometry/__init__.py +9 -7
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/geometry/lps.py +125 -122
- pyradplan-0.2.0/pyRadPlan/io/__init__.py +4 -0
- pyradplan-0.2.0/pyRadPlan/io/_matlab_file_handler.py +31 -0
- pyradplan-0.2.0/pyRadPlan/io/_patient_loader.py +113 -0
- pyradplan-0.2.0/pyRadPlan/io/matfile.py +35 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/__init__.py +19 -19
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/_base.py +163 -164
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/_ions.py +527 -528
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/_load.py +55 -48
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/_photons.py +219 -220
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/machines/_validate.py +61 -61
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/matRad/__init__.py +18 -18
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/matRad/_engine.py +36 -36
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/matRad/_matlab.py +26 -26
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/matRad/_octave.py +51 -51
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/optimization/__init__.py +12 -12
- pyradplan-0.2.0/pyRadPlan/optimization/_fluence_optimization.py +47 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/__init__.py +37 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_eud.py +50 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_factory.py +92 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_max_dvh.py +54 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_mean.py +50 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_min_dvh.py +54 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_objective.py +176 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_squared_dev.py +43 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_squared_over.py +45 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_squared_under.py +45 -0
- pyradplan-0.2.0/pyRadPlan/optimization/objectives/_std.py +36 -0
- pyradplan-0.2.0/pyRadPlan/optimization/problems/__init__.py +16 -0
- pyradplan-0.2.0/pyRadPlan/optimization/problems/_factory.py +144 -0
- pyradplan-0.2.0/pyRadPlan/optimization/problems/_nonlin_fluence.py +229 -0
- pyradplan-0.2.0/pyRadPlan/optimization/problems/_optiprob.py +295 -0
- pyradplan-0.2.0/pyRadPlan/optimization/problems/_simple_least_squares.py +118 -0
- pyradplan-0.2.0/pyRadPlan/optimization/solvers/__init__.py +27 -0
- pyradplan-0.2.0/pyRadPlan/optimization/solvers/_base_solvers.py +122 -0
- pyradplan-0.2.0/pyRadPlan/optimization/solvers/_factory.py +74 -0
- pyradplan-0.2.0/pyRadPlan/optimization/solvers/_ipopt.py +112 -0
- pyradplan-0.2.0/pyRadPlan/optimization/solvers/_scipy_solver.py +73 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/plan/__init__.py +3 -3
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/plan/_plans.py +361 -360
- pyradplan-0.2.0/pyRadPlan/quantities/__init__.py +42 -0
- pyradplan-0.2.0/pyRadPlan/quantities/_base.py +186 -0
- pyradplan-0.2.0/pyRadPlan/quantities/_dose.py +31 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/raytracer/__init__.py +4 -4
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/raytracer/_base.py +290 -289
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/raytracer/_perf.py +227 -227
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/raytracer/_siddon.py +396 -428
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/scenarios/__init__.py +119 -102
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/scenarios/_base.py +380 -374
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/scenarios/_nominal.py +126 -126
- pyradplan-0.2.0/pyRadPlan/stf/__init__.py +23 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/stf/_beam.py +194 -195
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/stf/_beamlet.py +112 -106
- pyradplan-0.2.0/pyRadPlan/stf/_exceptions.py +10 -0
- pyradplan-0.2.0/pyRadPlan/stf/_generate_stf.py +24 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/stf/_rangeshifter.py +39 -40
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/stf/_ray.py +219 -201
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/stf/_steeringinformation.py +185 -181
- {pyradplan-0.0.2/pyRadPlan/stf → pyradplan-0.2.0/pyRadPlan/stf/generators}/__init__.py +26 -29
- {pyradplan-0.0.2/pyRadPlan/stf → pyradplan-0.2.0/pyRadPlan/stf/generators}/_base.py +207 -226
- {pyradplan-0.0.2/pyRadPlan/stf → pyradplan-0.2.0/pyRadPlan/stf/generators}/_externalbeam.py +204 -162
- pyradplan-0.2.0/pyRadPlan/stf/generators/_factory.py +110 -0
- {pyradplan-0.0.2/pyRadPlan/stf → pyradplan-0.2.0/pyRadPlan/stf/generators}/_ions.py +276 -255
- {pyradplan-0.0.2/pyRadPlan/stf → pyradplan-0.2.0/pyRadPlan/stf/generators}/_photons.py +141 -125
- pyradplan-0.2.0/pyRadPlan/util/__init__.py +8 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/util/helpers.py +257 -209
- pyradplan-0.2.0/pyRadPlan/visualization/__init__.py +5 -0
- pyradplan-0.2.0/pyRadPlan/visualization/_plot_slice.py +105 -0
- pyradplan-0.2.0/pyRadPlan.egg-info/PKG-INFO +139 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan.egg-info/SOURCES.txt +44 -40
- pyradplan-0.2.0/pyRadPlan.egg-info/requires.txt +34 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan.egg-info/top_level.txt +0 -1
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyproject.toml +165 -123
- {pyradplan-0.0.2 → pyradplan-0.2.0}/setup.cfg +4 -4
- pyradplan-0.2.0/test/conftest.py +14 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/core/test_coordinates.py +46 -46
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/core/test_np2sitk.py +176 -178
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/core/test_resample.py +45 -45
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/cst/conftest.py +61 -57
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/cst/test_VOI.py +422 -422
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/cst/test_cst.py +253 -144
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/ct/test_ct.py +218 -218
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/ct/test_hlut.py +10 -10
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/dose/test_dose_particle.py +231 -234
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/dose/test_dose_photon.py +20 -22
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/geometry/test_lps.py +96 -96
- pyradplan-0.2.0/test/optimization/test_fluence_optiprob.py +23 -0
- pyradplan-0.2.0/test/optimization/test_ipopt_solver.py +39 -0
- pyradplan-0.2.0/test/optimization/test_objectives.py +251 -0
- pyradplan-0.2.0/test/optimization/test_problem_factory.py +59 -0
- pyradplan-0.2.0/test/optimization/test_scipy_solver.py +33 -0
- pyradplan-0.2.0/test/optimization/test_solver_factory.py +31 -0
- pyradplan-0.2.0/test/quantities/test_dose_quantity.py +108 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/stf/test_beamlet.py +53 -53
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/stf/test_stf.py +207 -205
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/stf/test_stf_gen.py +316 -295
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_dij.py +241 -238
- pyradplan-0.2.0/test/test_fileHandling.py +68 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_grid.py +148 -148
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_helpers.py +93 -65
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_machine_model.py +155 -155
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_matlabEngine.py +28 -30
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_octaveEngine.py +28 -30
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_plan.py +157 -158
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_raytracersiddon.py +104 -104
- {pyradplan-0.0.2 → pyradplan-0.2.0}/test/test_scenarios.py +204 -198
- pyradplan-0.2.0/test/visualization/test_plot_slice.py +85 -0
- 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/carbon_pencilbeam.py +0 -87
- pyradplan-0.0.2/examples/helium_pencilbeam.py +0 -80
- pyradplan-0.0.2/examples/photon_pencilbeam.py +0 -66
- pyradplan-0.0.2/examples/proton_pencilbeam.py +0 -80
- pyradplan-0.0.2/pyRadPlan/core/_exceptions.py +0 -9
- 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/__init__.py +0 -3
- pyradplan-0.0.2/pyRadPlan/io/matLabFileHandler.py +0 -25
- pyradplan-0.0.2/pyRadPlan/io/matRad.py +0 -22
- pyradplan-0.0.2/pyRadPlan/io/readHLUT.py +0 -17
- 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/_exceptions.py +0 -14
- pyradplan-0.0.2/pyRadPlan/stf/_generate_stf.py +0 -23
- pyradplan-0.0.2/pyRadPlan/stf/base_matrad.py +0 -6
- pyradplan-0.0.2/pyRadPlan/stf/hlutLibrary/matRad_default.hlut +0 -10
- pyradplan-0.0.2/pyRadPlan/stf/loadHLUT.py +0 -63
- 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_fileHandling.py +0 -37
- pyradplan-0.0.2/test/test_objectives.py +0 -371
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.0}/pyRadPlan/data/stf/matRad_stf.mat +0 -0
- /pyradplan-0.0.2/pyRadPlan/data/stf/matrad_stf_onebeam.mat → /pyradplan-0.2.0/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
- {pyradplan-0.0.2 → pyradplan-0.2.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.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pyRadPlan
|
|
3
|
+
Version: 0.2.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 load_patient, IonPlan, generate_stf, calc_dose_influence, fluence_optimization
|
|
67
|
+
|
|
68
|
+
# Read patient from provided TG119.mat file and validate data
|
|
69
|
+
tg119_path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
70
|
+
ct, cst = load_patient(tg119_path)
|
|
71
|
+
|
|
72
|
+
# Create a plan object
|
|
73
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
74
|
+
|
|
75
|
+
# Generate Steering Geometry ("stf")
|
|
76
|
+
stf = generate_stf(ct, cst, pln)
|
|
77
|
+
|
|
78
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
79
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
80
|
+
|
|
81
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
82
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
83
|
+
|
|
84
|
+
# Result
|
|
85
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
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*`:
|
|
89
|
+
|
|
90
|
+
| Plan property | API function | Description | ID |
|
|
91
|
+
| -------- | ------- | ------ | ------- |
|
|
92
|
+
| `prop_stf` | `generate_stf` | Create beam Geometry | generator |
|
|
93
|
+
| `prop_dose_calc` | `calc_dose_influence`, `calc_dose_forward` | Calculate dose matrix / distribution | engine |
|
|
94
|
+
| `prop_opt` | `fluence_optimization` | Optimization of beam fluences | problem
|
|
95
|
+
|
|
96
|
+
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.
|
|
97
|
+
|
|
98
|
+
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.
|
|
99
|
+
|
|
100
|
+
#### Low-level API
|
|
101
|
+
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:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
...
|
|
105
|
+
from pyRadPlan.stf import StfGeneratorIMPT
|
|
106
|
+
# Create a plan object
|
|
107
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
108
|
+
|
|
109
|
+
# Equivalent Top Level API configuration
|
|
110
|
+
# pln.prop_stf = {"gantry_angles": [90, 270], "couch_angles": [0, 0], "generator": "IMPT"}
|
|
111
|
+
# stf = generate_stf(ct,cst,pln)
|
|
112
|
+
|
|
113
|
+
# Low level:
|
|
114
|
+
stf_gen = StfGeneratorIMPT()
|
|
115
|
+
stf_gen.gantry_angles = [90, 270]
|
|
116
|
+
stf_gen.couch_angles = [0, 0]
|
|
117
|
+
stf = stf_gen.generate(ct,cst)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If you are interested in helping with development, get in touch, read the contributing guidelines, and the developer note below.
|
|
121
|
+
|
|
122
|
+
## Contributing & Notes for Developers
|
|
123
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
124
|
+
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]`
|
|
125
|
+
|
|
126
|
+
> **Note**
|
|
127
|
+
> 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
|
|
128
|
+
|
|
129
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
130
|
+
- **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.
|
|
131
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
132
|
+
|
|
133
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
134
|
+
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.
|
|
135
|
+
|
|
136
|
+
### Matlab / Octave Files & Engine
|
|
137
|
+
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`.
|
|
138
|
+
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.
|
|
139
|
+
To use Octave via oct2py, analogously append `[octave]`.
|
|
@@ -0,0 +1,95 @@
|
|
|
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 load_patient, IonPlan, generate_stf, calc_dose_influence, fluence_optimization
|
|
23
|
+
|
|
24
|
+
# Read patient from provided TG119.mat file and validate data
|
|
25
|
+
tg119_path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
26
|
+
ct, cst = load_patient(tg119_path)
|
|
27
|
+
|
|
28
|
+
# Create a plan object
|
|
29
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
30
|
+
|
|
31
|
+
# Generate Steering Geometry ("stf")
|
|
32
|
+
stf = generate_stf(ct, cst, pln)
|
|
33
|
+
|
|
34
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
35
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
36
|
+
|
|
37
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
38
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
39
|
+
|
|
40
|
+
# Result
|
|
41
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
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*`:
|
|
45
|
+
|
|
46
|
+
| Plan property | API function | Description | ID |
|
|
47
|
+
| -------- | ------- | ------ | ------- |
|
|
48
|
+
| `prop_stf` | `generate_stf` | Create beam Geometry | generator |
|
|
49
|
+
| `prop_dose_calc` | `calc_dose_influence`, `calc_dose_forward` | Calculate dose matrix / distribution | engine |
|
|
50
|
+
| `prop_opt` | `fluence_optimization` | Optimization of beam fluences | problem
|
|
51
|
+
|
|
52
|
+
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.
|
|
53
|
+
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
#### Low-level API
|
|
57
|
+
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:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
...
|
|
61
|
+
from pyRadPlan.stf import StfGeneratorIMPT
|
|
62
|
+
# Create a plan object
|
|
63
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
64
|
+
|
|
65
|
+
# Equivalent Top Level API configuration
|
|
66
|
+
# pln.prop_stf = {"gantry_angles": [90, 270], "couch_angles": [0, 0], "generator": "IMPT"}
|
|
67
|
+
# stf = generate_stf(ct,cst,pln)
|
|
68
|
+
|
|
69
|
+
# Low level:
|
|
70
|
+
stf_gen = StfGeneratorIMPT()
|
|
71
|
+
stf_gen.gantry_angles = [90, 270]
|
|
72
|
+
stf_gen.couch_angles = [0, 0]
|
|
73
|
+
stf = stf_gen.generate(ct,cst)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If you are interested in helping with development, get in touch, read the contributing guidelines, and the developer note below.
|
|
77
|
+
|
|
78
|
+
## Contributing & Notes for Developers
|
|
79
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
80
|
+
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]`
|
|
81
|
+
|
|
82
|
+
> **Note**
|
|
83
|
+
> 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
|
|
84
|
+
|
|
85
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
86
|
+
- **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.
|
|
87
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
88
|
+
|
|
89
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
### Matlab / Octave Files & Engine
|
|
93
|
+
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`.
|
|
94
|
+
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.
|
|
95
|
+
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
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
|
|
10
|
+
from pyRadPlan import (
|
|
11
|
+
IonPlan,
|
|
12
|
+
load_patient,
|
|
13
|
+
generate_stf,
|
|
14
|
+
calc_dose_influence,
|
|
15
|
+
fluence_optimization,
|
|
16
|
+
plot_slice,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
logging.basicConfig(level=logging.INFO)
|
|
20
|
+
|
|
21
|
+
# Read patient from provided TG119.mat file and validate data
|
|
22
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
23
|
+
ct, cst = load_patient(path)
|
|
24
|
+
|
|
25
|
+
# Create a plan object
|
|
26
|
+
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
27
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
28
|
+
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
29
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
30
|
+
|
|
31
|
+
# Generate Steering Geometry ("stf")
|
|
32
|
+
stf = generate_stf(ct, cst, pln)
|
|
33
|
+
|
|
34
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
35
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
36
|
+
|
|
37
|
+
# Optimize
|
|
38
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
39
|
+
|
|
40
|
+
# Result
|
|
41
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
42
|
+
|
|
43
|
+
# Choose a slice to visualize
|
|
44
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
45
|
+
|
|
46
|
+
# Visualize
|
|
47
|
+
plot_slice(
|
|
48
|
+
ct=ct,
|
|
49
|
+
cst=cst,
|
|
50
|
+
overlay=result["physical_dose"],
|
|
51
|
+
view_slice=view_slice,
|
|
52
|
+
plane="axial",
|
|
53
|
+
overlay_unit="Gy",
|
|
54
|
+
)
|
|
55
|
+
plot_slice(
|
|
56
|
+
ct=ct,
|
|
57
|
+
cst=cst,
|
|
58
|
+
overlay=result["effect"],
|
|
59
|
+
view_slice=view_slice,
|
|
60
|
+
plane="axial",
|
|
61
|
+
overlay_unit="dimensionless",
|
|
62
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from pyRadPlan import (
|
|
10
|
+
IonPlan,
|
|
11
|
+
load_patient,
|
|
12
|
+
generate_stf,
|
|
13
|
+
calc_dose_influence,
|
|
14
|
+
fluence_optimization,
|
|
15
|
+
plot_slice,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
logging.basicConfig(level=logging.INFO)
|
|
19
|
+
|
|
20
|
+
# Read patient from provided TG119.mat file and validate data
|
|
21
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
22
|
+
ct, cst = load_patient(path)
|
|
23
|
+
|
|
24
|
+
# Create a plan object
|
|
25
|
+
pln = IonPlan(radiation_mode="helium", machine="Generic")
|
|
26
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
27
|
+
|
|
28
|
+
# Generate Steering Geometry ("stf")
|
|
29
|
+
stf = generate_stf(ct, cst, pln)
|
|
30
|
+
|
|
31
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
32
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
33
|
+
|
|
34
|
+
# Optimize
|
|
35
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
36
|
+
|
|
37
|
+
# Result
|
|
38
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
39
|
+
|
|
40
|
+
# Choose a slice to visualize
|
|
41
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
42
|
+
|
|
43
|
+
# Visualize
|
|
44
|
+
plot_slice(
|
|
45
|
+
ct=ct,
|
|
46
|
+
cst=cst,
|
|
47
|
+
overlay=result["physical_dose"],
|
|
48
|
+
view_slice=view_slice,
|
|
49
|
+
plane="axial",
|
|
50
|
+
overlay_unit="Gy",
|
|
51
|
+
)
|
|
@@ -1,102 +1,97 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Example of importing a patient from a MatRad file and visualizing the CT,
|
|
3
|
-
VOIs with matplotlib.
|
|
4
|
-
|
|
5
|
-
Also produces a simple beam configuration and visualizes the resulting radiological depth cubes by
|
|
6
|
-
calling the RayTracer.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
# Standard Library Imports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
from pyRadPlan.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
cst =
|
|
38
|
-
|
|
39
|
-
# Choose a slice to visualize
|
|
40
|
-
view_slice = int(np.round(ct.size[2] / 2))
|
|
41
|
-
|
|
42
|
-
# We store images as sitk.Image objects, but we can easily convert them to numpy arrays for
|
|
43
|
-
# matplotlib. Taking a "view" here means we do not perform a deep copy of the image data.
|
|
44
|
-
cube_hu = sitk.GetArrayViewFromImage(ct.cube_hu)
|
|
45
|
-
plt.imshow(cube_hu[view_slice, :, :], cmap="gray")
|
|
46
|
-
|
|
47
|
-
# Now let's visualize the VOIs from the StructureSet.
|
|
48
|
-
for v, voi in enumerate(cst.vois):
|
|
49
|
-
mask = sitk.GetArrayViewFromImage(voi.mask)
|
|
50
|
-
plt.imshow(
|
|
51
|
-
(v + 1) * mask[view_slice, :, :],
|
|
52
|
-
cmap="jet",
|
|
53
|
-
alpha=0.5 * (mask[view_slice, :, :] > 0),
|
|
54
|
-
vmin=1,
|
|
55
|
-
vmax=len(cst.vois),
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
# Since we want to do planning, we create a plan object.
|
|
59
|
-
# We choose protons as the radiation mode and a Generic machine included with pyRadPlan
|
|
60
|
-
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
61
|
-
|
|
62
|
-
# We use the StfGeneratorIMPT to create a simple beam configuration
|
|
63
|
-
# with a single beam at 0 degrees
|
|
64
|
-
stfgen = StfGeneratorIMPT(pln)
|
|
65
|
-
stfgen.bixel_width = 5.0
|
|
66
|
-
stfgen.gantry_angles = [90.0]
|
|
67
|
-
|
|
68
|
-
# We generate the beam geometry on the CT and CST
|
|
69
|
-
stf = stfgen.generate(ct, cst)
|
|
70
|
-
|
|
71
|
-
# Now let's look at the water equivalent path length for our beam.
|
|
72
|
-
# For that, we use a default HU->rSP table to convert our CT to water-equivalent thickness and then
|
|
73
|
-
# call a voxel-wise RayTracing algorithm (proposed by Siddon) to calculate the radiological depth.
|
|
74
|
-
rt = RayTracerSiddon([ct.compute_wet(default_hlut())])
|
|
75
|
-
rad_depth_cubes = rt.trace_cubes(stf[0])
|
|
76
|
-
|
|
77
|
-
# We could write the image if we want, but we don't do this by default.
|
|
78
|
-
# sitk.WriteImage(ct.compute_wet(default_hlut()), "wet.nrrd")
|
|
79
|
-
# sitk.WriteImage(rad_depth_cubes[0], "rad_depth_cubes.nrrd")
|
|
80
|
-
|
|
81
|
-
# Let's see about our range of radiological depths
|
|
82
|
-
rd_np = sitk.GetArrayFromImage(rad_depth_cubes[0])
|
|
83
|
-
rd_np.ravel()[np.isnan(rd_np.ravel())] = 0
|
|
84
|
-
min_rad_depth = np.min(rd_np)
|
|
85
|
-
max_rad_depth = np.nanmax(rd_np)
|
|
86
|
-
print(f"Minimum rad depth: {min_rad_depth}
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# And finally, output!
|
|
100
|
-
plt.draw()
|
|
101
|
-
plt.pause(0.001)
|
|
102
|
-
plt.show()
|
|
1
|
+
"""
|
|
2
|
+
Example of importing a patient from a MatRad file and visualizing the CT,
|
|
3
|
+
VOIs with matplotlib.
|
|
4
|
+
|
|
5
|
+
Also produces a simple beam configuration and visualizes the resulting radiological depth cubes by
|
|
6
|
+
calling the RayTracer.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Standard Library Imports
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from importlib import resources # Standard from Python 3.9+
|
|
14
|
+
except ImportError:
|
|
15
|
+
import importlib_resources as resources # Backport for older versions
|
|
16
|
+
|
|
17
|
+
# Third Party Imports from pyRadPlan requirements
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
import SimpleITK as sitk
|
|
21
|
+
import matplotlib.pyplot as plt
|
|
22
|
+
|
|
23
|
+
# pyRadPlan Module Imports
|
|
24
|
+
from pyRadPlan.ct import default_hlut
|
|
25
|
+
from pyRadPlan.plan import IonPlan
|
|
26
|
+
from pyRadPlan.stf.generators import StfGeneratorIMPT
|
|
27
|
+
from pyRadPlan.raytracer import RayTracerSiddon
|
|
28
|
+
from pyRadPlan.visualization import plot_slice
|
|
29
|
+
from pyRadPlan.io import load_patient
|
|
30
|
+
|
|
31
|
+
# Configure the Logger to show you debug information
|
|
32
|
+
logging.basicConfig(level=logging.INFO)
|
|
33
|
+
logging.getLogger("pyRadPlan").setLevel(logging.DEBUG)
|
|
34
|
+
|
|
35
|
+
# Read patient from provided TG119.mat file and validate data
|
|
36
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
37
|
+
ct, cst = load_patient(path)
|
|
38
|
+
|
|
39
|
+
# Choose a slice to visualize
|
|
40
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
41
|
+
|
|
42
|
+
# We store images as sitk.Image objects, but we can easily convert them to numpy arrays for
|
|
43
|
+
# matplotlib. Taking a "view" here means we do not perform a deep copy of the image data.
|
|
44
|
+
cube_hu = sitk.GetArrayViewFromImage(ct.cube_hu)
|
|
45
|
+
plt.imshow(cube_hu[view_slice, :, :], cmap="gray")
|
|
46
|
+
|
|
47
|
+
# Now let's visualize the VOIs from the StructureSet.
|
|
48
|
+
for v, voi in enumerate(cst.vois):
|
|
49
|
+
mask = sitk.GetArrayViewFromImage(voi.mask)
|
|
50
|
+
plt.imshow(
|
|
51
|
+
(v + 1) * mask[view_slice, :, :],
|
|
52
|
+
cmap="jet",
|
|
53
|
+
alpha=0.5 * (mask[view_slice, :, :] > 0),
|
|
54
|
+
vmin=1,
|
|
55
|
+
vmax=len(cst.vois),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Since we want to do planning, we create a plan object.
|
|
59
|
+
# We choose protons as the radiation mode and a Generic machine included with pyRadPlan
|
|
60
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
61
|
+
|
|
62
|
+
# We use the StfGeneratorIMPT to create a simple beam configuration
|
|
63
|
+
# with a single beam at 0 degrees
|
|
64
|
+
stfgen = StfGeneratorIMPT(pln)
|
|
65
|
+
stfgen.bixel_width = 5.0
|
|
66
|
+
stfgen.gantry_angles = [90.0]
|
|
67
|
+
|
|
68
|
+
# We generate the beam geometry on the CT and CST
|
|
69
|
+
stf = stfgen.generate(ct, cst)
|
|
70
|
+
|
|
71
|
+
# Now let's look at the water equivalent path length for our beam.
|
|
72
|
+
# For that, we use a default HU->rSP table to convert our CT to water-equivalent thickness and then
|
|
73
|
+
# call a voxel-wise RayTracing algorithm (proposed by Siddon) to calculate the radiological depth.
|
|
74
|
+
rt = RayTracerSiddon([ct.compute_wet(default_hlut())])
|
|
75
|
+
rad_depth_cubes = rt.trace_cubes(stf[0])
|
|
76
|
+
|
|
77
|
+
# We could write the image if we want, but we don't do this by default.
|
|
78
|
+
# sitk.WriteImage(ct.compute_wet(default_hlut()), "wet.nrrd")
|
|
79
|
+
# sitk.WriteImage(rad_depth_cubes[0], "rad_depth_cubes.nrrd")
|
|
80
|
+
|
|
81
|
+
# Let's see about our range of radiological depths
|
|
82
|
+
rd_np = sitk.GetArrayFromImage(rad_depth_cubes[0])
|
|
83
|
+
rd_np.ravel()[np.isnan(rd_np.ravel())] = 0
|
|
84
|
+
min_rad_depth = np.min(rd_np)
|
|
85
|
+
max_rad_depth = np.nanmax(rd_np)
|
|
86
|
+
print(f"Minimum rad depth: {min_rad_depth}Maximum rad depth: {max_rad_depth}")
|
|
87
|
+
|
|
88
|
+
# Visualize
|
|
89
|
+
plot_slice(
|
|
90
|
+
ct=ct,
|
|
91
|
+
cst=cst,
|
|
92
|
+
overlay=rd_np,
|
|
93
|
+
view_slice=view_slice,
|
|
94
|
+
plane="axial",
|
|
95
|
+
overlay_unit="mm",
|
|
96
|
+
overlay_rel_threshold=1e-3,
|
|
97
|
+
)
|