From d876c3f5212ab1511fd1720057aaf943dfdcd939 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:25:37 +0800 Subject: [PATCH] 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 - [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 --- monai/data/image_reader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monai/data/image_reader.py b/monai/data/image_reader.py index 9ccf79d163..0f8de6b57d 100644 --- a/monai/data/image_reader.py +++ b/monai/data/image_reader.py @@ -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]