Skip to main content

DoseMetrics

Python Version PyPI version Tests Documentation License

DoseMetrics 0.4.0 is a Python library for radiotherapy dose analysis. It provides typed containers for dose distributions and structures, NIfTI and DICOM-RT I/O, DVH and plan-quality metrics, dose and geometry comparisons, gamma analysis, batch utilities, and publication-ready Matplotlib plots.

Installation

pip install dosemetrics

For local development:

git clone https://github.com/contouraid/dosemetrics.git
cd dosemetrics
make setup

Quick start

The current API keeps dose data, structure geometry, and metric computation separate:

from dosemetrics.metrics import conformity, dvh, homogeneity
from dosemetrics.utils import load_example_study, plot_subject_dvhs

dose, structures = load_example_study("test_subject")
ptv = structures["PTV"]

dose_bins, volume_percent = dvh.compute_dvh(dose, ptv, verbose=True)
stats = dvh.compute_dose_statistics(dose, ptv, verbose=True)
ci = conformity.compute_paddick_conformity_index(dose, ptv, prescription_dose=60.0)
hi = homogeneity.compute_homogeneity_index(dose, ptv)
fig, ax = plot_subject_dvhs(dose, structures)

print(f"Paddick CI: {ci:.3f}; HI: {hi:.3f}")

A NIfTI patient folder places Dose.nii.gz and one binary mask per structure in the same directory. load_structure_set() loads only geometry; load the dose independently with Dose.from_nifti().

Comparing plans

All reference-based functions accept reference first and evaluated second:

from dosemetrics import Dose
from dosemetrics.metrics import compare_ptv_dose, dose_comparison, gamma

reference = Dose.from_nifti("reference.nii.gz")
evaluated = Dose.from_nifti("evaluated.nii.gz")

mae_gy = dose_compare_mae(reference, evaluated)
gamma_map = gamma.compare_gamma_index(reference, evaluated)
gamma_pass = gamma.compute_gamma_passing_rate(gamma_map)
ptv_dose_distance = compare_ptv_dose(reference, evaluated, ptv)

Public package layout

  • dosemetrics: Dose, structure classes, StructureSet, and high-level loaders
  • dosemetrics.io: unified NIfTI/DICOM loading plus format-specific modules
  • dosemetrics.metrics: domain modules such as dvh, conformity, homogeneity, geometric, gamma, and dose_comparison, plus direct named compare_* functions
  • dosemetrics.utils: plotting, compliance, batch processing, and cohort analysis

Reference-free metrics remain grouped in domain modules. Named clinical plan comparisons are imported directly from dosemetrics.metrics.

Command line

dosemetrics --version
dosemetrics dvh Dose.nii.gz patient_folder -o dvh.csv
dosemetrics statistics Dose.nii.gz patient_folder -o statistics.csv
dosemetrics conformity Dose.nii.gz PTV.nii.gz --prescription 60
dosemetrics gamma reference.nii.gz evaluated.nii.gz --dose-criteria 3 --distance-criteria 3

Run dosemetrics --help or dosemetrics <command> --help for all options.

Development

make test
make docs
make app

The documentation notebooks use the public contouraid/dosemetrics-data dataset and are exercised by tests/test_documentation.py.

Documentation and demo

Citation

@software{dosemetrics2026,
  author = {Kamath, Amith},
  title = {DoseMetrics: A Python Library for Radiotherapy Dose Analysis},
  url = {https://github.com/contouraid/dosemetrics},
  version = {0.4.0},
  year = {2026}
}

License

Licensed under the Apache License, Version 2.0. Copyright 2023-2026 Amith Kamath and ContourAId. Redistribution must retain the notices in NOTICE.

Metadata

Release files for dosemetrics 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dosemetrics 0.4.1
File Size Uploaded
dosemetrics-0.4.1.tar.gz 109.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dosemetrics 0.4.1
File Interpreter ABI Platform
dosemetrics-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 224.8 kB

Release files / dosemetrics-0.4.1.tar.gz

Download URL dosemetrics-0.4.1.tar.gz
Size 109.2 kB
Tags Source
SHA-256 checksum
How to use checksums
09dc9f15ac57ffdfb18c66207a574a258eff7ac06e4631145b6554b44b6416de
BLAKE2b-256 checksum
How to use checksums
51581c00368e6595a437f8ab370d81db10213b51fcefa9edf06a8b337adacf26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / dosemetrics-0.4.1-py3-none-any.whl

Download URL dosemetrics-0.4.1-py3-none-any.whl
Size 115.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7079bbf34140799c4fec1c69ddd8ff76b906d0a730f484ea5ae97990ef7c4145
BLAKE2b-256 checksum
How to use checksums
0503a02fb493c4ebb34be227158352818860c831707cfafe63c049ae2b4a617c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page