qurit / rt-utils

A minimal Python library to facilitate the creation and manipulation of DICOM RTStructs.
MIT License
191 stars 56 forks source link

Creating contour sequences with SOPInstanceUID instead of using the MediaStorageSOPInstanceUID #34

Closed smichi23 closed 2 years ago

smichi23 commented 2 years ago

Hi,

First of all, you did an impressive work on this package!

I simply wanted to ask if there was a specific reason behind building the contour sequence around the MediaStorageSOPInstanceUID.

If not, adding an optional argument in order to switch between MediaStorageSOPInstanceUID and SOPInstanceUID could maybe be useful for users.

To give you additional context, here is small change I had to do in order to be able to add a new contour to an existing RTSTRUCT file with respect to the original structure.

In ds_helper.py

def create_contour_image_sequence(series_data) -> Sequence: contour_image_sequence = Sequence()

# Add each referenced image
for series in series_data:
    contour_image = Dataset()
    contour_image.ReferencedSOPClassUID = series.file_meta.MediaStorageSOPClassUID
    contour_image.ReferencedSOPInstanceUID = series.file_meta.MediaStorageSOPInstanceUID
    contour_image_sequence.append(contour_image)
return contour_image_sequence

became

def create_contour_image_sequence(series_data) -> Sequence: contour_image_sequence = Sequence()

# Add each referenced image
for series in series_data:
    contour_image = Dataset()
    contour_image.ReferencedSOPClassUID = series.SOPClassUID
    contour_image.ReferencedSOPInstanceUID = series.SOPInstanceUID
    contour_image_sequence.append(contour_image)
return contour_image_sequence

Thank you again for this amazing work!

asim-shrestha commented 2 years ago

Hi @smichi23 thank you for your kind words and for going ahead and making a pull request! I will take a deeper look at it all by Friday and hopefully get it pushed in :)

Lets carry this conversation there as well