Skip to content

Commit d876c3f

Browse files
authored
Fix missing SegmentDescription in PydicomReader (#6937)
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 <[email protected]>
1 parent 37b58fc commit d876c3f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

monai/data/image_reader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ def _get_seg_data(self, img):
766766
all_segs = np.zeros([*spatial_shape, n_classes])
767767

768768
for i, (frames, description) in enumerate(self._get_frame_data(img)):
769-
class_name = description.SegmentDescription
769+
segment_label = getattr(description, "SegmentLabel", f"label_{i}")
770+
class_name = getattr(description, "SegmentDescription", segment_label)
770771
if class_name not in metadata["labels"].keys():
771772
metadata["labels"][class_name] = i
772773
class_num = metadata["labels"][class_name]

0 commit comments

Comments
 (0)