Skip to content

Commit

Permalink
Fix KeyError in PydicomReader (#6946)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
KumoLiu authored Sep 5, 2023
1 parent 8e77e03 commit c4ed1f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion monai/data/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def _get_affine(self, metadata: dict, lps_to_ras: bool = True):
# "00200032" is the tag of `ImagePositionPatient`
sx, sy, sz = metadata["00200032"]["Value"]
# "00280030" is the tag of `PixelSpacing`
spacing = metadata["00280030"]["Value"]
spacing = metadata["00280030"]["Value"] if "00280030" in metadata else (1.0, 1.0)
dr, dc = metadata.get("spacing", spacing)[:2]
affine[0, 0] = cx * dr
affine[0, 1] = rx * dc
Expand Down

0 comments on commit c4ed1f8

Please sign in to comment.