11from __future__ import annotations
22
3- import io
4- import json
53import logging
64from copy import copy
75from pathlib import Path
86from typing import TYPE_CHECKING , Iterable
97from warnings import catch_warnings , filterwarnings
108
119import dask .array as da
12- import fsspec
1310import numpy as np
1411import zarr
15- import zarr .storage
1612from natsort import natsorted
1713from numpy .typing import ArrayLike
18- from tifffile import TiffFile , ZarrTiffStore
14+ from tifffile import TiffFile
1915from xarray import DataArray
2016
2117from iohub .mm_fov import MicroManagerFOV , MicroManagerFOVMapping
@@ -35,34 +31,6 @@ def _normalize_mm_pos_key(key: str | int) -> int:
3531 raise TypeError ("Micro-Manager position keys must be integers." )
3632
3733
38- def _tiff_to_fsspec_store (
39- zarr_tiff_store : ZarrTiffStore , root_uri : str
40- ) -> zarr .storage .FsspecStore :
41- """Bridge tifffile (zarr-python v2 interface) with zarr-python v3.
42-
43- Parameters
44- ----------
45- zarr_tiff_store : ZarrTiffStore
46- Zarr (v2) wrapper for a TIFF series
47- root_uri : str
48- `file://` URI to the directory containing the TIFF files
49-
50- Returns
51- -------
52- zarr.storage.FsspecStore
53- Zarr (v3) wrapper for a TIFF series
54- """
55- spec_container = io .StringIO ()
56- zarr_tiff_store .write_fsspec (spec_container , url = root_uri )
57- fs , _ = fsspec .url_to_fs (
58- "reference://" ,
59- fo = json .loads (spec_container .getvalue ()),
60- target_protocol = "file" ,
61- asynchronous = True ,
62- )
63- return zarr .storage .FsspecStore (fs = fs )
64-
65-
6634def find_first_ome_tiff_in_mmstack (data_path : Path ) -> Path :
6735 if data_path .is_file ():
6836 if "ome.tif" in data_path .name :
@@ -152,10 +120,8 @@ def _parse_data(self):
152120 self .width ,
153121 ) = dims .values ()
154122 self ._set_mm_meta (self ._first_tif .micromanager_metadata )
155- zarr_tiff_store = series .aszarr (multiscales = True )
156- self ._store = _tiff_to_fsspec_store (
157- zarr_tiff_store , root_uri = self ._root .as_uri ()
158- )
123+ # tifffile.zarr.ZarrTiffStore is a native zarr v3 store
124+ self ._store = series .aszarr (multiscales = True )
159125 _logger .debug (f"Opened { self ._store } ." )
160126 data = da .from_zarr (zarr .open (self ._store , mode = "r" )["0" ])
161127 self .dtype = data .dtype
0 commit comments