Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 0a69f0b

Browse files
authored
bugfix/fsspec-local-file-opener-cpp-buffer-for-czi (#425)
Pass the buffer instead of the localfileopener to CZI
1 parent c325ba2 commit 0a69f0b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

aicsimageio/readers/czi_reader.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> boo
9595
)
9696

9797
with fs.open(path) as open_resource:
98-
CziFile(open_resource)
98+
CziFile(open_resource.f)
9999
return True
100100

101101
except RuntimeError:
@@ -144,7 +144,7 @@ def __init__(
144144
def mapped_dims(self) -> str:
145145
if self._mapped_dims is None:
146146
with self._fs.open(self._path) as open_resource:
147-
czi = CziFile(open_resource)
147+
czi = CziFile(open_resource.f)
148148
self._mapped_dims = CziReader._fix_czi_dims(czi.dims)
149149

150150
return self._mapped_dims
@@ -161,7 +161,7 @@ def _fix_czi_dims(dims: str) -> str:
161161
def scenes(self) -> Tuple[str, ...]:
162162
if self._scenes is None:
163163
with self._fs.open(self._path) as open_resource:
164-
czi = CziFile(open_resource)
164+
czi = CziFile(open_resource.f)
165165
xpath_str = "./Metadata/Information/Image/Dimensions/S/Scenes/Scene"
166166
meta_scenes = czi.meta.findall(xpath_str)
167167
scene_names: List[str] = []
@@ -318,7 +318,7 @@ def _get_image_data(
318318

319319
# Init czi
320320
with fs.open(path) as open_resource:
321-
czi = CziFile(open_resource)
321+
czi = CziFile(open_resource.f)
322322

323323
# Get current scene read dims
324324
adjusted_scene_index = CziReader._adjust_scene_index(
@@ -610,7 +610,7 @@ def _read_delayed(self) -> xr.DataArray:
610610
The file could not be read or is not supported.
611611
"""
612612
with self._fs.open(self._path) as open_resource:
613-
czi = CziFile(open_resource)
613+
czi = CziFile(open_resource.f)
614614

615615
dims_shape = CziReader._dims_shape_to_scene_dims_shape(
616616
dims_shape=czi.get_dims_shape(),
@@ -671,7 +671,7 @@ def _read_immediate(self) -> xr.DataArray:
671671
The file could not be read or is not supported.
672672
"""
673673
with self._fs.open(self._path) as open_resource:
674-
czi = CziFile(open_resource)
674+
czi = CziFile(open_resource.f)
675675
dims_shape = CziReader._dims_shape_to_scene_dims_shape(
676676
dims_shape=czi.get_dims_shape(),
677677
scene_index=self.current_scene_index,
@@ -789,7 +789,7 @@ def _stitch_tiles(
789789
def _construct_mosaic_xarray(self, data: types.ArrayLike) -> xr.DataArray:
790790
# Get max of mosaic positions from lif
791791
with self._fs.open(self._path) as open_resource:
792-
czi = CziFile(open_resource)
792+
czi = CziFile(open_resource.f)
793793
dims_shape = CziReader._dims_shape_to_scene_dims_shape(
794794
dims_shape=czi.get_dims_shape(),
795795
scene_index=self.current_scene_index,
@@ -914,7 +914,7 @@ def get_mosaic_tile_position(self, mosaic_tile_index: int) -> Tuple[int, int]:
914914

915915
# Get max of mosaic positions from lif
916916
with self._fs.open(self._path) as open_resource:
917-
czi = CziFile(open_resource)
917+
czi = CziFile(open_resource.f)
918918

919919
bboxes = czi.get_all_mosaic_tile_bounding_boxes(S=self.current_scene_index)
920920
bbox = list(bboxes.values())[mosaic_tile_index]

0 commit comments

Comments
 (0)