From 0b2ea5ccd10e33332bc93d35dbdcb0b2c0910044 Mon Sep 17 00:00:00 2001 From: Vedat Baday Date: Fri, 9 Dec 2022 00:21:32 +0300 Subject: [PATCH 1/2] Change type of qto_xyz to ndarray --- monai/data/image_reader.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/monai/data/image_reader.py b/monai/data/image_reader.py index 66c41a1ba8..9027741aed 100644 --- a/monai/data/image_reader.py +++ b/monai/data/image_reader.py @@ -319,12 +319,14 @@ def _get_meta_dict(self, img) -> Dict: """ img_meta_dict = img.GetMetaDataDictionary() - meta_dict = {} - for key in img_meta_dict.GetKeys(): - if key.startswith("ITK_"): - continue - val = img_meta_dict[key] - meta_dict[key] = np.asarray(val) if type(val).__name__.startswith("itk") else val + meta_dict = { + key: img_meta_dict[key] + for key in img_meta_dict.GetKeys() + if not key.startswith("ITK_") + } + + if "qto_xyz" in meta_dict and not isinstance(meta_dict["qto_xyz"], np.ndarray): + meta_dict["qto_xyz"] = np.array(meta_dict["qto_xyz"]) meta_dict["spacing"] = np.asarray(img.GetSpacing()) return meta_dict From d9c8c9b6d12803d3c8375e3e7f2a65e787bea682 Mon Sep 17 00:00:00 2001 From: Vedat Baday Date: Fri, 9 Dec 2022 00:48:09 +0300 Subject: [PATCH 2/2] Reformat --- monai/data/image_reader.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/monai/data/image_reader.py b/monai/data/image_reader.py index 9027741aed..3ca08f863a 100644 --- a/monai/data/image_reader.py +++ b/monai/data/image_reader.py @@ -319,11 +319,7 @@ def _get_meta_dict(self, img) -> Dict: """ img_meta_dict = img.GetMetaDataDictionary() - meta_dict = { - key: img_meta_dict[key] - for key in img_meta_dict.GetKeys() - if not key.startswith("ITK_") - } + meta_dict = {key: img_meta_dict[key] for key in img_meta_dict.GetKeys() if not key.startswith("ITK_")} if "qto_xyz" in meta_dict and not isinstance(meta_dict["qto_xyz"], np.ndarray): meta_dict["qto_xyz"] = np.array(meta_dict["qto_xyz"])