Skip to content

Commit c4ed1f8

Browse files
authored
Fix KeyError in PydicomReader (#6946)
Fixes #6945 . ### Description Try get "00280030" (PixelSpacing) 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 8e77e03 commit c4ed1f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

monai/data/image_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def _get_affine(self, metadata: dict, lps_to_ras: bool = True):
663663
# "00200032" is the tag of `ImagePositionPatient`
664664
sx, sy, sz = metadata["00200032"]["Value"]
665665
# "00280030" is the tag of `PixelSpacing`
666-
spacing = metadata["00280030"]["Value"]
666+
spacing = metadata["00280030"]["Value"] if "00280030" in metadata else (1.0, 1.0)
667667
dr, dc = metadata.get("spacing", spacing)[:2]
668668
affine[0, 0] = cx * dr
669669
affine[0, 1] = rx * dc

0 commit comments

Comments
 (0)