qurit / rt-utils

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

AttributeError: 'Dataset' object has no attribute 'ContourImageSequence' #49

Closed JunMa11 closed 2 years ago

JunMa11 commented 2 years ago

Hi,

Thanks for sharing the great package.

I'm using the following code to load RT annotations.

rtstruct = RTStructBuilder.create_from(
  dicom_series_path=r"path to \Export_Case\CT", 
  rt_struct_path=r"path to\lung.dcm"
)
print(rtstruct.get_roi_names())
for name in rtstruct.get_roi_names():
    mask_3d = rtstruct.get_roi_mask_by_name(name).astype(np.uint8)

It can output the roi_names, but encounter the following error

['Lungs 1000 intensity threshold', 'Heart']
Traceback (most recent call last):

  File ".\utils.py", line 40, in <module>
    mask_3d = rtstruct.get_roi_mask_by_name(name).astype(np.uint8)

  File "D:\ProgramData\Anaconda3\lib\site-packages\rt_utils\rtstruct.py", line 113, in get_roi_mask_by_name
    return image_helper.create_series_mask_from_contour_sequence(

  File "D:\ProgramData\Anaconda3\lib\site-packages\rt_utils\image_helper.py", line 246, in create_series_mask_from_contour_sequence
    slice_contour_data = get_slice_contour_data(series_slice, contour_sequence)

  File "D:\ProgramData\Anaconda3\lib\site-packages\rt_utils\image_helper.py", line 259, in get_slice_contour_data
    for contour_image in contour.ContourImageSequence:

  File "D:\ProgramData\Anaconda3\lib\site-packages\pydicom\dataset.py", line 835, in __getattr__
    return object.__getattribute__(self, name)

AttributeError: 'Dataset' object has no attribute 'ContourImageSequence'

How can I fix this problem? Any comments would be highly appreciated:)

Best regards, Jun