Metadata-Version: 2.1
Name: DicomRTTool
Version: 0.3.5
Summary: Tools for reading dicom files, RT structures, and dose files, as well as tools for converting numpy prediction masks back to an RT structure
Home-page: https://github.com/brianmanderson/Dicom_RT_and_Images_to_Mask
Author: Brian Mark Anderson
Author-email: bmanderson@mdanderson.org
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: opencv-python (==4.2.0.*)
Requires-Dist: openpyxl
Requires-Dist: pandas
Requires-Dist: Pillow
Requires-Dist: pydicom
Requires-Dist: scikit-image
Requires-Dist: scipy
Requires-Dist: SimpleITK
Requires-Dist: six
Requires-Dist: xlrd
Requires-Dist: check-manifest

# 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](./Images/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.ReaderWriter import DicomReaderWriter
    Dicom_reader = DicomReaderWriter(description='Example')
    path = 'C:\users\brianmanderson\Patients\'
    Dicom_reader.walk_through_folders(path)  # This will walk through all of the folders, and print the indexes for each series instance UID present

    all_rois = Dicom_reader.return_rois(print_rois=True)  # Return a list of all rois present, and print them



    Contour_Names = ['Liver']
    associations = {'Liver_BMA_Program4':'Liver','Liver':'Liver'}

    Dicom_reader.set_contour_names(Contour_Names)
    Dicom_reader.__set_associations__(associations)
    Dicom_reader.get_images_and_mask()

    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.prediction_array_to_RT(prediction_array=pred, output_dir=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'))



