Skip to content

Commit

Permalink
Pass the buffer instead of the localfileopener to CZI
Browse files Browse the repository at this point in the history
  • Loading branch information
evamaxfield committed Jul 29, 2022
1 parent c325ba2 commit 8606b27
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions aicsimageio/readers/czi_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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] = []
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 8606b27

Please sign in to comment.