Skip to content

Commit

Permalink
Fix missing SegmentDescription in PydicomReader (#6937)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
KumoLiu authored Sep 4, 2023
1 parent 37b58fc commit d876c3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion monai/data/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ def _get_seg_data(self, img):
all_segs = np.zeros([*spatial_shape, n_classes])

for i, (frames, description) in enumerate(self._get_frame_data(img)):
class_name = description.SegmentDescription
segment_label = getattr(description, "SegmentLabel", f"label_{i}")
class_name = getattr(description, "SegmentDescription", segment_label)
if class_name not in metadata["labels"].keys():
metadata["labels"][class_name] = i
class_num = metadata["labels"][class_name]
Expand Down

0 comments on commit d876c3f

Please sign in to comment.