Skip to content

Get an error when reading dicom segmentation #6928

@binliunls

Description

@binliunls

Describe the bug
When I tried to read the dicom segmentation label with LoadImage in MONAI transforms, it reported a bug shown below.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/venv/lib/python3.11/site-packages/monai/transforms/io/array.py", line 290, in __call__
    img_array, meta_data = reader.get_data(img)
                           ^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/monai/data/image_reader.py", line 586, in get_data
    data_array, metadata = self._get_seg_data(d)
                           ^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/monai/data/image_reader.py", line 770, in _get_seg_data
    class_name = description.SegmentDescription
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pydicom/dataset.py", line 908, in __getattr__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Dataset' object has no attribute 'SegmentDescription'

To Reproduce
Steps to reproduce the behavior:

  1. Install the MONAI main branch.
  2. Download the attachment dcm file whose md5 is f511acb750076c56ad2d9647dcfe521d.
  3. Run command python -c "from monai.transforms import LoadImage; loader = LoadImage(reader='pydicomreader'); loader('./SE000000.dcm');"
  4. If I changed this line to class_name = description.SegmentDescription if hasattr(description, "SegmentDescription") else description.SegmentLabel, it works. However I am not sure if this modification is good enough.

Expected behavior
Read segmentation correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions