Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get an error when reading dicom segmentation #6928

Closed
binliunls opened this issue Sep 2, 2023 · 3 comments · Fixed by #6937
Closed

Get an error when reading dicom segmentation #6928

binliunls opened this issue Sep 2, 2023 · 3 comments · Fixed by #6937
Labels
bug Something isn't working

Comments

@binliunls
Copy link
Contributor

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.

@binliunls
Copy link
Contributor Author

cc @SachidanandAlle , @tangy5 for reference.

@wyli
Copy link
Contributor

wyli commented Sep 2, 2023

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

@wyli wyli added the bug Something isn't working label Sep 2, 2023
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Sep 4, 2023
Signed-off-by: KumoLiu <yunl@nvidia.com>
@KumoLiu
Copy link
Contributor

KumoLiu commented Sep 4, 2023

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

@wyli wyli closed this as completed in #6937 Sep 4, 2023
wyli pushed a commit that referenced this issue Sep 4, 2023
Fixes #6928.

### Description

`SegmentDescription` is optional,
https://dicom.innolitics.com/ciods/segmentation/segmentation-image/00620002/00620006,
so try
[`SegmentLabel`](https://dicom.innolitics.com/ciods/segmentation/segmentation-image/00620002/00620005)
first.



### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: KumoLiu <yunl@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants