Skip to main content

Tools 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

This code provides functionality for turning dicom images and RT structures into nifti files as well as turning prediction masks back into RT structures

Installation guide

pip install DicomRTTool

Highly recommend to go through the jupyter notebook Data_Curation_and_Predictions_to_RT

Data_Curation_and_Predictions_to_RT has three main parts

Works on oblique images for masks and predictions*

1) Identify RT structures and names in multiple patients

2) Creating associations file and turning dicom into nifti/numpy files

3) Turning predictions into RT structures

If you find this code useful, please provide a reference to my github page for others www.github.com/brianmanderson , thank you!

Please consider using the .write_parallel if you have many patients
Ring update allows for multiple rings to be represented correctly

multiple_rings.png

Various utilities created to help with the interpretation of dicom images/RT Structures

RT Structure and dicom conversion to numpy arrays

This code is designed to receive an input path to a folder which contains both dicom images and a single RT structure file

For example, assume a folder exists with dicom files and an RT structure located at 'C:\users\brianmanderson\Patient_1\CT1' with the roi 'Liver'

Assume there are 100 images, the generated data will be: Dicom_Image.ArrayDicom is the image numpy array in the format [# images, rows, cols]

You can then call it to return a mask based on contour names called DicomImage.get_mask(), this takes in a list of Contour Names

You can see the available contour names with

Example:

from DicomRTTool import DicomReaderWriter
Dicom_reader = DicomReaderWriter(get_images_mask=False)
path = 'C:\users\brianmanderson\Patients\'
Dicom_reader.down_folder(path)
# See all rois in the folders
for roi in Dicom_reader.all_rois:
    print(roi)


Contour_Names = ['Liver']
associations = {'Liver_BMA_Program4':'Liver','Liver':'Liver'}
path = 'C:\users\brianmanderson\Patients\Patient_1\CT_1\'
Dicom_reader = DicomReaderWriter(get_images_mask=True, Contour_Names=Contour_Names, associations=associations)

Dicom_reader.Make_Contour_From_directory(path)
image = Dicom_reader.ArrayDicom
mask = Dicom_reader.mask

pred = np.zeros([mask.shape[0],mask.shape[1],mask.shape[2],2]) # prediction needs to be [# images, rows, cols, # classes]
pred[:,200:300,200:300,1] = 1

output_path= os.path.join('.','Output')
Dicom_reader.with_annotations(pred,output_path,ROI_Names=['test'])

'''
Write the images and annotations as niftii files in parallel!
'''
Dicom_Reader.write_parallel(out_path=export_path,excel_file=os.path.join('.','MRN_Path_To_Iteration.xlsx'))

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-0.1.11.tar.gz (616.4 kB view details)

Uploaded Source

Built Distribution

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

DicomRTTool-0.1.11-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file DicomRTTool-0.1.11.tar.gz.

File metadata

  • Download URL: DicomRTTool-0.1.11.tar.gz
  • Upload date:
  • Size: 616.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.5

File hashes

Hashes for DicomRTTool-0.1.11.tar.gz
Algorithm Hash digest
SHA256 800b7cedd915501030116847a968b313b25070bcc3a70d2b6ce59d315a8d2ae6
MD5 68871a54c39c4f73a256e1467223ec8d
BLAKE2b-256 04354596356ba13ee8dd0de1ac264d730ef159227aae4e96242102db9da28b49

See more details on using hashes here.

File details

Details for the file DicomRTTool-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: DicomRTTool-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.5

File hashes

Hashes for DicomRTTool-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 50f7e379c9eacd0ddd475e34aabe5e6f07a3272cdb1e3c2ad80e7f3e370a55bc
MD5 8088fa35f3a019a153a0600562eb6253
BLAKE2b-256 b8d0506075b2e48e63c3e6f622f2b04d71eccdca2edcbaa5aa5e9aff3851c07c

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