Skip to main content

Services for reading DICOM files, RT structures, and dose files, as well as tools for converting numpy prediction masks back to an RT structure.

Project description

DicomRTTool

PyPI version Tests

Published! See the Technical Note and please cite it if you find this work useful.
DOI: https://doi.org/10.1016/j.prro.2021.02.003

Convert DICOM images and RT structures into NIfTI files, NumPy arrays, and SimpleITK image handles — and convert prediction masks back into RT structures.

Installation

pip install DicomRTTool

For the interactive image viewer (requires matplotlib):

pip install "DicomRTTool[viewer]"

Supported Python versions: 3.8, 3.10, 3.12+

Quick Start

from DicomRTTool.ReaderWriter import DicomReaderWriter, ROIAssociationClass

dicom_path = "/path/to/dicom"
reader = DicomReaderWriter(description="Examples", arg_max=True)
reader.walk_through_folders(dicom_path)

# Inspect available ROIs
all_rois = reader.return_rois(print_rois=True)

# Define target ROIs with optional name aliases
contour_names = ["tumor"]
associations = [ROIAssociationClass("tumor", ["tumor_mr", "tumor_ct"])]
reader.set_contour_names_and_associations(
    contour_names=contour_names, associations=associations
)

# Load images and masks
reader.get_images_and_mask()

image_numpy = reader.ArrayDicom          # NumPy image array
mask_numpy = reader.mask                  # NumPy mask array
image_handle = reader.dicom_handle        # SimpleITK Image
mask_handle = reader.annotation_handle    # SimpleITK Image

Reading Extra DICOM Tags

from pydicom.tag import Tag

plan_keys = {"MyNamedRTPlan": Tag((0x300a, 0x002))}
image_keys = {"MyPatientName": "0010|0010"}

reader = DicomReaderWriter(
    description="Examples",
    arg_max=True,
    plan_pydicom_string_keys=plan_keys,
    image_sitk_string_keys=image_keys,
)

What's New in v3.0

  • Modern Python packagingpyproject.toml replaces setup.py
  • Type annotations throughout — better IDE support and documentation
  • logging module replaces print() — configurable verbosity
  • concurrent.futures replaces raw threading.Queue — cleaner parallelism
  • dataclasses for all internal data models
  • No bare except: — proper exception handling everywhere
  • Deprecated pandas.DataFrame.append replaced with pd.concat
  • Full backward compatibility — existing import paths still work

License

GPL-3.0-or-later

Citation

If you find this code useful, please reference the publication and the GitHub page.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dicomrttool-3.0.3.tar.gz (628.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dicomrttool-3.0.3-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file dicomrttool-3.0.3.tar.gz.

File metadata

  • Download URL: dicomrttool-3.0.3.tar.gz
  • Upload date:
  • Size: 628.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for dicomrttool-3.0.3.tar.gz
Algorithm Hash digest
SHA256 321b7e956a18b649802b9fd905cdb7e785d204c33406880e88dda5c4dccbe33b
MD5 328ccdf2841e47a9e056932f338fd20c
BLAKE2b-256 6e1d45d7cd17da199fd50b69b739f2edddbda26e832561e075deba7285611c64

See more details on using hashes here.

File details

Details for the file dicomrttool-3.0.3-py3-none-any.whl.

File metadata

  • Download URL: dicomrttool-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for dicomrttool-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 14cf337fad871d49f79219c796f64e81254efb311477904a39fa0860e7fc01fe
MD5 6677b2cb67ca0b3841267a25778c5840
BLAKE2b-256 5bb6a7cfd4a7fa6a1d6b17f9ba715d89bb623e744d39ec2a17242ea80ddf5e68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page