Python module for computing dose-volume, LET-volume, and dose-LET-volume histograms from proton therapy DICOM plans. It allows also NTCP calculation for brain irradiations.
- DVH – Physical dose, fixed RBE×1.1, and variable RBE (McNamara, Wedenberg, Carabe)
- LVH – LETd-volume histograms per structure
- DLVH – 2-D dose-LET-volume histogram (colormap)
- Metrics – Dmin/mean/max, Dx%, Vx, gEUD, EQD2, dose-averaged LET, LETd-thresholded DVH, D_Lx%, L_Dx%
- Outputs – CSV, Excel, multi-page PDF (DVH/LVH), per-structure PNG (DLVH), NTCP summaries over RBE models
Full documentation here.
git clone https://github.com/oncoray/PyPlanAnalysis.git
cd PyPlanAnalysis
conda env create -f Environment.yml
conda activate PyPlan_envpip install . --no-build-isolation --no-deps pip install -e . --no-build-isolation --no-depsconda create -n YourEnv -c conda-forge --file requirements_conda.txt
conda activate YourEnv
pip install . --no-build-isolation --no-deps Run the example code on test data to have an example:
cd PyPlanAnalysis
python -m Examples.single_test_patientplan = PatientPlan.from_folder("data/Patient_01/")from PyPlanAnalysis import PatientPlan, RBEConfig, MetricConfig
plan = PatientPlan(
patient_id = "Patient_01",
dose_file = "RD_physicaldose.dcm",
let_file = "RD_LETd.dcm",
rtstruct = "RS_structures.dcm",
)from PyPlanAnalysis import RBEConfig, MetricConfig, RadiobiologyConfig
rbe_cfg = RBEConfig(models=["mcnamara", "linear"])
metric_cfg = MetricConfig(
dx = [2, 50, 98],
vx = [20, 40],
)
radiobio_cfg = RadiobiologyConfig(
alpha_beta_map = {"ctv": 10.0, "brainstem": 2.0},
alpha_beta_default = 2.0,
)
NTCP_config = NTCPConfig() # uses built-in defaultsresults = plan.analyse(structures=["CTV", "Brainstem"],
rbe_cfg=rbe_cfg,
metric_cfg=metric_cfg,
radiobio_cfg=radiobio_cfg)
results.to_excel("metrics.xlsx")
#or
results.save_all("output/Patient_01/")
#save DLVH plots
results.plot_dlvh(output_dir / "dlvh_2d")
NTCP_summary = results.CalcNTCP(NTCP_config)
NTCP_summary = pd.DataFrame.from_dict(NTCP_summary)
save_ntcp = output_dir / "NTCP_metrics.xlsx"
NTCP_summary.to_excel(save_ntcp)
PyPlanAnalysis/
├── __init__.py
├── data # Folder containing NTCPModels_params.xlsx for default NTCP computation
├── io.py # DICOM loading, grid resampling, structure masks
├── rbe.py # RBE models (fixed, McNamara, Wedenberg, Carabe, Linear (phys + 0.1 LET))
├── metrics.py # DVH/LVH metric computation, histogram helpers
├── plots.py # matplotlib plotting
├── NTCP.py # NTCP config and computation
└── plan.py # PatientPlan and AnalysisResults classes
- Python ≥ 3.10
- numpy>=1.24
- scipy>=1.10
- matplotlib>=3.7
- pandas>=2.0
- pydicom>=2.4
- openpyxl>=3.1
- scikit-image
- simpleitk
- pip
- setuptools
- wheel