Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions monai/data/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,22 @@ def _get_affine(self, metadata: dict, lps_to_ras: bool = True):
metadata: metadata with dict type.
lps_to_ras: whether to convert the affine matrix from "LPS" to "RAS". Defaults to True.

Warns:
UserWarning: when ImageOrientationPatient (00200037) or ImagePositionPatient
(00200032) is missing from metadata. The affine matrix is set to identity,
which may be incorrect. Common with multiframe DICOM files.

"""
affine: np.ndarray = np.eye(4)
if not ("00200037" in metadata and "00200032" in metadata):
warnings.warn(
"PydicomReader: ImageOrientationPatient (00200037) or "
"ImagePositionPatient (00200032) not found in DICOM metadata. "
"The affine matrix will be set to identity, which may be incorrect. "
"This commonly occurs with multiframe DICOM files (e.g., Enhanced CT). "
"Consider using ITKReader for accurate spatial metadata.",
stacklevel=2,
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return affine
# "00200037" is the tag of `ImageOrientationPatient`
rx, ry, rz, cx, cy, cz = metadata["00200037"]["Value"]
Expand Down
Loading