From d8bacb937bd03b77c763277e815825510c787f90 Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Thu, 11 Aug 2022 15:01:45 +0800 Subject: [PATCH 1/2] [DLMED] enhance docstring Signed-off-by: Nic Ma --- monai/transforms/io/array.py | 4 ++++ monai/transforms/io/dictionary.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/monai/transforms/io/array.py b/monai/transforms/io/array.py index dc43475b63..21920460a3 100644 --- a/monai/transforms/io/array.py +++ b/monai/transforms/io/array.py @@ -99,6 +99,10 @@ class LoadImage(Transform): - Current default readers: (nii, nii.gz -> NibabelReader), (png, jpg, bmp -> PILReader), (npz, npy -> NumpyReader), (nrrd -> NrrdReader), (DICOM file -> ITKReader). + Please note that for png, jpg, bmp format images, `PILReader` will swap axis 0 and 1 after + loading the array because the `HW` definition for non-medical specific file formats in PIL is + different from other common medical packages. + See also: - tutorial: https://github.com/Project-MONAI/tutorials/blob/master/modules/load_medical_images.ipynb diff --git a/monai/transforms/io/dictionary.py b/monai/transforms/io/dictionary.py index 761c891e85..c08f74035b 100644 --- a/monai/transforms/io/dictionary.py +++ b/monai/transforms/io/dictionary.py @@ -51,6 +51,10 @@ class LoadImaged(MapTransform): - Current default readers: (nii, nii.gz -> NibabelReader), (png, jpg, bmp -> PILReader), (npz, npy -> NumpyReader), (dcm, DICOM series and others -> ITKReader). + Please note that for png, jpg, bmp format images, `PILReader` will swap axis 0 and 1 after + loading the array because the `HW` definition for non-medical specific file formats in PIL is + different from other common medical packages. + Note: - If `reader` is specified, the loader will attempt to use the specified readers and the default supported From a9dec87e52ff5abf3a9b862ca34d06ae300975fa Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Thu, 11 Aug 2022 19:04:11 +0800 Subject: [PATCH 2/2] [DLMED] update according to comments Signed-off-by: Nic Ma --- monai/transforms/io/array.py | 6 +++--- monai/transforms/io/dictionary.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monai/transforms/io/array.py b/monai/transforms/io/array.py index 21920460a3..5ee17e6268 100644 --- a/monai/transforms/io/array.py +++ b/monai/transforms/io/array.py @@ -99,9 +99,9 @@ class LoadImage(Transform): - Current default readers: (nii, nii.gz -> NibabelReader), (png, jpg, bmp -> PILReader), (npz, npy -> NumpyReader), (nrrd -> NrrdReader), (DICOM file -> ITKReader). - Please note that for png, jpg, bmp format images, `PILReader` will swap axis 0 and 1 after - loading the array because the `HW` definition for non-medical specific file formats in PIL is - different from other common medical packages. + Please note that for png, jpg, bmp, and other 2D formats, readers often swap axis 0 and 1 after + loading the array because the `HW` definition for non-medical specific file formats is different + from other common medical packages. See also: diff --git a/monai/transforms/io/dictionary.py b/monai/transforms/io/dictionary.py index c08f74035b..a1f088b498 100644 --- a/monai/transforms/io/dictionary.py +++ b/monai/transforms/io/dictionary.py @@ -51,9 +51,9 @@ class LoadImaged(MapTransform): - Current default readers: (nii, nii.gz -> NibabelReader), (png, jpg, bmp -> PILReader), (npz, npy -> NumpyReader), (dcm, DICOM series and others -> ITKReader). - Please note that for png, jpg, bmp format images, `PILReader` will swap axis 0 and 1 after - loading the array because the `HW` definition for non-medical specific file formats in PIL is - different from other common medical packages. + Please note that for png, jpg, bmp, and other 2D formats, readers often swap axis 0 and 1 after + loading the array because the `HW` definition for non-medical specific file formats is different + from other common medical packages. Note: