Skip to main content

some tools for 302

Project description

ToolsFor302

ToolsFor302 provides Python helpers for dose grid loading, plotting, and gamma analysis.

Installation

pip install ToolsFor302

Runtime dependencies are installed by default: numpy, matplotlib, ipywidgets, SimpleITK, pymedphys, and pydicom.

Usage

ToolsFor302 0.3.4 uses DoseVolume as the common dose data container.

from ToolsFor302 import (
    DoseVolume,
    read_mhd_dose,
    read_bin_dose,
    read_dicom_dose,
    calculate_gamma,
    plot_slice,
    plot_gamma_histogram,
)

Read dose files:

mhd_volume = read_mhd_dose("dose.mhd")

bin_volume = read_bin_dose(
    "dose.bin",
    dtype="float",
    shape=(128, 256, 256),
    spacing_mm=(2.5, 1.0, 1.0),
)

dicom_volume = read_dicom_dose("rt_dose.dcm")

Create a volume directly:

import numpy as np

volume = DoseVolume(
    array=np.zeros((16, 64, 64)),
    axes_mm=(
        np.arange(16) * 2.5,
        np.arange(64) * 1.0,
        np.arange(64) * 1.0,
    ),
    metadata={"source": "example"},
)

Calculate gamma:

result = calculate_gamma(
    reference=mhd_volume,
    evaluation=dicom_volume,
    dose_percent_threshold=3,
    distance_mm_threshold=3,
    lower_percent_dose_cutoff=10,
)

print(result.pass_rate_percent)

Plot dose and gamma data:

slice_plot = plot_slice(mhd_volume, slice_index=20, show=True)
gamma_plot = plot_gamma_histogram(result, show=True)

slice_plot.fig.savefig("dose_slice.png")

Project structure

ToolsFor302_pypi/
├── ToolsFor302/          # Package source code
│   ├── __init__.py       # Public API exports
│   ├── dlTools.py        # Placeholder download/helper tools
│   └── doseTools.py      # Dose volume, I/O, plotting, and gamma tools
├── tests/                # Public API and doseTools tests
├── dist/                 # Built release artifacts
├── LICENSE
├── README.md
├── setup.py
└── .gitignore

API note

Version 0.3.4 is a breaking API cleanup. Old functions such as load_mhd_dose, load_bin_dose, cal_gamma, and show_gamma are no longer exported. Use read_mhd_dose, read_bin_dose, calculate_gamma, and the plot_* functions instead.

Project details


Download files

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

Source Distribution

toolsfor302-0.3.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

toolsfor302-0.3.4-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file toolsfor302-0.3.4.tar.gz.

File metadata

  • Download URL: toolsfor302-0.3.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for toolsfor302-0.3.4.tar.gz
Algorithm Hash digest
SHA256 df3a8d75eba350d5a556bc743cd8e12b5d290ae0858aa09025e50e2ecc5c92a2
MD5 eafd03684acfd6df19437ac9121df3df
BLAKE2b-256 b338b3cf95cebad10097475e289db517bf8ff34bcab570c999a5350739654ff7

See more details on using hashes here.

File details

Details for the file toolsfor302-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: toolsfor302-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for toolsfor302-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 211978c040eec85778482eb2703aea548975c560bb5e46941a22e5d67c1d900f
MD5 7ea5bdc13b9c6f8305743dbf137d8159
BLAKE2b-256 d8344e3ad9a911ce9c9589bdbd0f6af9164926690ed500cf2ee37c5449367539

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