pyRadPlan 0.3.4__tar.gz → 0.4.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.3.4 → pyradplan-0.4.0}/PKG-INFO +7 -3
- pyradplan-0.4.0/benchmark/benchmark_interp1d.py +156 -0
- pyradplan-0.4.0/benchmark/benchmark_interpnd.py +128 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_carbon.py +6 -4
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_proton.py +2 -10
- pyradplan-0.4.0/examples/proton_mc_fred.py +123 -0
- pyradplan-0.4.0/examples/proton_mc_topas.py +58 -0
- pyradplan-0.4.0/examples/utils_ai_agents.py +136 -0
- pyradplan-0.4.0/examples/utils_backends.py +122 -0
- pyradplan-0.4.0/pyRadPlan/ai_agents/__init__.py +11 -0
- pyradplan-0.4.0/pyRadPlan/ai_agents/_cst_agents.py +142 -0
- pyradplan-0.4.0/pyRadPlan/ai_agents/_plan_agents.py +57 -0
- pyradplan-0.4.0/pyRadPlan/ai_agents/_settings.py +35 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/resample.py +4 -0
- pyradplan-0.4.0/pyRadPlan/core/xp_utils/__init__.py +182 -0
- pyradplan-0.4.0/pyRadPlan/core/xp_utils/compat.py +485 -0
- pyradplan-0.4.0/pyRadPlan/core/xp_utils/helpers.py +706 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/cst/__init__.py +11 -1
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/cst/_cst.py +64 -6
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/cst/_voi.py +74 -2
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/beam_setup/TOPAS_beam_setup_biGaussian.txt.in +19 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/material_converter/TOPAS_schneider_converter.txt.in +2 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/scorer/TOPAS_scorer_doseToMedium.txt.in +8 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/scorer/TOPAS_scorer_doseToWater.txt.in +8 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/scorer/TOPAS_subscorer_LET.txt.in +6 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/template/beamSetup_template.txt +67 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/template/patient_template.txt +19 -0
- pyradplan-0.4.0/pyRadPlan/data/TOPAS/input/template/pyRadPlan_run_template.txt +22 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dij/_dij.py +135 -41
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/__init__.py +3 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_base.py +15 -11
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_base_pencilbeam.py +348 -107
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +150 -89
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_fredmc.py +0 -2
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_hongpb.py +7 -5
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_svdpb.py +28 -19
- pyradplan-0.4.0/pyRadPlan/dose/engines/_topasmc.py +757 -0
- pyradplan-0.4.0/pyRadPlan/dose/engines/kernels/__init__.py +13 -0
- pyradplan-0.4.0/pyRadPlan/dose/engines/kernels/_calc_geo_dists_kernel.py +142 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/geometry/lps.py +48 -24
- pyradplan-0.4.0/pyRadPlan/gui/__init__.py +25 -0
- pyradplan-0.4.0/pyRadPlan/gui/apps.py +54 -0
- pyradplan-0.4.0/pyRadPlan/gui/menus/_edit.py +5 -0
- pyradplan-0.4.0/pyRadPlan/gui/menus/_file.py +8 -0
- pyradplan-0.4.0/pyRadPlan/gui/menus/_help.py +9 -0
- pyradplan-0.4.0/pyRadPlan/gui/menus/_view.py +8 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/__init__.py +5 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/_analysis_widget.py +417 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/_result_widget.py +274 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/analysis/_dvh.py +103 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/analysis/_gamma.py +17 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/analysis/_qi.py +35 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/__init__.py +5 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/_labels.py +30 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/quantity_widget.py +900 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/viewer_options_widget.py +363 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/visualization_widget.py +143 -0
- pyradplan-0.4.0/pyRadPlan/gui/widgets/result/vois_widget.py +291 -0
- pyradplan-0.4.0/pyRadPlan/gui/windows/_analysis_win.py +145 -0
- pyradplan-0.4.0/pyRadPlan/gui/windows/_result_win.py +244 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/_beam_modifier.py +100 -54
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/kernel/_base.py +54 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/problems/_nonlin_fluence.py +12 -5
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/problems/_optiprob.py +64 -45
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/solvers/_base_solvers.py +1 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/solvers/_ipopt.py +6 -4
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/solvers/_scipy_solver.py +4 -2
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/quantities/__init__.py +26 -2
- pyradplan-0.4.0/pyRadPlan/quantities/_alpha_dose.py +37 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_base.py +283 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_dose.py +26 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_effect.py +32 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_let.py +24 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_let_x_dose.py +26 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_rbe_x_dose.py +48 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_resolver.py +103 -0
- pyradplan-0.4.0/pyRadPlan/quantities/_sqrt_beta_dose.py +26 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/raytracer/_siddon.py +39 -20
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_beam.py +7 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_beamlet.py +13 -2
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_ray.py +5 -2
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/visualization/_plot_multiple_slices.py +13 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/visualization/_plot_slice.py +38 -10
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan.egg-info/PKG-INFO +7 -3
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan.egg-info/SOURCES.txt +71 -3
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan.egg-info/requires.txt +6 -2
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyproject.toml +7 -4
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/conftest.py +4 -0
- pyradplan-0.4.0/test/core/xp_utils/compat/test_interp1d_torch.py +128 -0
- pyradplan-0.4.0/test/core/xp_utils/compat/test_interpnd.py +201 -0
- {pyradplan-0.3.4/test/compute → pyradplan-0.4.0/test/core/xp_utils/compat}/test_math_quantile.py +33 -1
- pyradplan-0.4.0/test/core/xp_utils/helpers/test_namespace_conversion.py +196 -0
- pyradplan-0.4.0/test/core/xp_utils/test_initialization.py +163 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/cst/test_VOI.py +18 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/cst/test_cst.py +61 -0
- pyradplan-0.4.0/test/dose/kernels/test_calc_geo_dists.py +695 -0
- pyradplan-0.4.0/test/dose/test_topas.py +68 -0
- pyradplan-0.4.0/test/geometry/test_lps.py +124 -0
- pyradplan-0.4.0/test/gui/conftest.py +61 -0
- pyradplan-0.4.0/test/gui/widgets/analysis/test_widget_analysis.py +31 -0
- pyradplan-0.4.0/test/gui/widgets/analysis/test_widget_dvh.py +24 -0
- pyradplan-0.4.0/test/gui/widgets/analysis/test_widget_gamma.py +0 -0
- pyradplan-0.4.0/test/gui/widgets/analysis/test_widget_qi.py +0 -0
- pyradplan-0.4.0/test/gui/widgets/result/test_widget_quantity.py +99 -0
- pyradplan-0.4.0/test/gui/widgets/result/test_widget_viewer_options.py +67 -0
- pyradplan-0.4.0/test/gui/widgets/result/test_widget_visualization.py +49 -0
- pyradplan-0.4.0/test/gui/widgets/result/test_widget_vois.py +56 -0
- pyradplan-0.4.0/test/gui/widgets/test_widget_result.py +68 -0
- pyradplan-0.4.0/test/gui/windows/test_win_analysis.py +44 -0
- pyradplan-0.4.0/test/gui/windows/test_win_result.py +15 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_ipopt_solver.py +1 -0
- pyradplan-0.4.0/test/quantities/test_alpha_dose_quantity.py +116 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/quantities/test_dose_quantity.py +3 -2
- pyradplan-0.4.0/test/quantities/test_effect_quantity.py +143 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/quantities/test_let_dose_quantity.py +3 -2
- pyradplan-0.4.0/test/quantities/test_rbe_x_dose_quantity.py +146 -0
- pyradplan-0.4.0/test/quantities/test_resolver.py +132 -0
- pyradplan-0.4.0/test/quantities/test_sqrt_beta_dose_quantity.py +120 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_dij.py +12 -0
- pyradplan-0.3.4/pyRadPlan/core/xp_utils/__init__.py +0 -90
- pyradplan-0.3.4/pyRadPlan/core/xp_utils/compat.py +0 -190
- pyradplan-0.3.4/pyRadPlan/core/xp_utils/helpers.py +0 -436
- pyradplan-0.3.4/pyRadPlan/dose/engines/kernels/_calc_geo_dists_kernel.py +0 -232
- pyradplan-0.3.4/pyRadPlan/quantities/_base.py +0 -226
- pyradplan-0.3.4/pyRadPlan/quantities/_dose.py +0 -37
- pyradplan-0.3.4/pyRadPlan/quantities/_let_x_dose.py +0 -35
- pyradplan-0.3.4/test/compute/test_namespace_conversion.py +0 -33
- pyradplan-0.3.4/test/geometry/test_lps.py +0 -96
- {pyradplan-0.3.4 → pyradplan-0.4.0}/LICENSE +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/README.md +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/benchmark/bench_trace_cubes.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/docs/conf.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/intro_minimal_photons.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/intro_minimal_protons.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/mc_fred.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_helium.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_photon.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_photon_forward.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_proton_let.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/pencilbeam_vhee.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/proton_mimicking.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/raytracer_rad_depth.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/utils_matrad.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/examples/utils_plotting.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/analysis/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/analysis/_dvh.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/_exceptions.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/_grids.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/datamodel.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/np2sitk.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/core/xp_utils/typing.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/ct/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/ct/_ct.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/ct/_hlut.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dij/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/_calc_dose.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_base_montecarlo.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/dose/engines/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/geometry/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/io/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/io/_matlab_file_handler.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/io/_patient_loader.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/io/matfile.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/_load.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/_validate.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/_external_beam.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/base/_internal_beam.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_beam_cutoff.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_beam_emittance.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_beam_energy.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_beam_focus.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_ions.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/_vhee.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/kernel/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/kernel/_ions.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/particles/kernel/_vhee.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/photons/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/photons/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/photons/_calculate_machine_scale.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/photons/_linac.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/machines/photons/_svd_kernel.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/matRad/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/matRad/_engine.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/matRad/_matlab.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/matRad/_octave.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_eud.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_mean.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_objective.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_squared_mimicking.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/objectives/_std.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/problems/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/problems/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/solvers/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/optimization/solvers/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/plan/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/plan/_plans.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/raytracer/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/raytracer/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/raytracer/_numba_perf.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/scenarios/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/scenarios/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/scenarios/_nominal.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_exceptions.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_generate_stf.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_rangeshifter.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/_steeringinformation.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_ions.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_photons.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/stf/generators/_vhee.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/util/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/util/helpers.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/util/keyboard_listener.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan/visualization/__init__.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan.egg-info/dependency_links.txt +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/pyRadPlan.egg-info/top_level.txt +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/setup.cfg +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/analysis/test_dvh.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/analysis/test_qi.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/core/test_coordinates.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/core/test_datamodel.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/core/test_np2sitk.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/core/test_resample.py +0 -0
- {pyradplan-0.3.4/test/compute → pyradplan-0.4.0/test/core/xp_utils/compat}/test_math_interp1d.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/cst/conftest.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/ct/test_ct.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/ct/test_hlut.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/data/test_validate_test_data.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/conftest.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_base_pencilbeam.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_dose_engine_base.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_fred.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_hongpb.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_pb_geodist.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/dose/test_svdpb.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/machines/test_beam_modifiers.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_fluence_optiprob.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_objectives.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_problem_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_scipy_solver.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/optimization/test_solver_factory.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/stf/test_beamlet.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/stf/test_stf.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/stf/test_stf_gen.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_fileHandling.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_grid.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_helpers.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_machine_model.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_matlabEngine.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_octaveEngine.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_plan.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_raytracersiddon.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/test_scenarios.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/visualization/test_plot_multiple_slices.py +0 -0
- {pyradplan-0.3.4 → pyradplan-0.4.0}/test/visualization/test_plot_slice.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyRadPlan
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A python interface and reimplementation to matRad
|
|
5
5
|
Author-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Lina Bucher <lina.bucher@dkfz-heidelberg.de>, Louis Ermeneux <louis.ermeneux@gmail.com>, Antonios Kontopoulos <antonios.kontopoulos@dkfz-heidelberg.de>, Julius Laub <julius.laub@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Victoria Santiago Aguilar <victoria.santiagoaguilar@dkfz-heidelberg.de>, Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Samir Schulz <samirshivaji.schulz@dkfz-heidelberg.de>, Wilfrid Wangon Zekou <wangonwil@gmail.com>, Jennifer Josephine Hardt <jennifer.hardt@dkfz-heidelberg.de>
|
|
6
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>
|
|
@@ -22,17 +22,21 @@ Requires-Dist: h5py>=3.11.0
|
|
|
22
22
|
Requires-Dist: regex>=2024.5.15
|
|
23
23
|
Requires-Dist: pydicom>=2.4.4
|
|
24
24
|
Requires-Dist: matplotlib>=3.9.2
|
|
25
|
-
Requires-Dist: pydantic<2.
|
|
25
|
+
Requires-Dist: pydantic<2.20,>=2.10
|
|
26
|
+
Requires-Dist: pydantic-settings<3.0,>=2.0
|
|
27
|
+
Requires-Dist: pydantic_ai<2.0,>=1.60
|
|
26
28
|
Requires-Dist: numpydantic>=1.6.9
|
|
27
29
|
Requires-Dist: SimpleITK>=2.4.0
|
|
28
30
|
Requires-Dist: tqdm>=4.0.0
|
|
29
31
|
Requires-Dist: pint>=0.24.0
|
|
32
|
+
Requires-Dist: jinja2
|
|
30
33
|
Provides-Extra: matlab
|
|
31
34
|
Requires-Dist: matlabengine; extra == "matlab"
|
|
32
35
|
Provides-Extra: octave
|
|
33
36
|
Requires-Dist: oct2py; extra == "octave"
|
|
34
37
|
Provides-Extra: gui
|
|
35
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: pyside6>=6.0.1; extra == "gui"
|
|
39
|
+
Requires-Dist: pyqtgraph>=0.12.0; extra == "gui"
|
|
36
40
|
Provides-Extra: numba
|
|
37
41
|
Requires-Dist: numba>=0.61.0; extra == "numba"
|
|
38
42
|
Provides-Extra: dev
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Benchmark interp1d with different backends."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from pyRadPlan.core.xp_utils.compat import interp1d
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import jax
|
|
11
|
+
import jax.numpy as jnp
|
|
12
|
+
except Exception:
|
|
13
|
+
jax = None
|
|
14
|
+
jnp = None
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
import cupy as cp
|
|
18
|
+
except Exception:
|
|
19
|
+
cp = None
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
import torch
|
|
23
|
+
except Exception:
|
|
24
|
+
torch = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# %% Helpers
|
|
28
|
+
def _make_case(xp, y_ndim: int):
|
|
29
|
+
n_grid = 4096
|
|
30
|
+
n_query = 100_000
|
|
31
|
+
n_series = 32
|
|
32
|
+
|
|
33
|
+
x_np = np.linspace(0.0, 1.0, n_grid)
|
|
34
|
+
|
|
35
|
+
rng = np.random.default_rng(42)
|
|
36
|
+
xq_np = rng.uniform(0.0, 1.0, size=n_query)
|
|
37
|
+
|
|
38
|
+
if y_ndim == 1:
|
|
39
|
+
y_np = np.sin(2 * np.pi * x_np)
|
|
40
|
+
elif y_ndim == 2:
|
|
41
|
+
y_np = np.stack(
|
|
42
|
+
[np.sin(2 * np.pi * x_np * (i + 1)) + 0.1 * i * x_np for i in range(n_series)],
|
|
43
|
+
axis=0,
|
|
44
|
+
)
|
|
45
|
+
else:
|
|
46
|
+
raise ValueError(y_ndim)
|
|
47
|
+
|
|
48
|
+
xq = xp.asarray(xq_np, dtype=xp.float64)
|
|
49
|
+
x = xp.asarray(x_np, dtype=xp.float64)
|
|
50
|
+
y = xp.asarray(y_np, dtype=xp.float64)
|
|
51
|
+
|
|
52
|
+
return xq, x, y
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _make_sequence_case(xp):
|
|
56
|
+
n_grid = 4096
|
|
57
|
+
n_query = 100_000
|
|
58
|
+
n_series = 8
|
|
59
|
+
|
|
60
|
+
x_np = np.linspace(0.0, 1.0, n_grid)
|
|
61
|
+
|
|
62
|
+
rng = np.random.default_rng(42)
|
|
63
|
+
xq_np = rng.uniform(0.0, 1.0, size=n_query)
|
|
64
|
+
|
|
65
|
+
ys_np = [np.sin(2 * np.pi * x_np * (i + 1)) + 0.1 * i * x_np for i in range(n_series)]
|
|
66
|
+
|
|
67
|
+
xq = xp.asarray(xq_np, dtype=xp.float64)
|
|
68
|
+
x = xp.asarray(x_np, dtype=xp.float64)
|
|
69
|
+
y = [xp.asarray(v, dtype=xp.float64) for v in ys_np]
|
|
70
|
+
|
|
71
|
+
return xq, x, y
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _block_until_ready(result):
|
|
75
|
+
if jax is not None and hasattr(result, "block_until_ready"):
|
|
76
|
+
result.block_until_ready()
|
|
77
|
+
|
|
78
|
+
if cp is not None:
|
|
79
|
+
try:
|
|
80
|
+
cp.cuda.Stream.null.synchronize()
|
|
81
|
+
except Exception:
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
if torch is not None and torch.cuda.is_available():
|
|
85
|
+
try:
|
|
86
|
+
torch.cuda.synchronize()
|
|
87
|
+
except Exception:
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
return result
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# %% Tests
|
|
94
|
+
@pytest.mark.parametrize("y_ndim", [1, 2], ids=["y-1d", "y-2d"])
|
|
95
|
+
def test_interp1d_numpy(benchmark, y_ndim):
|
|
96
|
+
xq, x, y = _make_case(np, y_ndim)
|
|
97
|
+
|
|
98
|
+
benchmark(lambda: interp1d(xq, x, y))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.skipif(jax is None, reason="JAX not installed")
|
|
102
|
+
@pytest.mark.parametrize("y_ndim", [1, 2], ids=["y-1d", "y-2d"])
|
|
103
|
+
def test_interp1d_jax(benchmark, y_ndim):
|
|
104
|
+
xq, x, y = _make_case(jnp, y_ndim)
|
|
105
|
+
|
|
106
|
+
# Warmup: compile is not benchmarked
|
|
107
|
+
_block_until_ready(interp1d(xq, x, y))
|
|
108
|
+
|
|
109
|
+
benchmark(lambda: _block_until_ready(interp1d(xq, x, y)))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@pytest.mark.skipif(cp is None, reason="CuPy is not available")
|
|
113
|
+
@pytest.mark.parametrize("y_ndim", [1, 2], ids=["y-1d", "y-2d"])
|
|
114
|
+
def test_interp1d_cupy(benchmark, y_ndim):
|
|
115
|
+
xq, x, y = _make_case(cp, y_ndim)
|
|
116
|
+
|
|
117
|
+
# Warmup
|
|
118
|
+
_block_until_ready(interp1d(xq, x, y))
|
|
119
|
+
|
|
120
|
+
benchmark(lambda: _block_until_ready(interp1d(xq, x, y)))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@pytest.mark.skipif(torch is None, reason="PyTorch is not available")
|
|
124
|
+
@pytest.mark.parametrize("y_ndim", [1, 2], ids=["y-1d", "y-2d"])
|
|
125
|
+
def test_interp1d_torch_cpu(benchmark, y_ndim):
|
|
126
|
+
xq, x, y = _make_case(torch, y_ndim)
|
|
127
|
+
|
|
128
|
+
# Warmup: torch.compile is not benchmarked
|
|
129
|
+
_block_until_ready(interp1d(xq, x, y))
|
|
130
|
+
|
|
131
|
+
benchmark(lambda: _block_until_ready(interp1d(xq, x, y)))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@pytest.mark.skipif(
|
|
135
|
+
torch is None or not torch.cuda.is_available(),
|
|
136
|
+
reason="PyTorch CUDA is not available",
|
|
137
|
+
)
|
|
138
|
+
@pytest.mark.parametrize("y_ndim", [1, 2], ids=["y-1d", "y-2d"])
|
|
139
|
+
def test_interp1d_torch_cuda(benchmark, y_ndim):
|
|
140
|
+
xq, x, y = _make_case(torch, y_ndim)
|
|
141
|
+
|
|
142
|
+
xq = xq.cuda()
|
|
143
|
+
x = x.cuda()
|
|
144
|
+
y = y.cuda()
|
|
145
|
+
|
|
146
|
+
# Warmup: torch.compile / CUDA dispatch is not benchmarked
|
|
147
|
+
_block_until_ready(interp1d(xq, x, y))
|
|
148
|
+
|
|
149
|
+
benchmark(lambda: _block_until_ready(interp1d(xq, x, y)))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@pytest.mark.parametrize("stack", [False, True], ids=["list", "list-stack"])
|
|
153
|
+
def test_interp1d_numpy_sequence(benchmark, stack):
|
|
154
|
+
xq, x, y = _make_sequence_case(np)
|
|
155
|
+
|
|
156
|
+
benchmark(lambda: interp1d(xq, x, y, stack=stack))
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Benchmark interpnd with different backends."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from pyRadPlan.core.xp_utils.compat import interpnd
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import jax
|
|
11
|
+
import jax.numpy as jnp
|
|
12
|
+
except Exception:
|
|
13
|
+
jax = None
|
|
14
|
+
jnp = None
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
import cupy as cp
|
|
18
|
+
except Exception:
|
|
19
|
+
cp = None
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
import torch
|
|
23
|
+
except Exception:
|
|
24
|
+
torch = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# %% Helpers
|
|
28
|
+
def _case_size(ndim: int) -> tuple[int, int]:
|
|
29
|
+
if ndim == 2:
|
|
30
|
+
return 256, 10_000
|
|
31
|
+
if ndim == 3:
|
|
32
|
+
return 64, 10_000
|
|
33
|
+
if ndim == 4:
|
|
34
|
+
return 24, 5_000
|
|
35
|
+
raise ValueError(ndim)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _make_case(xp, ndim: int):
|
|
39
|
+
n_grid, n_query = _case_size(ndim)
|
|
40
|
+
|
|
41
|
+
axes_np = tuple(np.linspace(0.0, 1.0, n_grid) for _ in range(ndim))
|
|
42
|
+
|
|
43
|
+
mesh = np.meshgrid(*axes_np, indexing="ij")
|
|
44
|
+
values_np = sum((i + 1) * np.sin(2 * np.pi * m) for i, m in enumerate(mesh))
|
|
45
|
+
|
|
46
|
+
rng = np.random.default_rng(42)
|
|
47
|
+
xq_np = rng.uniform(0.0, 1.0, size=(n_query, ndim))
|
|
48
|
+
|
|
49
|
+
x = tuple(xp.asarray(axis, dtype=xp.float64) for axis in axes_np)
|
|
50
|
+
y = xp.asarray(values_np, dtype=xp.float64)
|
|
51
|
+
xq = xp.asarray(xq_np, dtype=xp.float64)
|
|
52
|
+
|
|
53
|
+
return xq, x, y
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _block_until_ready(result):
|
|
57
|
+
if jax is not None and hasattr(result, "block_until_ready"):
|
|
58
|
+
result.block_until_ready()
|
|
59
|
+
|
|
60
|
+
if cp is not None:
|
|
61
|
+
try:
|
|
62
|
+
cp.cuda.Stream.null.synchronize()
|
|
63
|
+
except Exception:
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
if torch is not None and torch.cuda.is_available():
|
|
67
|
+
try:
|
|
68
|
+
torch.cuda.synchronize()
|
|
69
|
+
except Exception:
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
return result
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# %% Tests
|
|
76
|
+
@pytest.mark.parametrize("ndim", [2, 3, 4], ids=["2d", "3d", "4d"])
|
|
77
|
+
def test_interpnd_numpy(benchmark, ndim):
|
|
78
|
+
xq, x, y = _make_case(np, ndim)
|
|
79
|
+
|
|
80
|
+
benchmark(lambda: interpnd(xq, x, y))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@pytest.mark.skipif(jax is None, reason="JAX not installed")
|
|
84
|
+
@pytest.mark.parametrize("ndim", [2, 3, 4], ids=["2d", "3d", "4d"])
|
|
85
|
+
def test_interpnd_jax(benchmark, ndim):
|
|
86
|
+
xq, x, y = _make_case(jnp, ndim)
|
|
87
|
+
|
|
88
|
+
# Warmup: compile is not benchmarked
|
|
89
|
+
_block_until_ready(interpnd(xq, x, y))
|
|
90
|
+
|
|
91
|
+
benchmark(lambda: _block_until_ready(interpnd(xq, x, y)))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pytest.mark.skipif(cp is None, reason="CuPy is not available")
|
|
95
|
+
@pytest.mark.parametrize("ndim", [2, 3, 4], ids=["2d", "3d", "4d"])
|
|
96
|
+
def test_interpnd_cupy(benchmark, ndim):
|
|
97
|
+
xq, x, y = _make_case(cp, ndim)
|
|
98
|
+
|
|
99
|
+
# warmup
|
|
100
|
+
_block_until_ready(interpnd(xq, x, y))
|
|
101
|
+
|
|
102
|
+
benchmark(lambda: _block_until_ready(interpnd(xq, x, y)))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@pytest.mark.skipif(torch is None, reason="PyTorch is not available")
|
|
106
|
+
@pytest.mark.parametrize("ndim", [2, 3], ids=["2d", "3d"])
|
|
107
|
+
def test_interpnd_torch_cpu(benchmark, ndim):
|
|
108
|
+
xq, x, y = _make_case(torch, ndim)
|
|
109
|
+
|
|
110
|
+
benchmark(lambda: _block_until_ready(interpnd(xq, x, y)))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@pytest.mark.skipif(
|
|
114
|
+
torch is None or not torch.cuda.is_available(),
|
|
115
|
+
reason="PyTorch CUDA is not available",
|
|
116
|
+
)
|
|
117
|
+
@pytest.mark.parametrize("ndim", [2, 3], ids=["2d", "3d"])
|
|
118
|
+
def test_interpnd_torch_cuda(benchmark, ndim):
|
|
119
|
+
xq_np, x_np, y_np = _make_case(np, ndim)
|
|
120
|
+
|
|
121
|
+
x = tuple(torch.asarray(axis, dtype=torch.float64, device="cuda") for axis in x_np)
|
|
122
|
+
y = torch.asarray(y_np, dtype=torch.float64, device="cuda")
|
|
123
|
+
xq = torch.asarray(xq_np, dtype=torch.float64, device="cuda")
|
|
124
|
+
|
|
125
|
+
# warmup
|
|
126
|
+
_block_until_ready(interpnd(xq, x, y))
|
|
127
|
+
|
|
128
|
+
benchmark(lambda: _block_until_ready(interpnd(xq, x, y)))
|
|
@@ -22,7 +22,7 @@ from pyRadPlan import (
|
|
|
22
22
|
generate_stf,
|
|
23
23
|
calc_dose_influence,
|
|
24
24
|
fluence_optimization,
|
|
25
|
-
|
|
25
|
+
plot_multiple_slices,
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
logging.basicConfig(level=logging.INFO)
|
|
@@ -37,7 +37,8 @@ ct, cst = load_tg119()
|
|
|
37
37
|
# Create a plan object
|
|
38
38
|
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
39
39
|
pln.prop_stf = {"bixel_width": 4}
|
|
40
|
-
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
40
|
+
pln.prop_dose_calc = {"calc_bio_dose": True, "dose_grid": {"resolution": {"x": 3, "y": 3, "z": 3}}}
|
|
41
|
+
|
|
41
42
|
pln.prop_opt = {"solver": "scipy"}
|
|
42
43
|
|
|
43
44
|
# Generate Steering Geometry ("stf")
|
|
@@ -46,6 +47,7 @@ stf = generate_stf(ct, cst, pln)
|
|
|
46
47
|
# Calculate Dose Influence Matrix ("dij")
|
|
47
48
|
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
48
49
|
|
|
50
|
+
# %%
|
|
49
51
|
# Optimize
|
|
50
52
|
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
51
53
|
|
|
@@ -57,9 +59,9 @@ result = dij.compute_result_ct_grid(fluence)
|
|
|
57
59
|
view_slice = [int(np.round(ct.size[2] / 2))]
|
|
58
60
|
|
|
59
61
|
# Visualize the results
|
|
60
|
-
# Use
|
|
62
|
+
# Use plot_multiple_slices to visualize the biological effect and physical dose
|
|
61
63
|
# use plot_slice() for single distributions
|
|
62
|
-
|
|
64
|
+
plot_multiple_slices(
|
|
63
65
|
image_volume=ct,
|
|
64
66
|
cst=cst,
|
|
65
67
|
overlays=[result["effect"], result["physical_dose"]],
|
|
@@ -21,11 +21,10 @@ from pyRadPlan import (
|
|
|
21
21
|
generate_stf,
|
|
22
22
|
calc_dose_influence,
|
|
23
23
|
fluence_optimization,
|
|
24
|
-
plot_slice,
|
|
25
24
|
load_tg119,
|
|
26
25
|
xp_utils,
|
|
27
26
|
)
|
|
28
|
-
|
|
27
|
+
from pyRadPlan.gui import launch_viewer
|
|
29
28
|
from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
|
|
30
29
|
|
|
31
30
|
|
|
@@ -72,11 +71,4 @@ result = dij.compute_result_ct_grid(fluence)
|
|
|
72
71
|
view_slice = int(np.round(ct.size[2] / 2))
|
|
73
72
|
|
|
74
73
|
# Visualize
|
|
75
|
-
|
|
76
|
-
image_volume=ct,
|
|
77
|
-
cst=cst,
|
|
78
|
-
overlay=result["physical_dose"],
|
|
79
|
-
view_slice=view_slice,
|
|
80
|
-
plane="axial",
|
|
81
|
-
overlay_unit="Gy",
|
|
82
|
-
)
|
|
74
|
+
launch_viewer(ct, cst, result)
|
|
@@ -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,58 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""Demonstrates the use of pyRadPlan 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 with TOPAS.
|
|
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
|
+
# Import necessary libraries
|
|
14
|
+
import logging
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from pyRadPlan import (
|
|
18
|
+
IonPlan,
|
|
19
|
+
generate_stf,
|
|
20
|
+
calc_dose_influence,
|
|
21
|
+
calc_dose_forward,
|
|
22
|
+
load_tg119,
|
|
23
|
+
fluence_optimization,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
logging.basicConfig(level=logging.INFO)
|
|
28
|
+
|
|
29
|
+
# %%
|
|
30
|
+
# Load TG119 (provided within pyRadPlan)
|
|
31
|
+
ct, cst = load_tg119()
|
|
32
|
+
# %% [markdown]
|
|
33
|
+
# In this section, we create a proton therapy plan using the ParticleHongPencilBeamEngine.
|
|
34
|
+
# %%
|
|
35
|
+
# Create a plan object
|
|
36
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic")
|
|
37
|
+
pln.prop_stf = {
|
|
38
|
+
"gantry_angles": [90, 180],
|
|
39
|
+
"couch_angles": [0, 0],
|
|
40
|
+
}
|
|
41
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
42
|
+
|
|
43
|
+
# Generate Steering Geometry ("stf")
|
|
44
|
+
stf = generate_stf(ct, cst, pln)
|
|
45
|
+
|
|
46
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
47
|
+
|
|
48
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
49
|
+
|
|
50
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
51
|
+
# %% [markdown]
|
|
52
|
+
# TOPAS recalc
|
|
53
|
+
pln.prop_dose_calc = {
|
|
54
|
+
"engine": "TOPAS", # necessary for the following to take effect
|
|
55
|
+
"num_histories_direct": 1e7,
|
|
56
|
+
"external_calculation": True, # "E:\Code\pyRadPlan\pyRadPlan\data\TOPAS\2026-02-18",
|
|
57
|
+
}
|
|
58
|
+
result_mc = calc_dose_forward(ct, cst, stf, pln, fluence)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""
|
|
3
|
+
# AI Agents for Radiotherapy Planning.
|
|
4
|
+
|
|
5
|
+
This example demonstrates the usage of pydantic-ai based `ai_agents` in `pyRadPlan`
|
|
6
|
+
to assist in treatment planning. The module uses a user-defined LLM to suggest
|
|
7
|
+
beam angles and optimization objectives based on the treatment site.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
1. `pydantic-ai` and `pydantic-settings` installed.
|
|
12
|
+
2. An API key for your chosen AI provider set as an environment variable:
|
|
13
|
+
- OpenAI: `OPENAI_API_KEY`
|
|
14
|
+
- Anthropic: `ANTHROPIC_API_KEY`
|
|
15
|
+
- Google: `GOOGLE_API_KEY`
|
|
16
|
+
- Mistral: `MISTRAL_API_KEY`
|
|
17
|
+
If a .env file is present, the environment will be populated with python-dotenv
|
|
18
|
+
3. Optionally, set the model via `PYRADPLAN_AI_MODEL` (default: `claude-sonnet-4-5`).
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# %% tags=["active-ipynb"]
|
|
24
|
+
import logging
|
|
25
|
+
from dotenv import load_dotenv
|
|
26
|
+
from pyRadPlan import (
|
|
27
|
+
IonPlan,
|
|
28
|
+
load_tg119,
|
|
29
|
+
ai_agents,
|
|
30
|
+
generate_stf,
|
|
31
|
+
calc_dose_influence,
|
|
32
|
+
fluence_optimization,
|
|
33
|
+
plot_slice,
|
|
34
|
+
DVHCollection,
|
|
35
|
+
)
|
|
36
|
+
## These two lines are needed to allow nested event loops in Jupyter.
|
|
37
|
+
## Otherwise you will experience sync-errors when running the AI agents.
|
|
38
|
+
## Install it using `pip install nest_asyncio`.
|
|
39
|
+
# import nest_asyncio
|
|
40
|
+
# nest_asyncio.apply()
|
|
41
|
+
|
|
42
|
+
# %%
|
|
43
|
+
# Load environment variables from .env file
|
|
44
|
+
load_dotenv()
|
|
45
|
+
|
|
46
|
+
# Configure logging
|
|
47
|
+
logging.basicConfig(level=logging.INFO)
|
|
48
|
+
|
|
49
|
+
# %% [markdown]
|
|
50
|
+
"""
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
Set the model via the environment variable `PYRADPLAN_AI_MODEL`, or pass `model=`
|
|
54
|
+
explicitly to each call. Your provider API key must be set in the environment
|
|
55
|
+
(e.g. `OPENAI_API_KEY`). pydantic-ai picks it up automatically.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
# %%
|
|
59
|
+
# Set the model to use (can also be set via PYRADPLAN_AI_MODEL env var)
|
|
60
|
+
# os.environ["PYRADPLAN_AI_MODEL"] = "openai:gpt-5-mini"
|
|
61
|
+
|
|
62
|
+
# Inspect effective settings
|
|
63
|
+
settings = ai_agents.AiSettings()
|
|
64
|
+
print(f"Using model: {settings.model}")
|
|
65
|
+
|
|
66
|
+
# %% [markdown]
|
|
67
|
+
"""
|
|
68
|
+
## Load Data
|
|
69
|
+
|
|
70
|
+
We will use the TG119 phantom provided with `pyRadPlan`.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
# %%
|
|
74
|
+
ct, cst = load_tg119()
|
|
75
|
+
print("Loaded TG119 phantom.")
|
|
76
|
+
print("VOIs:", [v.name for v in cst.vois])
|
|
77
|
+
|
|
78
|
+
# %% [markdown]
|
|
79
|
+
"""
|
|
80
|
+
## Generate Beam Angles
|
|
81
|
+
|
|
82
|
+
We create a generic proton plan and ask the AI agent to suggest beam angles
|
|
83
|
+
for a prostate case.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
# %%
|
|
87
|
+
pln = IonPlan(radiation_mode="protons", machine="Generic", num_of_fractions=30, prescribed_dose=60)
|
|
88
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
89
|
+
pln.prop_dose_calc = {"dose_grid": ct.grid}
|
|
90
|
+
|
|
91
|
+
print("Generating beam angles for prostate...")
|
|
92
|
+
pln = ai_agents.generate_beam_angles(pln, treatment_site="prostate")
|
|
93
|
+
|
|
94
|
+
print(f"Suggested Gantry Angles: {pln.prop_stf['gantry_angles']}")
|
|
95
|
+
|
|
96
|
+
# %% [markdown]
|
|
97
|
+
"""
|
|
98
|
+
## Generate Optimization Objectives
|
|
99
|
+
|
|
100
|
+
Ask the AI agent to suggest optimization objectives for the VOIs.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
# %%
|
|
104
|
+
print("Generating VOI objectives...")
|
|
105
|
+
cst = ai_agents.generate_voi_objectives(pln, cst, treatment_site="prostate")
|
|
106
|
+
|
|
107
|
+
for voi in cst.vois:
|
|
108
|
+
if voi.objectives:
|
|
109
|
+
print(f"\nVOI: {voi.name}")
|
|
110
|
+
for obj in voi.objectives:
|
|
111
|
+
print(obj)
|
|
112
|
+
|
|
113
|
+
# %% [markdown]
|
|
114
|
+
"""
|
|
115
|
+
## Run plan with AI-generated settings.
|
|
116
|
+
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
# %%
|
|
120
|
+
stf = generate_stf(ct, cst, pln)
|
|
121
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
122
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
123
|
+
|
|
124
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
125
|
+
dvhs = DVHCollection.from_structure_set(cst, result["physical_dose"])
|
|
126
|
+
|
|
127
|
+
# %%
|
|
128
|
+
# TODO: agentic adaptation loop with information from DVH Collection
|
|
129
|
+
|
|
130
|
+
# %% [markdown]
|
|
131
|
+
"""
|
|
132
|
+
## Visualize Result
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
# %%
|
|
136
|
+
plot_slice(ct=ct, cst=cst, overlay=result["physical_dose"])
|