Skip to content

Commit acf2cba

Browse files
resolve comments
Signed-off-by: Yiheng Wang <[email protected]>
1 parent 83a1daf commit acf2cba

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

monai/data/image_reader.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,24 @@
3737
from monai.utils import MetaKeys, SpaceKeys, TraceKeys, ensure_tuple, optional_import, require_pkg
3838

3939
if TYPE_CHECKING:
40-
import cupy as cp
4140
import itk
42-
import kvikio
4341
import nibabel as nib
4442
import nrrd
4543
import pydicom
4644
from nibabel.nifti1 import Nifti1Image
4745
from PIL import Image as PILImage
4846

49-
has_nrrd = has_itk = has_nib = has_pil = has_pydicom = has_cp = has_kvikio = True
47+
has_nrrd = has_itk = has_nib = has_pil = has_pydicom = True
5048
else:
5149
itk, has_itk = optional_import("itk", allow_namespace_pkg=True)
5250
nib, has_nib = optional_import("nibabel")
5351
Nifti1Image, _ = optional_import("nibabel.nifti1", name="Nifti1Image")
5452
PILImage, has_pil = optional_import("PIL.Image")
5553
pydicom, has_pydicom = optional_import("pydicom")
5654
nrrd, has_nrrd = optional_import("nrrd", allow_namespace_pkg=True)
57-
cp, has_cp = optional_import("cupy")
58-
kvikio, has_kvikio = optional_import("kvikio")
55+
56+
cp, has_cp = optional_import("cupy")
57+
kvikio, has_kvikio = optional_import("kvikio")
5958

6059
__all__ = ["ImageReader", "ITKReader", "NibabelReader", "NumpyReader", "PILReader", "PydicomReader", "NrrdReader"]
6160

@@ -905,7 +904,9 @@ def __init__(
905904
self.as_closest_canonical = as_closest_canonical
906905
self.squeeze_non_spatial_dims = squeeze_non_spatial_dims
907906
if to_gpu and (not has_cp or not has_kvikio):
908-
warnings.warn("NibabelReader: CuPy and/or Kvikio not installed for GPU loading, falling back to CPU loading.")
907+
warnings.warn(
908+
"NibabelReader: CuPy and/or Kvikio not installed for GPU loading, falling back to CPU loading."
909+
)
909910
to_gpu = False
910911

911912
self.to_gpu = to_gpu
@@ -948,7 +949,7 @@ def read(self, data: Sequence[PathLike] | PathLike, **kwargs):
948949
img_.append(img) # type: ignore
949950
return img_ if len(filenames) > 1 else img_[0]
950951

951-
def get_data(self, img) -> tuple[np.ndarray | cp.ndarray, dict]:
952+
def get_data(self, img) -> tuple[np.ndarray, dict]:
952953
"""
953954
Extract data array and metadata from loaded image and return them.
954955
This function returns two objects, first is numpy array of image data, second is dict of metadata.
@@ -960,7 +961,7 @@ def get_data(self, img) -> tuple[np.ndarray | cp.ndarray, dict]:
960961
img: a Nibabel image object loaded from an image file or a list of Nibabel image objects.
961962
962963
"""
963-
img_array: list[np.ndarray | cp.ndarray] = []
964+
img_array: list[np.ndarray] = []
964965
compatible_meta: dict = {}
965966

966967
for i, filename in zip(ensure_tuple(img), self.filenames):

0 commit comments

Comments
 (0)