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.2.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.2-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dicomrttool-3.0.2.tar.gz
Algorithm Hash digest
SHA256 618762658fe84496f4c7bc5309a4a1bc0fd4a1c1bd75a32a3dcaa02b40bcd471
MD5 99f39e7e45128e71212f7be305fbb96b
BLAKE2b-256 f1f9086f066b2909357f12e1f709527fba2295229ebce20d8e7890c53899c520

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dicomrttool-3.0.2-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.2

File hashes

Hashes for dicomrttool-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3750b4cc4c16f61ca6bea3d362a6ecc675a09f11b0329181a3f8f221571cd3c
MD5 093edac1e8830ce6b48e08d0f25cedbc
BLAKE2b-256 66c968c3c6655400a0f267e44820a96754bea2d06b9d17dbfe73fc0b40ccd550

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