pyRadPlan 0.3.0__tar.gz → 0.3.1__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.0/pyRadPlan.egg-info → pyradplan-0.3.1}/PKG-INFO +5 -2
- {pyradplan-0.3.0 → pyradplan-0.3.1}/README.md +2 -0
- pyradplan-0.3.1/examples/utils_plotting.py +169 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/__init__.py +2 -1
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_factory.py +2 -2
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/raytracer/_base.py +68 -28
- pyradplan-0.3.1/pyRadPlan/raytracer/_numba_perf.py +33 -0
- pyradplan-0.3.1/pyRadPlan/visualization/__init__.py +9 -0
- pyradplan-0.3.1/pyRadPlan/visualization/_plot_multiple_slices.py +138 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/visualization/_plot_slice.py +84 -59
- {pyradplan-0.3.0 → pyradplan-0.3.1/pyRadPlan.egg-info}/PKG-INFO +5 -2
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan.egg-info/SOURCES.txt +4 -1
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan.egg-info/requires.txt +3 -1
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyproject.toml +2 -2
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_raytracersiddon.py +21 -0
- pyradplan-0.3.1/test/visualization/test_plot_multiple_slices.py +286 -0
- pyradplan-0.3.0/pyRadPlan/raytracer/_perf.py +0 -229
- pyradplan-0.3.0/pyRadPlan/visualization/__init__.py +0 -5
- {pyradplan-0.3.0 → pyradplan-0.3.1}/LICENSE +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/docs/conf.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/intro_minimal_photons.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/intro_minimal_protons.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/mc_fred.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_carbon.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_helium.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_photon.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_proton.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_proton_let.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/pencilbeam_vhee.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/raytracer_rad_depth.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/examples/utils_matrad.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/analysis/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/analysis/_dvh.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/_exceptions.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/_grids.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/datamodel.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/np2sitk.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/resample.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/xp_utils/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/xp_utils/compat.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/xp_utils/helpers.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/core/xp_utils/typing.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/cst/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/cst/_cst.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/cst/_voi.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/ct/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/ct/_ct.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/ct/_hlut.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/data/phantoms/TG119.mat +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dij/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dij/_dij.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/_calc_dose.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base_montecarlo.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base_pencilbeam.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_fredmc.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_hongpb.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_svdpb.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/geometry/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/geometry/lps.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/io/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/io/_matlab_file_handler.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/io/_patient_loader.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/io/matfile.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/_load.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/_validate.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/base/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/base/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/base/_external_beam.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/base/_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/base/_internal_beam.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_beam_cutoff.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_beam_emittance.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_beam_energy.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_beam_focus.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_ions.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/_vhee.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/kernel/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/kernel/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/kernel/_ions.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/particles/kernel/_vhee.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/photons/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/photons/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/photons/_linac.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/machines/photons/_svd_kernel.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/matRad/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/matRad/_engine.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/matRad/_matlab.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/matRad/_octave.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_eud.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_mean.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_objective.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_std.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_nonlin_fluence.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_optiprob.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_base_solvers.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_ipopt.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/plan/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/plan/_plans.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/quantities/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/quantities/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/quantities/_dose.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/quantities/_let_x_dose.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/raytracer/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/raytracer/_siddon.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/scenarios/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/scenarios/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/scenarios/_nominal.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_beam.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_beamlet.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_exceptions.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_generate_stf.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_rangeshifter.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_ray.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/_steeringinformation.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_ions.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_photons.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_vhee.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/util/__init__.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/util/helpers.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan/util/keyboard_listener.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan.egg-info/dependency_links.txt +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/pyRadPlan.egg-info/top_level.txt +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/setup.cfg +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/analysis/test_dvh.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/analysis/test_qi.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/compute/test_math_interp1d.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/compute/test_math_quantile.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/compute/test_namespace_conversion.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/conftest.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/core/test_coordinates.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/core/test_datamodel.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/core/test_np2sitk.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/core/test_resample.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/cst/conftest.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/cst/test_VOI.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/cst/test_cst.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/ct/test_ct.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/ct/test_hlut.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/data/test_validate_test_data.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/conftest.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_dose_engine_base.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_fred.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_hongpb.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_pb_geodist.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/dose/test_svdpb.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/geometry/test_lps.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_fluence_optiprob.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_ipopt_solver.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_objectives.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_problem_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_scipy_solver.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/optimization/test_solver_factory.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/quantities/test_dose_quantity.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/quantities/test_let_dose_quantity.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/stf/test_beamlet.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/stf/test_stf.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/stf/test_stf_gen.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_dij.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_fileHandling.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_grid.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_helpers.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_machine_model.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_matlabEngine.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_octaveEngine.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_plan.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/test/test_scenarios.py +0 -0
- {pyradplan-0.3.0 → pyradplan-0.3.1}/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.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: A python interface and reimplementation to matRad
|
|
5
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
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>
|
|
@@ -21,7 +21,6 @@ Requires-Dist: pymatreader>=1.0.0
|
|
|
21
21
|
Requires-Dist: h5py>=3.11.0
|
|
22
22
|
Requires-Dist: regex>=2024.5.15
|
|
23
23
|
Requires-Dist: pydicom>=2.4.4
|
|
24
|
-
Requires-Dist: numba>=0.61.0
|
|
25
24
|
Requires-Dist: matplotlib>=3.9.2
|
|
26
25
|
Requires-Dist: pydantic<2.13,>=2.10
|
|
27
26
|
Requires-Dist: numpydantic>=1.6.9
|
|
@@ -34,6 +33,8 @@ Provides-Extra: octave
|
|
|
34
33
|
Requires-Dist: oct2py; extra == "octave"
|
|
35
34
|
Provides-Extra: gui
|
|
36
35
|
Requires-Dist: PyQt5; extra == "gui"
|
|
36
|
+
Provides-Extra: numba
|
|
37
|
+
Requires-Dist: numba>=0.61.0; extra == "numba"
|
|
37
38
|
Provides-Extra: dev
|
|
38
39
|
Requires-Dist: pytest; extra == "dev"
|
|
39
40
|
Requires-Dist: coverage; extra == "dev"
|
|
@@ -65,6 +66,8 @@ Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de
|
|
|
65
66
|
## Concept and Goals
|
|
66
67
|
pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
|
|
67
68
|
|
|
69
|
+
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.
|
|
70
|
+
|
|
68
71
|
### Data Structures
|
|
69
72
|
pyRadPlan uses a similar datastructure and workflow concept as in matRad, while trying to ensure that the corresponding datastructures can be easily imported and exported from/to matRad. This facilitates the application of either algortihms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
70
73
|
|
|
@@ -16,6 +16,8 @@ Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de
|
|
|
16
16
|
## Concept and Goals
|
|
17
17
|
pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
|
|
18
18
|
|
|
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
|
+
|
|
19
21
|
### Data Structures
|
|
20
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 algortihms from matRad or native pyRadPlan at any stage of the treatment planning workflow.
|
|
21
23
|
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# %% [markdown]
|
|
2
|
+
"""# Multiple examples on how to use the visualization tools provided by pyRadPlan."""
|
|
3
|
+
# %% [markdown]
|
|
4
|
+
# This example demonstrates the usage of `plot_slice()`, `plot_distributions()` and `plot_3d()`.
|
|
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/utils_plotting.py
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Import necessary libraries
|
|
15
|
+
import logging
|
|
16
|
+
|
|
17
|
+
import matplotlib.pyplot as plt
|
|
18
|
+
|
|
19
|
+
from pyRadPlan import (
|
|
20
|
+
IonPlan,
|
|
21
|
+
generate_stf,
|
|
22
|
+
calc_dose_influence,
|
|
23
|
+
fluence_optimization,
|
|
24
|
+
plot_slice,
|
|
25
|
+
plot_multiple_slices,
|
|
26
|
+
load_tg119,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
logging.basicConfig(level=logging.INFO)
|
|
30
|
+
|
|
31
|
+
# %% [markdown]
|
|
32
|
+
# ### Just like in other examples, we need to generate some distributions/quantities to visualize.
|
|
33
|
+
# %%
|
|
34
|
+
# load TG119
|
|
35
|
+
ct, cst = load_tg119()
|
|
36
|
+
|
|
37
|
+
# Create a plan object
|
|
38
|
+
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
39
|
+
pln.prop_opt = {"solver": "scipy"}
|
|
40
|
+
# Lets calc the biological dose too
|
|
41
|
+
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
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
|
+
# Run fluence optimization and compute the result
|
|
50
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
51
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
52
|
+
|
|
53
|
+
# %% [markdown]
|
|
54
|
+
# ### Visualizing a single slice with `plot_slice()`
|
|
55
|
+
# %%
|
|
56
|
+
|
|
57
|
+
# Visualize only ct and choosen quantity
|
|
58
|
+
plot_slice(ct=ct, overlay=result["physical_dose"])
|
|
59
|
+
|
|
60
|
+
# Visualize ct, cst and choosen quantity
|
|
61
|
+
plot_slice(ct=ct, cst=cst, overlay=result["physical_dose"])
|
|
62
|
+
|
|
63
|
+
# %% [markdown]
|
|
64
|
+
# ## Visualze more abstract settings using `plot_slice()` <br>
|
|
65
|
+
|
|
66
|
+
# `plot_slice()` has multiple tweakable parameters:
|
|
67
|
+
# - **ct**: The CT data to visualize
|
|
68
|
+
# - **cst**: The structure set to visualize (optional)
|
|
69
|
+
# - **overlay**: The quantity to visualize
|
|
70
|
+
# - **view_slice**: Which slice to visualize (default: middle slice)
|
|
71
|
+
# - **plane**: Which plane to visualize (default: "axial")
|
|
72
|
+
# - **overlay_alpha**: Transparency of the overlay (default: 0.5)
|
|
73
|
+
# - **overlay_rel_threshold**: Relative threshold for the overlay (default: 0.01)
|
|
74
|
+
# - **overlay_unit**: The unit of the overlay quantity (default: "Gy")
|
|
75
|
+
# - **save_filename**: If provided, saves the plot to a file
|
|
76
|
+
# - **show_plot**: Whether to show the plot (default: True)
|
|
77
|
+
# - **use_global_max**: If True, uses the global maximum of the overlay for scaling (default: False)
|
|
78
|
+
# - **ax**: If provided, plots on the given axes (useful for subplots) - use of 'plot_distributions()' is recommended
|
|
79
|
+
# %%
|
|
80
|
+
# Feel free to change the parameters to see how they affect the plot.
|
|
81
|
+
plot_slice(
|
|
82
|
+
ct=ct,
|
|
83
|
+
cst=cst,
|
|
84
|
+
overlay=result["physical_dose"],
|
|
85
|
+
view_slice=64, # Visualize slice 10
|
|
86
|
+
plane="coronal", # axial, coronal or sagittal
|
|
87
|
+
overlay_alpha=0.5, # Transparency of the overlay
|
|
88
|
+
overlay_unit="Gy", # Gy, dimensionless, etc.
|
|
89
|
+
overlay_rel_threshold=0.01, # Relative threshold for the overlay
|
|
90
|
+
contour_line_width=1.0, # Width of the contour lines
|
|
91
|
+
save_filename=None, # alt: path/to/save/plot.png
|
|
92
|
+
show_plot=True, # Show the plot
|
|
93
|
+
use_global_max=False, # Do not use global max for scaling
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# %% [markdown]
|
|
97
|
+
# ### Visualizing multiple overlays/quantites with `plot_distributions()`
|
|
98
|
+
# This function might be useful in cases you want to compare multiple overlays/quantities/beams side by side.
|
|
99
|
+
|
|
100
|
+
# `plot_distributions()` has similar parameters to `plot_slice()`:
|
|
101
|
+
# - **ct**: The CT data to visualize
|
|
102
|
+
# - **cst**: The structure set to visualize (optional)
|
|
103
|
+
# - **overlays**: List of overlay images to visualize
|
|
104
|
+
# - **view_slice**: Which slices to visualize (default: middle slice)
|
|
105
|
+
# - **plane**: Which plane to visualize (default: "axial")
|
|
106
|
+
# - **overlay_alpha**: Transparency of the overlay (default: 0.5)
|
|
107
|
+
# - **overlay_unit**: List of units for each overlay (default: "Gy")
|
|
108
|
+
# - **overlay_rel_threshold**: Relative threshold for the overlay (default: 0.01)
|
|
109
|
+
# - **contour_line_width**: Line width for the contour lines (default: 1.0)
|
|
110
|
+
# - **save_filename**: If provided, saves the plot to a file
|
|
111
|
+
# - **show_plot**: Whether to show the plot (default: True)
|
|
112
|
+
# - **use_global_max**: If True, uses the global maximum of the overlay for scaling
|
|
113
|
+
# - **overlay_titles**: Custom titles for each overlay type (optional)
|
|
114
|
+
# %%
|
|
115
|
+
# Feel free to change the parameters to see how they affect the plot.
|
|
116
|
+
plot_multiple_slices(
|
|
117
|
+
ct=ct,
|
|
118
|
+
cst=cst,
|
|
119
|
+
overlays=[result["physical_dose"], result["effect"]],
|
|
120
|
+
view_slice=[64, 65], # Visualize slices 64 and 65
|
|
121
|
+
plane="axial", # axial, coronal or sagittal
|
|
122
|
+
overlay_alpha=0.5, # Transparency of the overlay
|
|
123
|
+
overlay_unit=["Gy", "dimensionless"], # Units for each overlay
|
|
124
|
+
overlay_rel_threshold=0.01, # Relative threshold for the overlay
|
|
125
|
+
contour_line_width=1.0, # Width of the contour lines
|
|
126
|
+
save_filename=None, # alt: path/to/save/plot.png
|
|
127
|
+
show_plot=True, # Show the plot
|
|
128
|
+
use_global_max=False, # Do not use global max for scaling
|
|
129
|
+
overlay_titles=["Physical Dose", "Biological Effect"], # Titles for each overlay
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# %% [markdown]
|
|
133
|
+
# ### Being more flexible with only `plot_slice()` is also possible:
|
|
134
|
+
# %%
|
|
135
|
+
# Create a figure with subplots for side-by-side comparison
|
|
136
|
+
# 2 rows (physical dose, biological effect) x 2 cols (slice1, slice2)
|
|
137
|
+
slices = [64, 65] # Slices to visualize
|
|
138
|
+
fig, axes = plt.subplots(2, 2, figsize=(12, 10))
|
|
139
|
+
|
|
140
|
+
# Plot physical dose for both slices
|
|
141
|
+
for i, slice_idx in enumerate(slices):
|
|
142
|
+
plot_slice(
|
|
143
|
+
ct=ct,
|
|
144
|
+
cst=cst,
|
|
145
|
+
overlay=result["physical_dose"],
|
|
146
|
+
view_slice=slice_idx, # Single slice
|
|
147
|
+
plane="axial",
|
|
148
|
+
overlay_unit="Gy",
|
|
149
|
+
show_plot=False,
|
|
150
|
+
ax=axes[0, i], # Top row
|
|
151
|
+
)
|
|
152
|
+
axes[0, i].set_title(f"Physical Dose - Slice {slice_idx}")
|
|
153
|
+
|
|
154
|
+
# Plot biological effect for both slices
|
|
155
|
+
for i, slice_idx in enumerate(slices):
|
|
156
|
+
plot_slice(
|
|
157
|
+
ct=ct,
|
|
158
|
+
cst=cst,
|
|
159
|
+
overlay=result["effect"],
|
|
160
|
+
view_slice=slice_idx, # Single slice
|
|
161
|
+
plane="axial",
|
|
162
|
+
overlay_unit="dimensionless",
|
|
163
|
+
show_plot=False,
|
|
164
|
+
ax=axes[1, i], # Bottom row
|
|
165
|
+
)
|
|
166
|
+
axes[1, i].set_title(f"Biological Effect - Slice {slice_idx}")
|
|
167
|
+
|
|
168
|
+
plt.tight_layout()
|
|
169
|
+
plt.show()
|
|
@@ -35,7 +35,7 @@ from .stf import SteeringInformation, validate_stf
|
|
|
35
35
|
from .dose._calc_dose import calc_dose_influence, calc_dose_forward
|
|
36
36
|
from .optimization._fluence_optimization import fluence_optimization
|
|
37
37
|
from .analysis._dvh import DVH, DVHCollection
|
|
38
|
-
from .visualization import plot_slice
|
|
38
|
+
from .visualization import plot_slice, plot_multiple_slices
|
|
39
39
|
from .io import load_patient, load_tg119
|
|
40
40
|
from .core import xp_utils
|
|
41
41
|
|
|
@@ -68,6 +68,7 @@ __all__ = [
|
|
|
68
68
|
"SteeringInformation",
|
|
69
69
|
"validate_stf",
|
|
70
70
|
"plot_slice",
|
|
71
|
+
"plot_multiple_slices",
|
|
71
72
|
"load_patient",
|
|
72
73
|
"load_tg119",
|
|
73
74
|
]
|
|
@@ -48,8 +48,8 @@ def get_available_engines(pln: Union[Plan, dict[str]]) -> dict[str, Type[DoseEng
|
|
|
48
48
|
|
|
49
49
|
Returns
|
|
50
50
|
-------
|
|
51
|
-
|
|
52
|
-
A
|
|
51
|
+
dict[str, Type[DoseEngineBase]]
|
|
52
|
+
A dictionary containing the available engines.
|
|
53
53
|
"""
|
|
54
54
|
pln = validate_pln(pln)
|
|
55
55
|
return {
|
|
@@ -7,12 +7,17 @@ import time
|
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
import SimpleITK as sitk
|
|
10
|
+
import array_api_compat
|
|
10
11
|
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
from ..core.xp_utils.typing import Array
|
|
13
|
+
from ..core.np2sitk import linear_indices_to_image_coordinates
|
|
14
|
+
from ..geometry import lps
|
|
15
|
+
from ..stf._beam import Beam
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
try:
|
|
18
|
+
from ._numba_perf import fast_spatial_circle_lookup
|
|
19
|
+
except ImportError:
|
|
20
|
+
fast_spatial_circle_lookup = None
|
|
16
21
|
|
|
17
22
|
logger = logging.getLogger(__name__)
|
|
18
23
|
|
|
@@ -173,40 +178,24 @@ class RayTracerBase(ABC):
|
|
|
173
178
|
)
|
|
174
179
|
ray_matrix_scale = 1 + ray_matrix_bev_y / beam.sad
|
|
175
180
|
|
|
176
|
-
# num_candidate_rays = 2 * np.ceil(500.0 / ray_spacing).astype(np.int64) + 1
|
|
177
|
-
|
|
178
|
-
spacing_range = ray_spacing * np.arange(
|
|
179
|
-
np.floor(-500.0 / ray_spacing), np.ceil(500.0 / ray_spacing) + 1, dtype=self.precision
|
|
180
|
-
)
|
|
181
|
-
candidate_ray_coords_x, candidate_ray_coords_z = np.meshgrid(spacing_range, spacing_range)
|
|
182
|
-
|
|
183
181
|
# If we have reference positions, we use them to restrict the raytracing region
|
|
184
182
|
reference_positions_bev = ray_matrix_scale * np.array(
|
|
185
183
|
[ray.ray_pos_bev for ray in beam.rays]
|
|
186
184
|
)
|
|
187
185
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
candidate_ray_coords_x,
|
|
191
|
-
candidate_ray_coords_z,
|
|
192
|
-
reference_positions_bev,
|
|
193
|
-
self.lateral_cut_off,
|
|
186
|
+
spacing_range = ray_spacing * np.arange(
|
|
187
|
+
np.floor(-500.0 / ray_spacing), np.ceil(500.0 / ray_spacing) + 1, dtype=self.precision
|
|
194
188
|
)
|
|
195
189
|
|
|
196
|
-
|
|
190
|
+
candidate_ray_mx = self._get_candidate_ray_matrix(spacing_range, reference_positions_bev)
|
|
197
191
|
|
|
198
|
-
|
|
199
|
-
# notix = (candidate_ray_coords_x - reference_positions_bev[i, 0]) ** 2 + (
|
|
200
|
-
# candidate_ray_coords_z - reference_positions_bev[i, 2]
|
|
201
|
-
# ) ** 2 <= self.lateral_cut_off**2
|
|
202
|
-
# candidate_ray_mx[notix] = True
|
|
192
|
+
ray_idx_z, ray_idx_x = np.nonzero(candidate_ray_mx)
|
|
203
193
|
|
|
204
|
-
ray_matrix_bev = np.
|
|
194
|
+
ray_matrix_bev = np.column_stack(
|
|
205
195
|
(
|
|
206
|
-
|
|
207
|
-
ray_matrix_bev_y
|
|
208
|
-
|
|
209
|
-
candidate_ray_coords_z[candidate_ray_mx].reshape(-1, 1),
|
|
196
|
+
spacing_range[ray_idx_x],
|
|
197
|
+
np.full(ray_idx_x.shape[0], ray_matrix_bev_y, dtype=self.precision),
|
|
198
|
+
spacing_range[ray_idx_z],
|
|
210
199
|
)
|
|
211
200
|
)
|
|
212
201
|
|
|
@@ -301,6 +290,57 @@ class RayTracerBase(ABC):
|
|
|
301
290
|
return rad_depth_cubes
|
|
302
291
|
# scale_factor[valid_ix] = lengths[valid_ix] / d12[valid_ix]
|
|
303
292
|
|
|
293
|
+
def _get_candidate_ray_matrix(self, spacing_range: Array, ref_pos_bev: Array) -> Array:
|
|
294
|
+
"""Get candidate ray matrix for given ray spacing and reference positions."""
|
|
295
|
+
|
|
296
|
+
xp = array_api_compat.array_namespace(spacing_range, ref_pos_bev)
|
|
297
|
+
|
|
298
|
+
# Use numba accelerated code if possible
|
|
299
|
+
if array_api_compat.is_numpy_namespace(xp) and fast_spatial_circle_lookup is not None:
|
|
300
|
+
candidate_ray_coords_x, candidate_ray_coords_z = np.meshgrid(
|
|
301
|
+
spacing_range, spacing_range
|
|
302
|
+
)
|
|
303
|
+
return fast_spatial_circle_lookup(
|
|
304
|
+
candidate_ray_coords_x, candidate_ray_coords_z, ref_pos_bev, self.lateral_cut_off
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# Array API compliant code
|
|
308
|
+
n_candidates = array_api_compat.size(spacing_range)
|
|
309
|
+
|
|
310
|
+
candidate_ray_mx = xp.zeros((n_candidates, n_candidates), dtype=xp.bool)
|
|
311
|
+
|
|
312
|
+
r2 = self.lateral_cut_off**2
|
|
313
|
+
|
|
314
|
+
# use buffers to avoid repeated allocations in the loop
|
|
315
|
+
buffer_x = xp.empty_like(spacing_range)
|
|
316
|
+
buffer_z = xp.empty_like(spacing_range)
|
|
317
|
+
|
|
318
|
+
for i in range(ref_pos_bev.shape[0]):
|
|
319
|
+
# Use in-place operations as much as possible
|
|
320
|
+
buffer_x[:] = spacing_range
|
|
321
|
+
buffer_z[:] = spacing_range
|
|
322
|
+
|
|
323
|
+
buffer_x -= ref_pos_bev[i, 0]
|
|
324
|
+
buffer_z -= ref_pos_bev[i, 2]
|
|
325
|
+
|
|
326
|
+
buffer_x *= buffer_x
|
|
327
|
+
buffer_z *= buffer_z
|
|
328
|
+
|
|
329
|
+
# simple full boolean or
|
|
330
|
+
# candidate_ray_mx |= (buffer_x[:, None] + buffer_z[None, :) <= r2
|
|
331
|
+
|
|
332
|
+
# reduce update region by finding z ranges that are valid
|
|
333
|
+
z_ok = xp.astype(buffer_z <= r2, xp.uint8) # argmax later only works on numeric types
|
|
334
|
+
if not xp.any(z_ok):
|
|
335
|
+
continue
|
|
336
|
+
|
|
337
|
+
z0 = xp.argmax(z_ok)
|
|
338
|
+
z1 = array_api_compat.size(z_ok) - xp.argmax(z_ok[::-1])
|
|
339
|
+
|
|
340
|
+
candidate_ray_mx[z0:z1, :] |= (buffer_z[z0:z1, None] + buffer_x[None, :]) <= r2
|
|
341
|
+
|
|
342
|
+
return candidate_ray_mx
|
|
343
|
+
|
|
304
344
|
@abstractmethod
|
|
305
345
|
def _initialize_geometry(self):
|
|
306
346
|
"""
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from numba import njit, prange
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@njit(parallel=True, nogil=True, cache=True)
|
|
6
|
+
def fast_spatial_circle_lookup(
|
|
7
|
+
mesh_x: np.ndarray, mesh_z: np.ndarray, lookup_pos: np.ndarray, radius: float
|
|
8
|
+
) -> np.ndarray:
|
|
9
|
+
"""Lookup all points within a circle in a meshgrid.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
mesh_x : np.ndarray
|
|
14
|
+
The x-coordinates of the meshgrid (NxN)
|
|
15
|
+
mesh_z : np.ndarray
|
|
16
|
+
The y-coordinates of the meshgrid (NxN)
|
|
17
|
+
lookup_pos : np.ndarray
|
|
18
|
+
the reference positions to lookup (Mx3)
|
|
19
|
+
radius : float
|
|
20
|
+
The radius of the circle.
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
np.ndarray
|
|
25
|
+
The indices of the points within the circle.
|
|
26
|
+
"""
|
|
27
|
+
candidate_ray_mx = np.full(mesh_x.shape, False, dtype=np.bool_)
|
|
28
|
+
for i in prange(lookup_pos.shape[0]):
|
|
29
|
+
ix = (mesh_x.ravel() - lookup_pos[i, 0]) ** 2 + (
|
|
30
|
+
mesh_z.ravel() - lookup_pos[i, 2]
|
|
31
|
+
) ** 2 <= radius**2
|
|
32
|
+
candidate_ray_mx.ravel()[ix] = 1
|
|
33
|
+
return candidate_ray_mx
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from typing import Optional, Union, Literal, TypedDict
|
|
2
|
+
from typing_extensions import Unpack
|
|
3
|
+
import numpy as np
|
|
4
|
+
import SimpleITK as sitk
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import pint
|
|
7
|
+
import re
|
|
8
|
+
from pyRadPlan import CT, StructureSet
|
|
9
|
+
from pyRadPlan.visualization._plot_slice import plot_slice
|
|
10
|
+
|
|
11
|
+
# Initialize Units
|
|
12
|
+
ureg = pint.UnitRegistry()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PlotMultipleSlicesKwargs(TypedDict, total=False):
|
|
16
|
+
plane: Union[Literal["axial", "coronal", "sagittal"], int]
|
|
17
|
+
overlay_alpha: float
|
|
18
|
+
overlay_unit: Union[str, pint.Unit, list[Union[str, pint.Unit]]]
|
|
19
|
+
overlay_rel_threshold: float
|
|
20
|
+
contour_line_width: float
|
|
21
|
+
save_filename: Optional[str]
|
|
22
|
+
show_plot: bool
|
|
23
|
+
use_global_max: bool
|
|
24
|
+
overlay_titles: Optional[list[str]]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def plot_multiple_slices(
|
|
28
|
+
ct: Optional[Union[CT, dict]] = None,
|
|
29
|
+
cst: Optional[Union[StructureSet, dict, list]] = None,
|
|
30
|
+
overlays: Optional[Union[sitk.Image, np.ndarray]] = None,
|
|
31
|
+
view_slice: Optional[Union[list[int], np.ndarray, int]] = None,
|
|
32
|
+
**kwargs: Unpack[PlotMultipleSlicesKwargs],
|
|
33
|
+
):
|
|
34
|
+
"""Plot multiple distributions for given slices with dynamic figure sizing.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
ct : CT
|
|
39
|
+
The CT object.
|
|
40
|
+
cst : StructureSet
|
|
41
|
+
The StructureSet object.
|
|
42
|
+
overlays : list of sitk.Image or np.ndarray
|
|
43
|
+
List of overlay images to visualize.
|
|
44
|
+
view_slice : List[int], array, int or None
|
|
45
|
+
Slice indices to visualize.
|
|
46
|
+
|
|
47
|
+
**kwargs
|
|
48
|
+
----------
|
|
49
|
+
plane : str or int
|
|
50
|
+
The plane to visualize. Can be "axial", "coronal", or "sagittal". Default is "axial".
|
|
51
|
+
overlay_alpha : float
|
|
52
|
+
The alpha value for the overlay. Default is 0.5.
|
|
53
|
+
overlay_unit : list of str or pint.Unit
|
|
54
|
+
List of units for each overlay. Default is "".
|
|
55
|
+
overlay_rel_threshold : float
|
|
56
|
+
The relative threshold for the overlay. Default is 0.01.
|
|
57
|
+
contour_line_width : float
|
|
58
|
+
The line width for the contour lines. Default is 1.0.
|
|
59
|
+
save_filename : str
|
|
60
|
+
The filename to save the plot. Default is None.
|
|
61
|
+
show_plot : bool
|
|
62
|
+
If True, show the plot. Default is True.
|
|
63
|
+
use_global_max : bool
|
|
64
|
+
If True, use the overlay's global maximum for scaling. Default is False.
|
|
65
|
+
overlay_titles : list of str, optional
|
|
66
|
+
Custom titles for each overlay type. Default is None.
|
|
67
|
+
"""
|
|
68
|
+
overlay_unit = kwargs.get("overlay_unit", pint.Unit(""))
|
|
69
|
+
save_filename = kwargs.get("save_filename", None)
|
|
70
|
+
show_plot = kwargs.get("show_plot", True)
|
|
71
|
+
overlay_titles = kwargs.get("overlay_titles", None)
|
|
72
|
+
|
|
73
|
+
if ct is None and overlays is None:
|
|
74
|
+
raise ValueError("At least one of 'ct' or 'overlays' must be provided.")
|
|
75
|
+
# Ensure inputs are lists/arrays
|
|
76
|
+
view_slice = [view_slice] if not isinstance(view_slice, (list, np.ndarray)) else view_slice
|
|
77
|
+
overlays = [overlays] if not isinstance(overlays, list) else overlays
|
|
78
|
+
|
|
79
|
+
if not isinstance(overlay_unit, list):
|
|
80
|
+
overlay_unit = [overlay_unit] * len(overlays)
|
|
81
|
+
elif len(overlay_unit) != len(overlays):
|
|
82
|
+
raise ValueError("Length of 'overlay_unit' must match the number of overlays.")
|
|
83
|
+
|
|
84
|
+
n_slices = len(view_slice) if view_slice is not None else 1
|
|
85
|
+
n_overlays = len(overlays) if overlays is not None else 1
|
|
86
|
+
|
|
87
|
+
# TODO: Not sure if figsize per subplot should be an attribute. Add above if needed.
|
|
88
|
+
figsize_per_subplot = (5, 5)
|
|
89
|
+
# Calculate dynamic figure size
|
|
90
|
+
width = figsize_per_subplot[0] * n_slices
|
|
91
|
+
height = figsize_per_subplot[1] * n_overlays
|
|
92
|
+
figsize = (width, height)
|
|
93
|
+
|
|
94
|
+
fig, axes = plt.subplots(n_overlays, n_slices, figsize=figsize)
|
|
95
|
+
|
|
96
|
+
# Normalize axes to shape (n_overlays, n_slices)
|
|
97
|
+
axes = np.asarray(axes, dtype=object).reshape(n_overlays, n_slices)
|
|
98
|
+
|
|
99
|
+
for i, overlay in enumerate(overlays):
|
|
100
|
+
for j, slice_idx in enumerate(view_slice):
|
|
101
|
+
# Using the already existing plot_slice function to plot each overlay
|
|
102
|
+
# Prepare kwargs for plot_slice
|
|
103
|
+
plot_slice_kwargs = kwargs.copy()
|
|
104
|
+
plot_slice_kwargs.update(
|
|
105
|
+
{
|
|
106
|
+
"overlay_unit": overlay_unit[i],
|
|
107
|
+
"show_plot": False,
|
|
108
|
+
"ax": axes[i, j],
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
# Remove arguments that are not in plot_slice kwargs or handled explicitly
|
|
112
|
+
plot_slice_kwargs.pop("overlay_titles", None)
|
|
113
|
+
plot_slice_kwargs.pop("save_filename", None) # Handled at the end
|
|
114
|
+
|
|
115
|
+
plot_slice(ct=ct, cst=cst, overlay=overlay, view_slice=slice_idx, **plot_slice_kwargs)
|
|
116
|
+
|
|
117
|
+
# Try to extract slice index from the title set by plot_slice
|
|
118
|
+
# Title format: "Slice z={slice_idx}"
|
|
119
|
+
idx = (
|
|
120
|
+
int(re.search(r"Slice [xyz]=(\d+)", axes[i, j].get_title()).group(1))
|
|
121
|
+
if slice_idx is None
|
|
122
|
+
else slice_idx
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Set title
|
|
126
|
+
title = (
|
|
127
|
+
f"{overlay_titles[i]} - Slice {idx}"
|
|
128
|
+
if overlay_titles and i < len(overlay_titles)
|
|
129
|
+
else f"Overlay {i + 1} - Slice {idx}"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
axes[i, j].set_title(title)
|
|
133
|
+
|
|
134
|
+
plt.tight_layout()
|
|
135
|
+
if save_filename:
|
|
136
|
+
plt.savefig(save_filename)
|
|
137
|
+
if show_plot:
|
|
138
|
+
plt.show()
|