Skip to content

Get an error when reading dicom segmentation #6928

Closed

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.

Activity

  1. binliunls commented on Sep 2, 2023

    @binliunls
    ContributorAuthor

    cc @SachidanandAlle , @tangy5 for reference.

  2. wyli commented on Sep 2, 2023

    @wyli
    Contributor

    it seems SegmentLabel is a required attribute and SegmentDescription is optional, perhaps the logic should be try SegmentLabel first

  3. added
    bugSomething isn't working
    on Sep 2, 2023
  4. added a commit that references this issue on Sep 4, 2023
    64c3321
  5. KumoLiu commented on Sep 4, 2023

    @KumoLiu
    Contributor

    Not sure whether SegmentLabel is unique here for frames otherwise we need to specify something like flabel_{i} here.

  6. added a commit that references this issue on Sep 4, 2023
    d876c3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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