diff --git a/aicsimageio/readers/nd2_reader.py b/aicsimageio/readers/nd2_reader.py index 53904f4fb..30670b646 100644 --- a/aicsimageio/readers/nd2_reader.py +++ b/aicsimageio/readers/nd2_reader.py @@ -6,7 +6,6 @@ from .. import constants, exceptions, types from ..utils import io_utils -from ..utils.dask_proxy import DaskArrayProxy from .reader import Reader if TYPE_CHECKING: @@ -16,7 +15,6 @@ try: import nd2 - from nd2._util import NEW_HEADER_MAGIC, OLD_HEADER_MAGIC except ImportError: raise ImportError( "The nd2 package is required for this reader. " @@ -42,8 +40,7 @@ class ND2Reader(Reader): @staticmethod def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> bool: - with fs.open(path, "rb") as fh: - return fh.read(4) in (NEW_HEADER_MAGIC, OLD_HEADER_MAGIC) + return nd2.is_supported_file(path, fs.open) def __init__(self, image: types.PathLike): self._fs, self._path = io_utils.pathlike_to_fs(image, enforce_exists=True) @@ -75,10 +72,8 @@ def _xarr_reformat(self, delayed: bool) -> xr.DataArray: xarr = rdr.to_xarray( delayed=delayed, squeeze=False, position=self.current_scene_index ) - if delayed: - xarr.data = DaskArrayProxy(xarr.data, rdr) xarr.attrs[constants.METADATA_UNPROCESSED] = xarr.attrs.pop("metadata") - return xarr.isel({nd2._util.AXIS.POSITION: 0}) + return xarr.isel({nd2.AXIS.POSITION: 0}) @property def physical_pixel_sizes(self) -> types.PhysicalPixelSizes: diff --git a/setup.py b/setup.py index 0bf876bac..dc8d7e59d 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def run(self): "imageio[ffmpeg]>=2.9.0,<2.11.0", "Pillow>=8.2.0,!=8.3.0,<9", ], - "nd2": ["nd2[legacy]==0.1.4"], + "nd2": ["nd2[legacy]>=0.2.0"], "dv": ["mrc>=0.2.0"], # "czi": ["aicspylibczi>=3.0.5"], # excluded for licensing reasons # "bioformats": ["bioformats_jar"], # excluded for licensing reasons