pyRadPlan 0.2.7__tar.gz → 0.3.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.2.7/pyRadPlan.egg-info → pyradplan-0.3.0}/PKG-INFO +12 -8
- pyradplan-0.3.0/examples/intro_minimal_photons.py +39 -0
- pyradplan-0.2.7/examples/helium_pencilbeam.py → pyradplan-0.3.0/examples/intro_minimal_protons.py +11 -18
- pyradplan-0.3.0/examples/mc_fred.py +123 -0
- pyradplan-0.3.0/examples/pencilbeam_carbon.py +71 -0
- pyradplan-0.2.7/examples/proton_pencilbeam.py → pyradplan-0.3.0/examples/pencilbeam_helium.py +26 -3
- pyradplan-0.2.7/examples/photon_pencilbeam.py → pyradplan-0.3.0/examples/pencilbeam_photon.py +28 -5
- pyradplan-0.3.0/examples/pencilbeam_proton.py +82 -0
- pyradplan-0.2.7/examples/proton_let_optimization.py → pyradplan-0.3.0/examples/pencilbeam_proton_let.py +34 -6
- pyradplan-0.3.0/examples/pencilbeam_vhee.py +92 -0
- pyradplan-0.2.7/examples/import_matrad_patient.py → pyradplan-0.3.0/examples/raytracer_rad_depth.py +9 -3
- pyradplan-0.3.0/examples/utils_matrad.py +75 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/__init__.py +27 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/analysis/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/_grids.py +2 -2
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/datamodel.py +53 -7
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/np2sitk.py +31 -21
- pyradplan-0.3.0/pyRadPlan/core/xp_utils/__init__.py +90 -0
- pyradplan-0.3.0/pyRadPlan/core/xp_utils/compat.py +190 -0
- pyradplan-0.3.0/pyRadPlan/core/xp_utils/helpers.py +385 -0
- pyradplan-0.3.0/pyRadPlan/core/xp_utils/typing.py +63 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/cst/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/cst/_cst.py +206 -109
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/cst/_voi.py +15 -19
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/ct/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/ct/_ct.py +151 -87
- pyradplan-0.3.0/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
- pyradplan-0.3.0/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dij/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dij/_dij.py +154 -37
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/__init__.py +5 -1
- pyradplan-0.3.0/pyRadPlan/dose/engines/_base_montecarlo.py +8 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_base_pencilbeam.py +136 -88
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +66 -27
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_factory.py +1 -1
- pyradplan-0.3.0/pyRadPlan/dose/engines/_fredmc.py +1433 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_hongpb.py +33 -16
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_svdpb.py +0 -6
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/geometry/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/io/__init__.py +2 -0
- pyradplan-0.3.0/pyRadPlan/machines/__init__.py +37 -0
- pyradplan-0.3.0/pyRadPlan/machines/_validate.py +42 -0
- pyradplan-0.3.0/pyRadPlan/machines/base/__init__.py +14 -0
- pyradplan-0.3.0/pyRadPlan/machines/base/_base.py +59 -0
- pyradplan-0.2.7/pyRadPlan/machines/_base.py → pyradplan-0.3.0/pyRadPlan/machines/base/_external_beam.py +9 -53
- pyradplan-0.3.0/pyRadPlan/machines/base/_factory.py +55 -0
- pyradplan-0.3.0/pyRadPlan/machines/base/_internal_beam.py +7 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/__init__.py +15 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_base.py +331 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_beam_cutoff.py +41 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_beam_emittance.py +19 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_beam_energy.py +44 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_beam_focus.py +37 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_ions.py +85 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/_vhee.py +33 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/kernel/__init__.py +7 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/kernel/_base.py +168 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/kernel/_ions.py +24 -0
- pyradplan-0.3.0/pyRadPlan/machines/particles/kernel/_vhee.py +7 -0
- pyradplan-0.3.0/pyRadPlan/machines/photons/__init__.py +6 -0
- pyradplan-0.3.0/pyRadPlan/machines/photons/_base.py +3 -0
- pyradplan-0.2.7/pyRadPlan/machines/_photons.py → pyradplan-0.3.0/pyRadPlan/machines/photons/_linac.py +13 -100
- pyradplan-0.3.0/pyRadPlan/machines/photons/_svd_kernel.py +102 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/matRad/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/__init__.py +1 -5
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/objectives/__init__.py +1 -1
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_eud.py +54 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/objectives/_factory.py +1 -1
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_max_dvh.py +58 -0
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_mean.py +53 -0
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_min_dvh.py +58 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/objectives/_objective.py +5 -7
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/objectives/_squared_dev.py +9 -17
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_squared_over.py +39 -0
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_squared_under.py +38 -0
- pyradplan-0.3.0/pyRadPlan/optimization/objectives/_std.py +28 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/problems/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/problems/_factory.py +2 -2
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/problems/_nonlin_fluence.py +105 -67
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/problems/_optiprob.py +43 -28
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/solvers/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/solvers/_base_solvers.py +65 -7
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/solvers/_factory.py +1 -1
- pyradplan-0.3.0/pyRadPlan/optimization/solvers/_ipopt.py +189 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/solvers/_scipy_solver.py +36 -9
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/plan/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/plan/_plans.py +8 -2
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/quantities/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/quantities/_base.py +77 -31
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/quantities/_dose.py +11 -5
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/quantities/_let_x_dose.py +11 -5
- pyradplan-0.3.0/pyRadPlan/raytracer/_siddon.py +568 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/scenarios/__init__.py +1 -6
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/__init__.py +1 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_beam.py +30 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_ray.py +46 -13
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/__init__.py +5 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/_ions.py +42 -0
- pyradplan-0.3.0/pyRadPlan/stf/generators/_vhee.py +186 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/util/__init__.py +2 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/util/helpers.py +12 -11
- pyradplan-0.3.0/pyRadPlan/util/keyboard_listener.py +197 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/visualization/_plot_slice.py +6 -1
- {pyradplan-0.2.7 → pyradplan-0.3.0/pyRadPlan.egg-info}/PKG-INFO +12 -8
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan.egg-info/SOURCES.txt +47 -12
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan.egg-info/requires.txt +8 -4
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyproject.toml +15 -10
- pyradplan-0.3.0/test/compute/test_math_interp1d.py +156 -0
- pyradplan-0.3.0/test/compute/test_math_quantile.py +76 -0
- pyradplan-0.3.0/test/compute/test_namespace_conversion.py +33 -0
- pyradplan-0.3.0/test/conftest.py +101 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/core/test_coordinates.py +1 -1
- pyradplan-0.3.0/test/core/test_datamodel.py +120 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/cst/test_cst.py +110 -7
- pyradplan-0.3.0/test/dose/test_fred.py +336 -0
- pyradplan-0.3.0/test/dose/test_pb_geodist.py +105 -0
- pyradplan-0.3.0/test/optimization/test_ipopt_solver.py +89 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/optimization/test_objectives.py +50 -27
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/optimization/test_scipy_solver.py +7 -5
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/quantities/test_dose_quantity.py +8 -7
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/quantities/test_let_dose_quantity.py +9 -5
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/stf/test_stf.py +23 -34
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/stf/test_stf_gen.py +10 -25
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_dij.py +67 -48
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_machine_model.py +6 -5
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_raytracersiddon.py +4 -3
- pyradplan-0.2.7/examples/carbon_pencilbeam.py +0 -56
- pyradplan-0.2.7/pyRadPlan/data/stf/matRad_stf.mat +0 -0
- pyradplan-0.2.7/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
- pyradplan-0.2.7/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
- pyradplan-0.2.7/pyRadPlan/machines/__init__.py +0 -19
- pyradplan-0.2.7/pyRadPlan/machines/_ions.py +0 -593
- pyradplan-0.2.7/pyRadPlan/machines/_validate.py +0 -61
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_eud.py +0 -50
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_max_dvh.py +0 -54
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_mean.py +0 -50
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_min_dvh.py +0 -54
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_squared_over.py +0 -45
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_squared_under.py +0 -45
- pyradplan-0.2.7/pyRadPlan/optimization/objectives/_std.py +0 -36
- pyradplan-0.2.7/pyRadPlan/optimization/solvers/_ipopt.py +0 -112
- pyradplan-0.2.7/pyRadPlan/raytracer/_siddon.py +0 -427
- pyradplan-0.2.7/test/conftest.py +0 -43
- pyradplan-0.2.7/test/core/test_datamodel.py +0 -49
- pyradplan-0.2.7/test/optimization/test_ipopt_solver.py +0 -39
- {pyradplan-0.2.7 → pyradplan-0.3.0}/LICENSE +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/README.md +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/docs/conf.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/analysis/_dvh.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/_exceptions.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/core/resample.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/ct/_hlut.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/_calc_dose.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/dose/engines/_base.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/geometry/lps.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/io/_matlab_file_handler.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/io/_patient_loader.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/io/matfile.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/machines/_load.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/matRad/_engine.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/matRad/_matlab.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/matRad/_octave.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/raytracer/__init__.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/raytracer/_base.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/raytracer/_perf.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/scenarios/_base.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/scenarios/_nominal.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_beamlet.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_exceptions.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_generate_stf.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_rangeshifter.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/_steeringinformation.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/_base.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/_factory.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/stf/generators/_photons.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan/visualization/__init__.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan.egg-info/dependency_links.txt +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/pyRadPlan.egg-info/top_level.txt +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/setup.cfg +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/analysis/test_dvh.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/analysis/test_qi.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/core/test_np2sitk.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/core/test_resample.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/cst/conftest.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/cst/test_VOI.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/ct/test_ct.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/ct/test_hlut.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/data/test_validate_test_data.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/dose/conftest.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/dose/test_dose_engine_base.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/dose/test_factory.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/dose/test_hongpb.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/dose/test_svdpb.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/geometry/test_lps.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/optimization/test_fluence_optiprob.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/optimization/test_problem_factory.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/optimization/test_solver_factory.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/stf/test_beamlet.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_fileHandling.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_grid.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_helpers.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_matlabEngine.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_octaveEngine.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_plan.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/test_scenarios.py +0 -0
- {pyradplan-0.2.7 → pyradplan-0.3.0}/test/visualization/test_plot_slice.py +0 -0
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyRadPlan
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
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>,
|
|
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>, Samir Schulz <samirshivaji.schulz@dkfz-heidelberg.de>
|
|
6
|
+
Maintainer-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>
|
|
7
7
|
Project-URL: Homepage, https://git.dkfz.de
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: BSD License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python:
|
|
11
|
+
Requires-Python: <3.14,>=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: scipy>=1.13.0
|
|
15
|
-
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: numpy<=2.3,>=2.0
|
|
16
|
+
Requires-Dist: array_api_compat
|
|
17
|
+
Requires-Dist: array_api_strict
|
|
18
|
+
Requires-Dist: array_api_extra
|
|
19
|
+
Requires-Dist: types-array-api
|
|
16
20
|
Requires-Dist: pymatreader>=1.0.0
|
|
17
21
|
Requires-Dist: h5py>=3.11.0
|
|
18
22
|
Requires-Dist: regex>=2024.5.15
|
|
19
23
|
Requires-Dist: pydicom>=2.4.4
|
|
20
|
-
Requires-Dist: numba>=0.
|
|
24
|
+
Requires-Dist: numba>=0.61.0
|
|
21
25
|
Requires-Dist: matplotlib>=3.9.2
|
|
22
|
-
Requires-Dist: pydantic<2.
|
|
23
|
-
Requires-Dist: numpydantic>=1.6.
|
|
26
|
+
Requires-Dist: pydantic<2.13,>=2.10
|
|
27
|
+
Requires-Dist: numpydantic>=1.6.9
|
|
24
28
|
Requires-Dist: SimpleITK>=2.4.0
|
|
25
29
|
Requires-Dist: tqdm>=4.0.0
|
|
26
30
|
Requires-Dist: pint>=0.24.0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for photon dose calculation using pencilbeam engine."""
|
|
3
|
+
|
|
4
|
+
# %%
|
|
5
|
+
# Necessary imports
|
|
6
|
+
from pyRadPlan import (
|
|
7
|
+
load_tg119,
|
|
8
|
+
PhotonPlan,
|
|
9
|
+
generate_stf,
|
|
10
|
+
calc_dose_influence,
|
|
11
|
+
fluence_optimization,
|
|
12
|
+
plot_slice,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Read patient from provided TG119.mat file and validate data
|
|
16
|
+
ct, cst = load_tg119()
|
|
17
|
+
|
|
18
|
+
# Create a plan object
|
|
19
|
+
pln = PhotonPlan()
|
|
20
|
+
|
|
21
|
+
# Generate Steering Geometry ("stf")
|
|
22
|
+
stf = generate_stf(ct, cst, pln)
|
|
23
|
+
|
|
24
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
25
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
26
|
+
|
|
27
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
28
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
29
|
+
|
|
30
|
+
# Result
|
|
31
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
32
|
+
|
|
33
|
+
# Plot
|
|
34
|
+
plot_slice(
|
|
35
|
+
ct=ct,
|
|
36
|
+
cst=cst,
|
|
37
|
+
overlay=result["physical_dose"],
|
|
38
|
+
overlay_unit="Gy",
|
|
39
|
+
)
|
pyradplan-0.2.7/examples/helium_pencilbeam.py → pyradplan-0.3.0/examples/intro_minimal_protons.py
RENAMED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for proton dose calculation using pencilbeam engine."""
|
|
4
3
|
|
|
4
|
+
# %%
|
|
5
|
+
# Necessary imports
|
|
5
6
|
from pyRadPlan import (
|
|
6
|
-
IonPlan,
|
|
7
|
-
load_tg119,
|
|
8
|
-
generate_stf,
|
|
9
7
|
calc_dose_influence,
|
|
10
8
|
fluence_optimization,
|
|
9
|
+
generate_stf,
|
|
10
|
+
IonPlan,
|
|
11
|
+
load_tg119,
|
|
11
12
|
plot_slice,
|
|
12
13
|
)
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Load TG119 (provided within pyRadPlan)
|
|
15
|
+
# Read patient from provided TG119.mat file and validate data
|
|
17
16
|
ct, cst = load_tg119()
|
|
18
17
|
|
|
19
18
|
# Create a plan object
|
|
20
|
-
pln = IonPlan(
|
|
21
|
-
pln.prop_stf = {"bixel_width": 4}
|
|
19
|
+
pln = IonPlan()
|
|
22
20
|
|
|
23
21
|
# Generate Steering Geometry ("stf")
|
|
24
22
|
stf = generate_stf(ct, cst, pln)
|
|
@@ -26,21 +24,16 @@ stf = generate_stf(ct, cst, pln)
|
|
|
26
24
|
# Calculate Dose Influence Matrix ("dij")
|
|
27
25
|
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
28
26
|
|
|
29
|
-
#
|
|
27
|
+
# Fluence Optimization (objectives loaded from "cst")
|
|
30
28
|
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
31
29
|
|
|
32
30
|
# Result
|
|
33
31
|
result = dij.compute_result_ct_grid(fluence)
|
|
34
32
|
|
|
35
|
-
#
|
|
36
|
-
view_slice = int(np.round(ct.size[2] / 2))
|
|
37
|
-
|
|
38
|
-
# Visualize
|
|
33
|
+
# Plot
|
|
39
34
|
plot_slice(
|
|
40
35
|
ct=ct,
|
|
41
36
|
cst=cst,
|
|
42
37
|
overlay=result["physical_dose"],
|
|
43
|
-
view_slice=view_slice,
|
|
44
|
-
plane="axial",
|
|
45
38
|
overlay_unit="Gy",
|
|
46
39
|
)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for proton dose calculation using the FRED engine."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how to use the pyRadPlan library to perform proton dose calculations using the FRED Monte Carlo engine.
|
|
5
|
+
|
|
6
|
+
# For installation instructions, please refer to https://www.fred-mc.org/
|
|
7
|
+
|
|
8
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
9
|
+
# This will create a .ipynb file in the same directory:
|
|
10
|
+
|
|
11
|
+
# ```bash
|
|
12
|
+
# pip install jupytext
|
|
13
|
+
# jupytext --to notebook path/to/this/file/proton_MC_FRED.py
|
|
14
|
+
|
|
15
|
+
# %%
|
|
16
|
+
# Import necessary libraries
|
|
17
|
+
import logging
|
|
18
|
+
import numpy as np
|
|
19
|
+
|
|
20
|
+
from pyRadPlan import (
|
|
21
|
+
IonPlan,
|
|
22
|
+
generate_stf,
|
|
23
|
+
calc_dose_influence,
|
|
24
|
+
calc_dose_forward,
|
|
25
|
+
load_tg119,
|
|
26
|
+
fluence_optimization,
|
|
27
|
+
plot_slice,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
|
|
31
|
+
|
|
32
|
+
logging.basicConfig(level=logging.INFO)
|
|
33
|
+
|
|
34
|
+
# %%
|
|
35
|
+
# Load TG119 (provided within pyRadPlan)
|
|
36
|
+
ct, cst = load_tg119()
|
|
37
|
+
|
|
38
|
+
# %% [markdown]
|
|
39
|
+
# In this section, we create a proton therapy plan using the FRED engine.
|
|
40
|
+
# First, we define the parameters for the steering information (`prop_stf`).
|
|
41
|
+
# Next, we specify the settings for dose calculation (`prop_dose_calc`),
|
|
42
|
+
# including compatibility with different FRED versions through `dij_format_version`.
|
|
43
|
+
# Finally, we configure the optimization parameters (`prop_opt`), as demonstrated in previous examples.
|
|
44
|
+
|
|
45
|
+
# Use less histories and beams when experimenting. This reduces computation time significantly.
|
|
46
|
+
|
|
47
|
+
# %%
|
|
48
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
49
|
+
pln.prop_stf = {
|
|
50
|
+
"gantry_angles": [0, 180], # define gantry angles for n beams
|
|
51
|
+
"couch_angles": [0, 0],
|
|
52
|
+
"longitudinal_spot_spacing": 2.0,
|
|
53
|
+
"iso_center": np.array([[-5.0, -5.0, -5.0], [-5.0, -5.0, -5.0]]), # two beams
|
|
54
|
+
"bixel_width": 10,
|
|
55
|
+
"add_margin": 1,
|
|
56
|
+
}
|
|
57
|
+
pln.prop_dose_calc = {
|
|
58
|
+
"engine": "FRED", # Use the FRED engine for dose calculation
|
|
59
|
+
"fred_version": "3.76.0", # std: "3.70.0"
|
|
60
|
+
"use_gpu": True, # std: True | one has to set GPU = 1 using 'fred -config' manually!
|
|
61
|
+
"calc_let": False, # std: False
|
|
62
|
+
"scorers": ["Dose"], # std: ["Dose"]
|
|
63
|
+
"room_material": "Air", # vacuum | std: Air
|
|
64
|
+
"print_output": False,
|
|
65
|
+
"num_histories_per_beamlet": 2e3, # use less histories for faster computation (e.g. 2e2) or less beams
|
|
66
|
+
# "dij_format_version": "31", # 20/30 for fred 3.70.0 and 21/31 for fred 3.76.0
|
|
67
|
+
# "save_input": "path/to/save/input",
|
|
68
|
+
# "save_output": "path/to/save/output", # or True (for current dir)/False | std: False (using temp path)
|
|
69
|
+
# "use_output": "path/to/use/output", # skips output file generation if only 'use_output_file' is set and not 'save_output_file'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
73
|
+
|
|
74
|
+
# %% [markdown]
|
|
75
|
+
# Generate Steering Geometry ("stf")
|
|
76
|
+
# %%
|
|
77
|
+
stf = generate_stf(ct, cst, pln)
|
|
78
|
+
|
|
79
|
+
# %% [markdown]
|
|
80
|
+
# Run calc_dose_influence (dose influence matrix)
|
|
81
|
+
# %%
|
|
82
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
83
|
+
|
|
84
|
+
# %% [markdown]
|
|
85
|
+
# Define cst objectives and run fluence optimization
|
|
86
|
+
# %%
|
|
87
|
+
cst.vois[0].objectives = [SquaredOverdosing(priority=100.0, d_max=1.0)] # OAR
|
|
88
|
+
cst.vois[1].objectives = [SquaredDeviation(priority=1000.0, d_ref=3.0)] # Target
|
|
89
|
+
cst.vois[2].objectives = [
|
|
90
|
+
MeanDose(priority=1.0, d_ref=0.0),
|
|
91
|
+
SquaredOverdosing(priority=10.0, d_max=2.0),
|
|
92
|
+
] # BODY
|
|
93
|
+
|
|
94
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
95
|
+
|
|
96
|
+
# %% [markdown]
|
|
97
|
+
# Compute dose distribution and other quantities given in pln.prop_opt
|
|
98
|
+
# %%
|
|
99
|
+
result_opt = dij.compute_result_ct_grid(fluence)
|
|
100
|
+
|
|
101
|
+
# %% [markdown]
|
|
102
|
+
# Visualize the results
|
|
103
|
+
# %%
|
|
104
|
+
|
|
105
|
+
# Choose a slice to visualize
|
|
106
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
107
|
+
|
|
108
|
+
plot_slice(
|
|
109
|
+
ct=ct,
|
|
110
|
+
cst=cst,
|
|
111
|
+
overlay=result_opt["physical_dose"],
|
|
112
|
+
view_slice=view_slice,
|
|
113
|
+
plane="axial",
|
|
114
|
+
overlay_unit="Gy",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# %% [markdown]
|
|
118
|
+
# You can also run calc_dose_forward (direct dose calculation) without optimization.
|
|
119
|
+
# %%
|
|
120
|
+
# Set run_direct_dose_calc to True to perform direct dose calculation
|
|
121
|
+
run_direct_dose_calc = False
|
|
122
|
+
if run_direct_dose_calc:
|
|
123
|
+
result_fwd = calc_dose_forward(ct, cst, stf, pln, np.ones(stf.total_number_of_bixels))
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for carbon dose calculation using pencilbeam engine."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how to use the pyRadPlan library to perform carbon ion dose calculations with biological effect modeling.
|
|
5
|
+
|
|
6
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
7
|
+
# This will create a .ipynb file in the same directory:
|
|
8
|
+
|
|
9
|
+
# ```bash
|
|
10
|
+
# pip install jupytext
|
|
11
|
+
# jupytext --to notebook path/to/this/file/pencilbeam_carbon.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
15
|
+
import logging
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
|
|
19
|
+
from pyRadPlan import (
|
|
20
|
+
IonPlan,
|
|
21
|
+
load_tg119,
|
|
22
|
+
generate_stf,
|
|
23
|
+
calc_dose_influence,
|
|
24
|
+
fluence_optimization,
|
|
25
|
+
plot_distributions,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
logging.basicConfig(level=logging.INFO)
|
|
29
|
+
|
|
30
|
+
# %%
|
|
31
|
+
# Load TG119 (provided within pyRadPlan)
|
|
32
|
+
ct, cst = load_tg119()
|
|
33
|
+
|
|
34
|
+
# %% [markdown]
|
|
35
|
+
# In this section, we create a carbon ion therapy plan with biological effect calculation.
|
|
36
|
+
# %%
|
|
37
|
+
# Create a plan object
|
|
38
|
+
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
39
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
40
|
+
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
41
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
42
|
+
|
|
43
|
+
# Generate Steering Geometry ("stf")
|
|
44
|
+
stf = generate_stf(ct, cst, pln)
|
|
45
|
+
|
|
46
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
47
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
48
|
+
|
|
49
|
+
# Optimize
|
|
50
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
51
|
+
|
|
52
|
+
# Result
|
|
53
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
54
|
+
|
|
55
|
+
# %%
|
|
56
|
+
# Choose slices to visualize
|
|
57
|
+
view_slice = [int(np.round(ct.size[2] / 2))]
|
|
58
|
+
|
|
59
|
+
# Visualize the results
|
|
60
|
+
# Use plot_distributions to visualize the biological effect and physical dose
|
|
61
|
+
# use plot_slice() for single distributions
|
|
62
|
+
plot_distributions(
|
|
63
|
+
ct=ct,
|
|
64
|
+
cst=cst,
|
|
65
|
+
overlays=[result["effect"], result["physical_dose"]],
|
|
66
|
+
view_slice=view_slice,
|
|
67
|
+
plane="axial",
|
|
68
|
+
overlay_unit=["dimensionless", "Gy"],
|
|
69
|
+
overlay_titles=["Biological Effect", "Physical Dose"],
|
|
70
|
+
show_plot=True,
|
|
71
|
+
)
|
pyradplan-0.2.7/examples/proton_pencilbeam.py → pyradplan-0.3.0/examples/pencilbeam_helium.py
RENAMED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for helium dose calculation using pencilbeam engine."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how to use the pyRadPlan library to perform helium dose calculations.
|
|
5
|
+
|
|
6
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
7
|
+
# This will create a .ipynb file in the same directory:
|
|
8
|
+
|
|
9
|
+
# ```bash
|
|
10
|
+
# pip install jupytext
|
|
11
|
+
# jupytext --to notebook path/to/this/file/pencilbeam_helium.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
1
15
|
import logging
|
|
2
16
|
|
|
3
17
|
import numpy as np
|
|
@@ -15,11 +29,15 @@ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosin
|
|
|
15
29
|
|
|
16
30
|
logging.basicConfig(level=logging.INFO)
|
|
17
31
|
|
|
32
|
+
# %%
|
|
18
33
|
# Load TG119 (provided within pyRadPlan)
|
|
19
34
|
ct, cst = load_tg119()
|
|
20
35
|
|
|
36
|
+
# %% [markdown]
|
|
37
|
+
# In this section, we create a helium therapy plan using the ParticleHongPencilBeamEngine.
|
|
38
|
+
# %%
|
|
21
39
|
# Create a plan object
|
|
22
|
-
pln = IonPlan(radiation_mode="
|
|
40
|
+
pln = IonPlan(radiation_mode="helium", machine="Generic")
|
|
23
41
|
pln.prop_opt = {"solver": "scipy"}
|
|
24
42
|
|
|
25
43
|
# Generate Steering Geometry ("stf")
|
|
@@ -29,17 +47,22 @@ stf = generate_stf(ct, cst, pln)
|
|
|
29
47
|
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
30
48
|
|
|
31
49
|
# Optimization
|
|
32
|
-
cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
|
|
33
50
|
cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
|
|
51
|
+
cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
|
|
34
52
|
cst.vois[2].objectives = [
|
|
35
53
|
MeanDose(priority=1.0, d_ref=0.0),
|
|
36
54
|
SquaredOverdosing(priority=10.0, d_max=2.0),
|
|
37
55
|
] # BODY
|
|
56
|
+
|
|
57
|
+
# Calculate optimized fluence
|
|
38
58
|
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
39
59
|
|
|
40
|
-
#
|
|
60
|
+
# Compute the result on the CT grid
|
|
41
61
|
result = dij.compute_result_ct_grid(fluence)
|
|
42
62
|
|
|
63
|
+
# %% [markdown]
|
|
64
|
+
# Visualize the results
|
|
65
|
+
# %%
|
|
43
66
|
# Choose a slice to visualize
|
|
44
67
|
view_slice = int(np.round(ct.size[2] / 2))
|
|
45
68
|
|
pyradplan-0.2.7/examples/photon_pencilbeam.py → pyradplan-0.3.0/examples/pencilbeam_photon.py
RENAMED
|
@@ -1,23 +1,41 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for photon dose calculation using pencilbeam engine."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how to use the pyRadPlan library to perform photon dose calculations.
|
|
5
|
+
|
|
6
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
7
|
+
# This will create a .ipynb file in the same directory:
|
|
8
|
+
|
|
9
|
+
# ```bash
|
|
10
|
+
# pip install jupytext
|
|
11
|
+
# jupytext --to notebook path/to/this/file/pencilbeam_photon.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
1
15
|
import logging
|
|
2
16
|
|
|
3
17
|
import numpy as np
|
|
4
18
|
|
|
5
19
|
from pyRadPlan import (
|
|
6
20
|
PhotonPlan,
|
|
7
|
-
load_tg119,
|
|
8
21
|
generate_stf,
|
|
9
22
|
calc_dose_influence,
|
|
10
23
|
fluence_optimization,
|
|
11
24
|
plot_slice,
|
|
25
|
+
load_tg119,
|
|
12
26
|
)
|
|
13
27
|
|
|
14
28
|
from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
|
|
15
29
|
|
|
16
30
|
logging.basicConfig(level=logging.INFO)
|
|
17
31
|
|
|
32
|
+
# %%
|
|
18
33
|
# Load TG119 (provided within pyRadPlan)
|
|
19
34
|
ct, cst = load_tg119()
|
|
20
35
|
|
|
36
|
+
# %% [markdown]
|
|
37
|
+
# In this section, we create a photon therapy plan using the ParticleHongPencilBeamEngine.
|
|
38
|
+
# %%
|
|
21
39
|
# Create a plan object
|
|
22
40
|
pln = PhotonPlan(machine="Generic")
|
|
23
41
|
num_of_beams = 5
|
|
@@ -28,22 +46,27 @@ pln.prop_stf = {
|
|
|
28
46
|
# Generate Steering Geometry ("stf")
|
|
29
47
|
stf = generate_stf(ct, cst, pln)
|
|
30
48
|
|
|
49
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
31
50
|
# Calculate Dose Influence Matrix ("dij")
|
|
32
51
|
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
33
52
|
|
|
34
|
-
#
|
|
35
|
-
cst.vois[
|
|
36
|
-
cst.vois[
|
|
53
|
+
# Optimization
|
|
54
|
+
cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
|
|
55
|
+
cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
|
|
37
56
|
cst.vois[2].objectives = [
|
|
38
57
|
MeanDose(priority=1.0, d_ref=0.0),
|
|
39
58
|
SquaredOverdosing(priority=10.0, d_max=2.0),
|
|
40
59
|
] # BODY
|
|
41
60
|
|
|
61
|
+
# Calculate optimized fluence
|
|
42
62
|
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
43
63
|
|
|
44
|
-
#
|
|
64
|
+
# Compute the result on the CT grid
|
|
45
65
|
result = dij.compute_result_ct_grid(fluence)
|
|
46
66
|
|
|
67
|
+
# %% [markdown]
|
|
68
|
+
# Visualize the results
|
|
69
|
+
# %%
|
|
47
70
|
# Choose a slice to visualize
|
|
48
71
|
view_slice = int(np.round(ct.size[2] / 2))
|
|
49
72
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for proton dose calculation using pencilbeam engine."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how to use the pyRadPlan library to perform proton dose calculations.
|
|
5
|
+
|
|
6
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
7
|
+
# This will create a .ipynb file in the same directory:
|
|
8
|
+
|
|
9
|
+
# ```bash
|
|
10
|
+
# pip install jupytext
|
|
11
|
+
# jupytext --to notebook path/to/this/file/pencilbeam_proton.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
15
|
+
import logging
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
|
|
19
|
+
from pyRadPlan import (
|
|
20
|
+
IonPlan,
|
|
21
|
+
generate_stf,
|
|
22
|
+
calc_dose_influence,
|
|
23
|
+
fluence_optimization,
|
|
24
|
+
plot_slice,
|
|
25
|
+
load_tg119,
|
|
26
|
+
xp_utils,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
xp_utils.PREFER_GPU = True
|
|
33
|
+
xp_utils.PREFERRED_CPU_ARRAY_BACKEND = "numpy"
|
|
34
|
+
logging.basicConfig(level=logging.INFO)
|
|
35
|
+
|
|
36
|
+
# %%
|
|
37
|
+
# Load TG119 (provided within pyRadPlan)
|
|
38
|
+
ct, cst = load_tg119()
|
|
39
|
+
|
|
40
|
+
# %% [markdown]
|
|
41
|
+
# In this section, we create a proton therapy plan using the ParticleHongPencilBeamEngine.
|
|
42
|
+
# %%
|
|
43
|
+
# Create a plan object
|
|
44
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
45
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
46
|
+
pln.prop_dose_calc = {"dose_grid": ct.grid}
|
|
47
|
+
|
|
48
|
+
# Generate Steering Geometry ("stf")
|
|
49
|
+
stf = generate_stf(ct, cst, pln)
|
|
50
|
+
|
|
51
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
52
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
53
|
+
|
|
54
|
+
# Optimization
|
|
55
|
+
cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
|
|
56
|
+
cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
|
|
57
|
+
cst.vois[2].objectives = [
|
|
58
|
+
MeanDose(priority=1.0, d_ref=0.0),
|
|
59
|
+
SquaredOverdosing(priority=10.0, d_max=2.0),
|
|
60
|
+
] # BODY
|
|
61
|
+
|
|
62
|
+
# Calculate optimized fluence
|
|
63
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
64
|
+
|
|
65
|
+
# Compute the result on the CT grid
|
|
66
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
67
|
+
|
|
68
|
+
# %% [markdown]
|
|
69
|
+
# Visualize the results
|
|
70
|
+
# %%
|
|
71
|
+
# Choose a slice to visualize
|
|
72
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
73
|
+
|
|
74
|
+
# Visualize
|
|
75
|
+
plot_slice(
|
|
76
|
+
ct=ct,
|
|
77
|
+
cst=cst,
|
|
78
|
+
overlay=result["physical_dose"],
|
|
79
|
+
view_slice=view_slice,
|
|
80
|
+
plane="axial",
|
|
81
|
+
overlay_unit="Gy",
|
|
82
|
+
)
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Example for using LET as quantity during optimization."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates how pyRadPlan handles additional quantities such as LET.
|
|
5
|
+
|
|
6
|
+
# To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
|
|
7
|
+
# This will create a .ipynb file in the same directory:
|
|
8
|
+
|
|
9
|
+
# ```bash
|
|
10
|
+
# pip install jupytext
|
|
11
|
+
# jupytext --to notebook path/to/this/file/proton_let.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
1
15
|
import logging
|
|
2
16
|
|
|
3
17
|
import numpy as np
|
|
@@ -15,7 +29,10 @@ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosin
|
|
|
15
29
|
|
|
16
30
|
logging.basicConfig(level=logging.INFO)
|
|
17
31
|
|
|
18
|
-
#
|
|
32
|
+
# %% [markdown]
|
|
33
|
+
# Just like in the other examples, we load the ct and cst, create the Plan and Steeringinformation
|
|
34
|
+
# %%
|
|
35
|
+
# load TG119
|
|
19
36
|
ct, cst = load_tg119()
|
|
20
37
|
|
|
21
38
|
# Create a plan object
|
|
@@ -28,19 +45,30 @@ stf = generate_stf(ct, cst, pln)
|
|
|
28
45
|
# Calculate Dose Influence Matrix ("dij")
|
|
29
46
|
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
30
47
|
|
|
31
|
-
#
|
|
32
|
-
|
|
48
|
+
# %% [markdown]
|
|
49
|
+
# When defining the objective functions and its parameters, one can add the respective quantity.
|
|
50
|
+
# Standard quantity is physical dose.
|
|
51
|
+
# %%
|
|
52
|
+
# OAR
|
|
33
53
|
cst.vois[0].objectives = [
|
|
34
54
|
SquaredOverdosing(priority=10.0, d_max=1.0),
|
|
35
55
|
SquaredOverdosing(priority=5.0, d_max=1.0, quantity="let_dose"),
|
|
36
|
-
]
|
|
56
|
+
]
|
|
57
|
+
# Target
|
|
58
|
+
cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
|
|
59
|
+
# BODY
|
|
37
60
|
cst.vois[2].objectives = [
|
|
38
61
|
MeanDose(priority=1.0, d_ref=0.0),
|
|
39
62
|
SquaredOverdosing(priority=10.0, d_max=2.0),
|
|
40
|
-
]
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
# %% [markdown]
|
|
66
|
+
# We then calculate the optimized fluence and the corresponding result of the plan.
|
|
67
|
+
# Additionally we plot both the physical dose and the LET.
|
|
68
|
+
# %%
|
|
41
69
|
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
42
70
|
|
|
43
|
-
#
|
|
71
|
+
# Compute the result
|
|
44
72
|
result = dij.compute_result_ct_grid(fluence)
|
|
45
73
|
|
|
46
74
|
# Choose a slice to visualize
|