pyRadPlan 0.3.3__tar.gz → 0.3.4__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.3 → pyradplan-0.3.4}/PKG-INFO +3 -3
- {pyradplan-0.3.3 → pyradplan-0.3.4}/README.md +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/intro_minimal_photons.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/intro_minimal_protons.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/mc_fred.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_carbon.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_helium.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_photon.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_photon_forward.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_proton.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_proton_let.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/pencilbeam_vhee.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/proton_mimicking.py +3 -3
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/raytracer_rad_depth.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/utils_plotting.py +13 -9
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/analysis/_dvh.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/resample.py +19 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/xp_utils/helpers.py +52 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/cst/_cst.py +1 -1
- pyradplan-0.3.4/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dij/_dij.py +69 -14
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_base.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_base_pencilbeam.py +79 -37
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +8 -5
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_fredmc.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_hongpb.py +4 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_svdpb.py +22 -5
- pyradplan-0.3.4/pyRadPlan/dose/engines/kernels/_calc_geo_dists_kernel.py +232 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/_base.py +1 -3
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/_beam_modifier.py +3 -3
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/_external_beam.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_base.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_ions.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/photons/_linac.py +18 -5
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_mean.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/problems/_nonlin_fluence.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/problems/_optiprob.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/solvers/_base_solvers.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/raytracer/_base.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/scenarios/_base.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_beamlet.py +2 -2
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_steeringinformation.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/visualization/_plot_multiple_slices.py +26 -9
- pyradplan-0.3.4/pyRadPlan/visualization/_plot_slice.py +393 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan.egg-info/PKG-INFO +3 -3
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan.egg-info/SOURCES.txt +2 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyproject.toml +8 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/cst/test_VOI.py +1 -1
- pyradplan-0.3.4/test/dose/test_base_pencilbeam.py +97 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_fred.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_hongpb.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_svdpb.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/machines/test_beam_modifiers.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_dij.py +61 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_machine_model.py +4 -4
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_scenarios.py +1 -1
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/visualization/test_plot_multiple_slices.py +20 -19
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/visualization/test_plot_slice.py +57 -10
- pyradplan-0.3.3/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- pyradplan-0.3.3/pyRadPlan/visualization/_plot_slice.py +0 -214
- {pyradplan-0.3.3 → pyradplan-0.3.4}/LICENSE +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/benchmark/bench_trace_cubes.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/docs/conf.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/examples/utils_matrad.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/analysis/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/_exceptions.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/_grids.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/datamodel.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/np2sitk.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/xp_utils/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/xp_utils/compat.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/core/xp_utils/typing.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/cst/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/cst/_voi.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/ct/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/ct/_ct.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/ct/_hlut.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dij/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/_calc_dose.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_base_montecarlo.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/dose/engines/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/geometry/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/geometry/lps.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/io/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/io/_matlab_file_handler.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/io/_patient_loader.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/io/matfile.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/_load.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/_validate.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/base/_internal_beam.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_beam_cutoff.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_beam_emittance.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_beam_energy.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_beam_focus.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/_vhee.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/kernel/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/kernel/_base.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/kernel/_ions.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/particles/kernel/_vhee.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/photons/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/photons/_base.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/photons/_calculate_machine_scale.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/machines/photons/_svd_kernel.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/matRad/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/matRad/_engine.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/matRad/_matlab.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/matRad/_octave.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_eud.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_objective.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_squared_mimicking.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/objectives/_std.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/problems/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/problems/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/solvers/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/solvers/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/solvers/_ipopt.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/plan/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/plan/_plans.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/quantities/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/quantities/_base.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/quantities/_dose.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/quantities/_let_x_dose.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/raytracer/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/raytracer/_numba_perf.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/raytracer/_siddon.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/scenarios/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/scenarios/_nominal.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_beam.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_exceptions.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_generate_stf.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_rangeshifter.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/_ray.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_base.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_ions.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_photons.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/stf/generators/_vhee.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/util/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/util/helpers.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/util/keyboard_listener.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan/visualization/__init__.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan.egg-info/dependency_links.txt +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan.egg-info/requires.txt +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/pyRadPlan.egg-info/top_level.txt +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/setup.cfg +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/analysis/test_dvh.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/analysis/test_qi.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/compute/test_math_interp1d.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/compute/test_math_quantile.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/compute/test_namespace_conversion.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/conftest.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/core/test_coordinates.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/core/test_datamodel.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/core/test_np2sitk.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/core/test_resample.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/cst/conftest.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/cst/test_cst.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/ct/test_ct.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/ct/test_hlut.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/data/test_validate_test_data.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/conftest.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_dose_engine_base.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/dose/test_pb_geodist.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/geometry/test_lps.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_fluence_optiprob.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_ipopt_solver.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_objectives.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_problem_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_scipy_solver.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/optimization/test_solver_factory.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/quantities/test_dose_quantity.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/quantities/test_let_dose_quantity.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/stf/test_beamlet.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/stf/test_stf.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/stf/test_stf_gen.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_fileHandling.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_grid.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_helpers.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_matlabEngine.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_octaveEngine.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_plan.py +0 -0
- {pyradplan-0.3.3 → pyradplan-0.3.4}/test/test_raytracersiddon.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyRadPlan
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A python interface and reimplementation to matRad
|
|
5
|
-
Author-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Lina Bucher <lina.bucher@dkfz-heidelberg.de>, 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>
|
|
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>
|
|
7
7
|
Project-URL: Homepage, https://git.dkfz.de
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -70,7 +70,7 @@ pyRadPlan is a multi-modality treatment planning toolkit in python born from the
|
|
|
70
70
|
One of pyRadPlan's main goals is for its algorithms to be [Python Array API](https://data-apis.org/array-api/) conform as much as possible, to allow free choice of compute backends and devices (i.e., [`numpy`](https://numpy.org/), [`cupy`](https://cupy.dev/), [`pytorch`](https://pytorch.org/)). Further, its data structures (more precisely, their metadata) should be easily serializable for exchange with novel LLMs. This facilitate performant treatment planning research while enabling the integration of AI - such as deep neural networks implemented in [`pytorch`](https://pytorch.org/) or interaction with an LLM Agent via [`pydantic-ai`](https://ai.pydantic.dev/) - at every step of the treatment planning workflow.
|
|
71
71
|
|
|
72
72
|
### Data Structures
|
|
73
|
-
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
|
|
73
|
+
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 algorithms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
74
74
|
|
|
75
75
|
To enforce valid datastructures, we perform validation and serialization with [`pydantic`](https://docs.pydantic.dev/latest/).
|
|
76
76
|
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.
|
|
@@ -19,7 +19,7 @@ pyRadPlan is a multi-modality treatment planning toolkit in python born from the
|
|
|
19
19
|
One of pyRadPlan's main goals is for its algorithms to be [Python Array API](https://data-apis.org/array-api/) conform as much as possible, to allow free choice of compute backends and devices (i.e., [`numpy`](https://numpy.org/), [`cupy`](https://cupy.dev/), [`pytorch`](https://pytorch.org/)). Further, its data structures (more precisely, their metadata) should be easily serializable for exchange with novel LLMs. This facilitate performant treatment planning research while enabling the integration of AI - such as deep neural networks implemented in [`pytorch`](https://pytorch.org/) or interaction with an LLM Agent via [`pydantic-ai`](https://ai.pydantic.dev/) - at every step of the treatment planning workflow.
|
|
20
20
|
|
|
21
21
|
### Data Structures
|
|
22
|
-
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
|
|
22
|
+
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 algorithms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
23
23
|
|
|
24
24
|
To enforce valid datastructures, we perform validation and serialization with [`pydantic`](https://docs.pydantic.dev/latest/).
|
|
25
25
|
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.
|
|
@@ -60,7 +60,7 @@ view_slice = [int(np.round(ct.size[2] / 2))]
|
|
|
60
60
|
# Use plot_distributions to visualize the biological effect and physical dose
|
|
61
61
|
# use plot_slice() for single distributions
|
|
62
62
|
plot_distributions(
|
|
63
|
-
|
|
63
|
+
image_volume=ct,
|
|
64
64
|
cst=cst,
|
|
65
65
|
overlays=[result["effect"], result["physical_dose"]],
|
|
66
66
|
view_slice=view_slice,
|
|
@@ -76,13 +76,13 @@ view_slice = int(np.round(ct.size[2] / 2))
|
|
|
76
76
|
|
|
77
77
|
# Visualize
|
|
78
78
|
plot_slice(
|
|
79
|
-
|
|
79
|
+
image_volume=ct,
|
|
80
80
|
cst=cst,
|
|
81
81
|
overlay=result["physical_dose"],
|
|
82
82
|
view_slice=view_slice,
|
|
83
83
|
)
|
|
84
84
|
plot_slice(
|
|
85
|
-
|
|
85
|
+
image_volume=ct,
|
|
86
86
|
cst=cst,
|
|
87
87
|
overlay=result["let"],
|
|
88
88
|
view_slice=view_slice,
|
|
@@ -74,11 +74,11 @@ fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
|
74
74
|
result = dij.compute_result_ct_grid(fluence)
|
|
75
75
|
|
|
76
76
|
# %%
|
|
77
|
-
# Now let's
|
|
77
|
+
# Now let's mimic a reference dose distribution from the reference plan with noise
|
|
78
78
|
noise_stdev = 0.02
|
|
79
79
|
reference_dose = sitk.SpeckleNoise(result["physical_dose"], noise_stdev)
|
|
80
80
|
|
|
81
|
-
# Let's
|
|
81
|
+
# Let's mimic the noisy dose distribution by using the SquaredMimicking objective.
|
|
82
82
|
cst.vois[1].objectives = [] # Target
|
|
83
83
|
cst.vois[0].objectives = [] # OAR
|
|
84
84
|
cst.vois[2].objectives = [SquaredMimicking(priority=1000.0, d_ref=reference_dose)] # BODY
|
|
@@ -97,7 +97,7 @@ view_slice = int(np.round(ct.size[2] / 2))
|
|
|
97
97
|
|
|
98
98
|
# Visualize
|
|
99
99
|
plot_slice(
|
|
100
|
-
|
|
100
|
+
image_volume=ct,
|
|
101
101
|
cst=cst,
|
|
102
102
|
overlay=result_mimicked["physical_dose"],
|
|
103
103
|
view_slice=view_slice,
|
|
@@ -54,11 +54,11 @@ result = dij.compute_result_ct_grid(fluence)
|
|
|
54
54
|
# ### Visualizing a single slice with `plot_slice()`
|
|
55
55
|
# %%
|
|
56
56
|
|
|
57
|
-
# Visualize only ct and
|
|
58
|
-
plot_slice(
|
|
57
|
+
# Visualize only ct and chosen quantity
|
|
58
|
+
plot_slice(image_volume=ct, overlay=result["physical_dose"])
|
|
59
59
|
|
|
60
|
-
# Visualize ct, cst and
|
|
61
|
-
plot_slice(
|
|
60
|
+
# Visualize ct, cst and chosen quantity
|
|
61
|
+
plot_slice(image_volume=ct, cst=cst, overlay=result["physical_dose"])
|
|
62
62
|
|
|
63
63
|
# %% [markdown]
|
|
64
64
|
# ## Visualze more abstract settings using `plot_slice()` <br>
|
|
@@ -79,7 +79,7 @@ plot_slice(ct=ct, cst=cst, overlay=result["physical_dose"])
|
|
|
79
79
|
# %%
|
|
80
80
|
# Feel free to change the parameters to see how they affect the plot.
|
|
81
81
|
plot_slice(
|
|
82
|
-
|
|
82
|
+
image_volume=ct,
|
|
83
83
|
cst=cst,
|
|
84
84
|
overlay=result["physical_dose"],
|
|
85
85
|
view_slice=64, # Visualize slice 10
|
|
@@ -94,7 +94,7 @@ plot_slice(
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
# %% [markdown]
|
|
97
|
-
# ### Visualizing multiple overlays/
|
|
97
|
+
# ### Visualizing multiple overlays/quantities with `plot_distributions()`
|
|
98
98
|
# This function might be useful in cases you want to compare multiple overlays/quantities/beams side by side.
|
|
99
99
|
|
|
100
100
|
# `plot_distributions()` has similar parameters to `plot_slice()`:
|
|
@@ -112,9 +112,13 @@ plot_slice(
|
|
|
112
112
|
# - **use_global_max**: If True, uses the global maximum of the overlay for scaling
|
|
113
113
|
# - **overlay_titles**: Custom titles for each overlay type (optional)
|
|
114
114
|
# %%
|
|
115
|
+
plot_multiple_slices(
|
|
116
|
+
image_volume=ct,
|
|
117
|
+
)
|
|
118
|
+
# %%
|
|
115
119
|
# Feel free to change the parameters to see how they affect the plot.
|
|
116
120
|
plot_multiple_slices(
|
|
117
|
-
|
|
121
|
+
image_volume=ct,
|
|
118
122
|
cst=cst,
|
|
119
123
|
overlays=[result["physical_dose"], result["effect"]],
|
|
120
124
|
view_slice=[64, 65], # Visualize slices 64 and 65
|
|
@@ -140,7 +144,7 @@ fig, axes = plt.subplots(2, 2, figsize=(12, 10))
|
|
|
140
144
|
# Plot physical dose for both slices
|
|
141
145
|
for i, slice_idx in enumerate(slices):
|
|
142
146
|
plot_slice(
|
|
143
|
-
|
|
147
|
+
image_volume=ct,
|
|
144
148
|
cst=cst,
|
|
145
149
|
overlay=result["physical_dose"],
|
|
146
150
|
view_slice=slice_idx, # Single slice
|
|
@@ -154,7 +158,7 @@ for i, slice_idx in enumerate(slices):
|
|
|
154
158
|
# Plot biological effect for both slices
|
|
155
159
|
for i, slice_idx in enumerate(slices):
|
|
156
160
|
plot_slice(
|
|
157
|
-
|
|
161
|
+
image_volume=ct,
|
|
158
162
|
cst=cst,
|
|
159
163
|
overlay=result["effect"],
|
|
160
164
|
view_slice=slice_idx, # Single slice
|
|
@@ -134,7 +134,7 @@ class DVH(PyRadPlanBaseModel):
|
|
|
134
134
|
Notes
|
|
135
135
|
-----
|
|
136
136
|
The x ccoordinate (dose/quantity) corresponds to the histograms
|
|
137
|
-
bin center for the
|
|
137
|
+
bin center for the differential DVH. This is because the differential
|
|
138
138
|
DVH captures the relative volume within a bin, thus the center
|
|
139
139
|
represents the dose/quantity value for that bin best.
|
|
140
140
|
Be aware of this difference to the cumulative DVH.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Image / Grid Resampling."""
|
|
2
2
|
|
|
3
|
+
from typing import Literal, Union
|
|
4
|
+
|
|
3
5
|
import numpy as np
|
|
4
6
|
import SimpleITK as sitk
|
|
5
7
|
from ._grids import Grid
|
|
@@ -11,6 +13,7 @@ def resample_image(
|
|
|
11
13
|
target_image: sitk.Image = None,
|
|
12
14
|
target_grid_spacing: tuple[float, float, float] = None,
|
|
13
15
|
target_grid: Grid = None,
|
|
16
|
+
extrapolate: Union[float, int, bool, Literal["nearest"]] = "nearest",
|
|
14
17
|
) -> sitk.Image: # also accept sitk images and grid points. Can be dealt with with kwargs
|
|
15
18
|
"""
|
|
16
19
|
Resample an sitk Image.
|
|
@@ -23,6 +26,8 @@ def resample_image(
|
|
|
23
26
|
The input image to be resampled.
|
|
24
27
|
interpolator : sitk.InterpolatorEnum, optional
|
|
25
28
|
The interpolator to use for resampling. Default is sitk.sitkBSpline.
|
|
29
|
+
extrapolate : Union[float, int, bool, Literal["nearest"], None], optional
|
|
30
|
+
The value to use for extrapolation outside the image boundaries. Default is None.
|
|
26
31
|
target_image : sitk.Image, optional
|
|
27
32
|
The reference image to resample to. Default is None.
|
|
28
33
|
target_grid_spacing : tuple[float,float,float], optional
|
|
@@ -53,6 +58,18 @@ def resample_image(
|
|
|
53
58
|
target_grid = image_grid.resample(target_grid_spacing)
|
|
54
59
|
|
|
55
60
|
resample = sitk.ResampleImageFilter()
|
|
61
|
+
resample.UseNearestNeighborExtrapolatorOff()
|
|
62
|
+
if extrapolate == "nearest":
|
|
63
|
+
resample.UseNearestNeighborExtrapolatorOn()
|
|
64
|
+
elif isinstance(extrapolate, (int, float)):
|
|
65
|
+
resample.SetDefaultPixelValue(extrapolate)
|
|
66
|
+
elif extrapolate is False:
|
|
67
|
+
resample.SetDefaultPixelValue(0)
|
|
68
|
+
elif extrapolate is True:
|
|
69
|
+
resample.SetDefaultPixelValue(1)
|
|
70
|
+
else:
|
|
71
|
+
raise ValueError("Invalid value for 'extrapolate' parameter.")
|
|
72
|
+
|
|
56
73
|
resample.SetOutputSpacing(target_grid.resolution_vector)
|
|
57
74
|
resample.SetSize(target_grid.dimensions)
|
|
58
75
|
resample.SetOutputDirection(target_grid.direction.ravel())
|
|
@@ -71,6 +88,7 @@ def resample_numpy_array(
|
|
|
71
88
|
target_image: sitk.Image = None,
|
|
72
89
|
target_grid_spacing: tuple[float, float, float] = None,
|
|
73
90
|
target_grid: Grid = None,
|
|
91
|
+
extrapolate: Union[float, int, bool, Literal["nearest"]] = "nearest",
|
|
74
92
|
) -> np.ndarray:
|
|
75
93
|
"""
|
|
76
94
|
Resample a numpy grid.
|
|
@@ -130,6 +148,7 @@ def resample_numpy_array(
|
|
|
130
148
|
target_image=target_image,
|
|
131
149
|
target_grid_spacing=target_grid_spacing,
|
|
132
150
|
target_grid=target_grid,
|
|
151
|
+
extrapolate=extrapolate,
|
|
133
152
|
)
|
|
134
153
|
|
|
135
154
|
return sitk.GetArrayFromImage(resampled_array_sitk)
|
|
@@ -277,7 +277,7 @@ def _convert_scipy_sparse_for_namespace(
|
|
|
277
277
|
|
|
278
278
|
if array_api_compat.is_cupy_namespace(xp_new) and cp is not None:
|
|
279
279
|
try:
|
|
280
|
-
# Access the copy
|
|
280
|
+
# Access the copy constructor from the fmt string
|
|
281
281
|
f_create = getattr(csp, fmt + "_matrix")
|
|
282
282
|
except AttributeError:
|
|
283
283
|
sparray = sparray.tocoo()
|
|
@@ -383,3 +383,54 @@ def is_sparse_array(arr: Any) -> bool:
|
|
|
383
383
|
return True
|
|
384
384
|
|
|
385
385
|
raise TypeError("Sparse check helper not implemented for type '{}'.".format(type(arr)))
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def _rebuild_scipy_csc_in_namespace(
|
|
389
|
+
xp_new: ArrayNamespace,
|
|
390
|
+
data: Array,
|
|
391
|
+
indices: Array,
|
|
392
|
+
indptr: Array,
|
|
393
|
+
shape: tuple,
|
|
394
|
+
) -> Union[scp.spmatrix, scp.sparray]:
|
|
395
|
+
"""Reconstruct a CSC sparse matrix in *xp_new* from pre-converted component arrays.
|
|
396
|
+
|
|
397
|
+
This is a low-level helper used by :meth:`Dij.to_namespace` to avoid uploading
|
|
398
|
+
shared row-index arrays more than once when multiple dose quantities share the
|
|
399
|
+
same CSC index storage (as assembled by the pencil-beam engine).
|
|
400
|
+
|
|
401
|
+
Parameters
|
|
402
|
+
----------
|
|
403
|
+
xp_new :
|
|
404
|
+
Target array namespace (numpy, cupy, torch, …).
|
|
405
|
+
data :
|
|
406
|
+
Non-zero values already in *xp_new*.
|
|
407
|
+
indices :
|
|
408
|
+
CSC row-index array already in *xp_new*.
|
|
409
|
+
indptr :
|
|
410
|
+
CSC column-pointer array already in *xp_new*.
|
|
411
|
+
shape :
|
|
412
|
+
Matrix shape ``(nrows, ncols)``.
|
|
413
|
+
|
|
414
|
+
Returns
|
|
415
|
+
-------
|
|
416
|
+
Sparse matrix compatible with *xp_new*.
|
|
417
|
+
|
|
418
|
+
Raises
|
|
419
|
+
------
|
|
420
|
+
TypeError
|
|
421
|
+
If rebuilding is not yet supported for *xp_new*.
|
|
422
|
+
"""
|
|
423
|
+
if array_api_compat.is_numpy_namespace(
|
|
424
|
+
xp_new
|
|
425
|
+
) or array_api_compat.is_array_api_strict_namespace(xp_new):
|
|
426
|
+
return scp.csc_array((data, indices, indptr), shape=shape, copy=False)
|
|
427
|
+
|
|
428
|
+
if array_api_compat.is_cupy_namespace(xp_new) and cp is not None:
|
|
429
|
+
return csp.csc_matrix((data, indices, indptr), shape=shape)
|
|
430
|
+
|
|
431
|
+
if array_api_compat.is_torch_namespace(xp_new) and torch is not None:
|
|
432
|
+
return torch.sparse_csc_tensor(indptr, indices, data, size=shape)
|
|
433
|
+
|
|
434
|
+
raise TypeError(
|
|
435
|
+
f"Rebuilding a CSC sparse matrix in namespace '{xp_new.__name__}' is not yet supported."
|
|
436
|
+
)
|
|
@@ -292,7 +292,7 @@ class StructureSet(PyRadPlanBaseModel):
|
|
|
292
292
|
curr_voi = self.vois[ix_voi].model_copy()
|
|
293
293
|
curr_mask = curr_voi.mask
|
|
294
294
|
|
|
295
|
-
# if the overlap
|
|
295
|
+
# if the overlap priority is higher than we need to apply overlap
|
|
296
296
|
if curr_voi.overlap_priority >= new_vois[ix_sorted[i - 1]].overlap_priority:
|
|
297
297
|
if curr_voi.overlap_priority > new_vois[ix_sorted[i - 1]].overlap_priority:
|
|
298
298
|
last_priority_mask = overlap_mask
|
|
Binary file
|
|
@@ -29,6 +29,7 @@ from pyRadPlan.core import PyRadPlanBaseModel
|
|
|
29
29
|
from pyRadPlan.util import swap_orientation_sparse_matrix
|
|
30
30
|
|
|
31
31
|
from ..core.xp_utils import to_namespace
|
|
32
|
+
from ..core.xp_utils.helpers import _rebuild_scipy_csc_in_namespace
|
|
32
33
|
|
|
33
34
|
InfluenceMatrixArray = Union[Array, sp.spmatrix, sp.sparray]
|
|
34
35
|
InfluenceMatrixContainer = NDArray[Shape["*, ..."], object]
|
|
@@ -256,7 +257,7 @@ class Dij(PyRadPlanBaseModel):
|
|
|
256
257
|
)
|
|
257
258
|
if value.flat[i] is not None and not isinstance(value.flat[i], sp.csc_matrix):
|
|
258
259
|
value.flat[i] = sp.csc_matrix(value.flat[i])
|
|
259
|
-
# return 0 if value is None. savemat()
|
|
260
|
+
# return 0 if value is None. savemat() can't handle 'None'
|
|
260
261
|
elif context and context.get("matRad") == "mat-file" and value is None:
|
|
261
262
|
value = np.array([0])
|
|
262
263
|
return value
|
|
@@ -267,7 +268,7 @@ class Dij(PyRadPlanBaseModel):
|
|
|
267
268
|
if context and context.get("matRad") == "mat-file" and value is not None:
|
|
268
269
|
# TODO: it might be necessary to rotate the cube!
|
|
269
270
|
return value
|
|
270
|
-
# return 0 if value is None. savemat()
|
|
271
|
+
# return 0 if value is None. savemat() can't handle 'None'
|
|
271
272
|
elif context and context.get("matRad") == "mat-file" and value is None:
|
|
272
273
|
value = np.array([0])
|
|
273
274
|
return value
|
|
@@ -319,7 +320,7 @@ class Dij(PyRadPlanBaseModel):
|
|
|
319
320
|
out["physical_dose"] = self.physical_dose.flat[scenario_index] @ intensity
|
|
320
321
|
out["physical_dose_beam"] = []
|
|
321
322
|
|
|
322
|
-
# !Note: This
|
|
323
|
+
# !Note: This implementation is faster than the intuitive:
|
|
323
324
|
# out_example = self.physical_dose.flat[scenario_index]@(intensity*beam_mask)
|
|
324
325
|
# Since slicing over the intensity vector reduces the matrix operation size.
|
|
325
326
|
for i in range(self.num_of_beams):
|
|
@@ -471,23 +472,77 @@ class Dij(PyRadPlanBaseModel):
|
|
|
471
472
|
Default is True.
|
|
472
473
|
"""
|
|
473
474
|
|
|
474
|
-
#
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
# record memory addresses here, before model_copy would break the sharing.
|
|
476
|
+
_shared_idx_cache: dict[int, tuple | None] = {}
|
|
477
|
+
if keep_sparse_compat:
|
|
478
|
+
for q in self.quantities:
|
|
479
|
+
q_container = getattr(self, q)
|
|
480
|
+
if q_container is None:
|
|
481
|
+
continue
|
|
482
|
+
for i in range(q_container.size):
|
|
483
|
+
mat = q_container.flat[i]
|
|
484
|
+
if mat is not None and isinstance(mat, (sp.csc_matrix, sp.csc_array)):
|
|
485
|
+
_shared_idx_cache.setdefault(mat.indices.ctypes.data, None)
|
|
486
|
+
|
|
487
|
+
n_unique = len(_shared_idx_cache)
|
|
488
|
+
n_total = sum(
|
|
489
|
+
sum(
|
|
490
|
+
1
|
|
491
|
+
for idx in range(getattr(self, q).size)
|
|
492
|
+
if getattr(self, q).flat[idx] is not None
|
|
493
|
+
and isinstance(getattr(self, q).flat[idx], (sp.csc_matrix, sp.csc_array))
|
|
494
|
+
)
|
|
495
|
+
for q in self.quantities
|
|
496
|
+
if getattr(self, q) is not None
|
|
497
|
+
)
|
|
498
|
+
if n_total > n_unique:
|
|
499
|
+
ns_name = xp_new if isinstance(xp_new, str) else xp_new.__name__
|
|
500
|
+
logger.debug(
|
|
501
|
+
"to_namespace: %d CSC matrices share %d unique row-index array(s) — "
|
|
502
|
+
"converting index arrays only once to namespace '%s'.",
|
|
503
|
+
n_total,
|
|
504
|
+
n_unique,
|
|
505
|
+
ns_name,
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
# shallow copy and then convert the matrices in-place to avoid unnecessary copying of large arrays.
|
|
509
|
+
dij_copy = self.model_copy(deep=False)
|
|
510
|
+
for _q in self.quantities:
|
|
511
|
+
_src = getattr(self, _q)
|
|
512
|
+
if _src is not None:
|
|
513
|
+
_fresh = np.empty_like(_src) # same shape, dtype=object
|
|
514
|
+
_fresh.flat[:] = None
|
|
515
|
+
object.__setattr__(dij_copy, _q, _fresh)
|
|
477
516
|
|
|
478
517
|
for q in self.quantities:
|
|
479
518
|
q_container: InfluenceMatrixContainer = getattr(self, q)
|
|
480
519
|
if q_container is not None:
|
|
481
520
|
for i in range(q_container.size):
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
521
|
+
mat = q_container.flat[i]
|
|
522
|
+
if mat is None:
|
|
523
|
+
continue
|
|
524
|
+
|
|
525
|
+
# scipy CSC matrices whose index arrays may be shared
|
|
526
|
+
if keep_sparse_compat and isinstance(mat, (sp.csc_matrix, sp.csc_array)):
|
|
527
|
+
addr = mat.indices.ctypes.data
|
|
528
|
+
if addr in _shared_idx_cache:
|
|
529
|
+
if _shared_idx_cache[addr] is None:
|
|
530
|
+
# First encounter for this index array: convert once
|
|
531
|
+
conv_indices = to_namespace(xp_new, mat.indices)
|
|
532
|
+
conv_indptr = to_namespace(xp_new, mat.indptr)
|
|
533
|
+
_shared_idx_cache[addr] = (conv_indices, conv_indptr)
|
|
534
|
+
conv_indices, conv_indptr = _shared_idx_cache[addr]
|
|
535
|
+
conv_data = to_namespace(xp_new, mat.data)
|
|
536
|
+
getattr(dij_copy, q).flat[i] = _rebuild_scipy_csc_in_namespace(
|
|
537
|
+
xp_new, conv_data, conv_indices, conv_indptr, mat.shape
|
|
538
|
+
)
|
|
539
|
+
continue
|
|
540
|
+
|
|
541
|
+
getattr(dij_copy, q).flat[i] = to_namespace(
|
|
542
|
+
xp_new, mat, keep_sparse_compat=keep_sparse_compat
|
|
543
|
+
)
|
|
486
544
|
|
|
487
|
-
if isinstance(xp_new, str)
|
|
488
|
-
name = xp_new
|
|
489
|
-
else:
|
|
490
|
-
name = xp_new.__name__
|
|
545
|
+
name = xp_new.__name__ if not isinstance(xp_new, str) else xp_new
|
|
491
546
|
|
|
492
547
|
logger.info(f"Converted Dij to namespace '{name}'")
|
|
493
548
|
|
|
@@ -583,7 +583,7 @@ class DoseEngineBase(ABC):
|
|
|
583
583
|
self._machine = self.load_machine(radiation_mode, machine)
|
|
584
584
|
|
|
585
585
|
# Voxel selection for dose calculation
|
|
586
|
-
# TODO: set overlap
|
|
586
|
+
# TODO: set overlap priorities - Skips most of the function
|
|
587
587
|
cst = self.set_overlap_priorities(cst, ct_dim=None)
|
|
588
588
|
|
|
589
589
|
# resizing cst to dose cube resolution
|