From 8606b27691c6cf4387279ee866761286c4513026 Mon Sep 17 00:00:00 2001 From: evamaxfield Date: Fri, 29 Jul 2022 09:02:24 -0700 Subject: [PATCH] Pass the buffer instead of the localfileopener to CZI --- aicsimageio/readers/czi_reader.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/aicsimageio/readers/czi_reader.py b/aicsimageio/readers/czi_reader.py index 47dde8ebc..adba89e2f 100644 --- a/aicsimageio/readers/czi_reader.py +++ b/aicsimageio/readers/czi_reader.py @@ -95,7 +95,7 @@ def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> boo ) with fs.open(path) as open_resource: - CziFile(open_resource) + CziFile(open_resource.f) return True except RuntimeError: @@ -144,7 +144,7 @@ def __init__( def mapped_dims(self) -> str: if self._mapped_dims is None: with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) self._mapped_dims = CziReader._fix_czi_dims(czi.dims) return self._mapped_dims @@ -161,7 +161,7 @@ def _fix_czi_dims(dims: str) -> str: def scenes(self) -> Tuple[str, ...]: if self._scenes is None: with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) xpath_str = "./Metadata/Information/Image/Dimensions/S/Scenes/Scene" meta_scenes = czi.meta.findall(xpath_str) scene_names: List[str] = [] @@ -318,7 +318,7 @@ def _get_image_data( # Init czi with fs.open(path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) # Get current scene read dims adjusted_scene_index = CziReader._adjust_scene_index( @@ -610,7 +610,7 @@ def _read_delayed(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) dims_shape = CziReader._dims_shape_to_scene_dims_shape( dims_shape=czi.get_dims_shape(), @@ -671,7 +671,7 @@ def _read_immediate(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) dims_shape = CziReader._dims_shape_to_scene_dims_shape( dims_shape=czi.get_dims_shape(), scene_index=self.current_scene_index, @@ -789,7 +789,7 @@ def _stitch_tiles( def _construct_mosaic_xarray(self, data: types.ArrayLike) -> xr.DataArray: # Get max of mosaic positions from lif with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) dims_shape = CziReader._dims_shape_to_scene_dims_shape( dims_shape=czi.get_dims_shape(), scene_index=self.current_scene_index, @@ -914,7 +914,7 @@ def get_mosaic_tile_position(self, mosaic_tile_index: int) -> Tuple[int, int]: # Get max of mosaic positions from lif with self._fs.open(self._path) as open_resource: - czi = CziFile(open_resource) + czi = CziFile(open_resource.f) bboxes = czi.get_all_mosaic_tile_bounding_boxes(S=self.current_scene_index) bbox = list(bboxes.values())[mosaic_tile_index]