diff --git a/monai/data/image_reader.py b/monai/data/image_reader.py index a85eb95c20..653078c5a4 100644 --- a/monai/data/image_reader.py +++ b/monai/data/image_reader.py @@ -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, + ) return affine # "00200037" is the tag of `ImageOrientationPatient` rx, ry, rz, cx, cy, cz = metadata["00200037"]["Value"]