Skip to main content

A small library for handling masks and RT-Structs

Project description

A minimal Python library for RTStruct manipulation

PyPI version


Motivated to allow physicians and other users to view the results of ML segmentation, rt-utils allows you to create new RTStructs, easily add one or more regions of interest, and save the resulting RTStruct in just a few lines! There will also be support

How it works

RT-Utils provides a builder class to faciliate the creation or loading of an RTStruct. From there you can add ROIs through masks and optinally input the colour of the region along with the name.

The format for the ROI mask is an nd numpy array. We expect an array of 2d binary masks, one plane for each slice location within the DICOM series. The slices should be sorted in ascending order within the mask. Through these masks, we extract the contours of the regions of interest and place them within the RTStruct file. Note that there is currently only support for the use of one frame of reference UID and structered set ROI sequence. Also note that holes within the ROI may be handled poorly.

Installation

pip install rt_utils

Creating new RTStructs

from rt_utils import RTStructBuilder

rtstruct = RTStructBuilder.create_new(dicom_series_path="./testlocation")
rtstruct.add_roi(mask=MASK_FROM_ML_MODEL, color=[255, 0, 255], name="RT-Utils ROI!")
rtstruct.save("test-rt-struct.dcm")

Loading existing RTStructs

from rt_utils import RTStructBuilder

rtstruct = RTStructBuilder.create_from(dicom_series_path="./testlocation", rt_struct_path="./testlocation/rt-struct.dcm")
rtstruct.add_roi(mask=MASK_FROM_ML_MODEL, color=[255, 0, 255], name="RT-Utils ROI!")
rtstruct.save("updated-rt-struct.dcm")

Results

The results of a generated ROI with a dummy mask, as viewed in Slicer.

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

rt-utils-0.0.4.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

rt_utils-0.0.4-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file rt-utils-0.0.4.tar.gz.

File metadata

  • Download URL: rt-utils-0.0.4.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for rt-utils-0.0.4.tar.gz
Algorithm Hash digest
SHA256 dfdf5967c40de01b1c8b40e0de0ec75b7a886cdcea3b51fb9fc3e43a125ef65c
MD5 dd87744b255a6887ee37ad94b0dc3c5d
BLAKE2b-256 4a4a2d3051f1d4ff4e58e6ac762fd47c2ec52df3039b811b6e04f3e4359c6a7b

See more details on using hashes here.

File details

Details for the file rt_utils-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: rt_utils-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for rt_utils-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 16955b590f6a4263f1924207f2b6206c37919573f348918c1eac516bc337d60f
MD5 62714893d7a3857c7ffb9c2a20cca136
BLAKE2b-256 51001a1f8da42aa0597146579a03c7c23b8ee54731cfe93d5546c746a4aaaa59

See more details on using hashes here.

Supported by

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