Skip to content

Commit

Permalink
fix bug reading dragonfly acquisitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ieivanov committed Apr 2, 2024
1 parent 0c6984e commit b9737eb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions iohub/mmstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from numpy.typing import ArrayLike
from tifffile import TiffFile
from xarray import DataArray
from natsort import natsorted

from iohub.mm_fov import MicroManagerFOV, MicroManagerFOVMapping

Expand Down Expand Up @@ -126,6 +127,7 @@ def _parse_data(self):
self._store = series.aszarr()
_logger.debug(f"Opened {self._store}.")
data = da.from_zarr(zarr.open(self._store))
data = data[:self.positions] # not all positions may have been acquires
self.dtype = data.dtype
img = DataArray(data, dims=raw_dims, name=self.dirname)
xarr = img.expand_dims(
Expand All @@ -150,7 +152,7 @@ def xdata(self):
return self._xdata

def __len__(self) -> int:
return self.positions
return len(self.xdata.keys())

def __getitem__(self, key: str | int) -> MMOmeTiffFOV:
key = _normalize_mm_pos_key(key)
Expand Down Expand Up @@ -218,15 +220,14 @@ def _set_mm_meta(self, mm_meta: dict) -> None:
mm_version == "2.0.1 20220920"
and self._mm_meta["Summary"]["Prefix"] == "raw_data"
):
file_names = set(
[(key[0], val[0]) for key, val in self.coord_map.items()]
)
files = natsorted(self.root.glob("*.ome.tif"))
self.positions = len(files) # not all positions are saved

if self._mm_meta["Summary"]["Positions"] > 1:
self._stage_positions = [None] * self.positions

for p_idx, file_name in file_names:
site_idx = int(file_name.split("_")[-1].split("-")[0])
for p_idx, file_name in enumerate(files):
site_idx = int(str(file_name).split("_")[-1].split("-")[0])
pos = self._simplify_stage_position(
self._mm_meta["Summary"]["StagePositions"][site_idx]
)
Expand Down

0 comments on commit b9737eb

Please sign in to comment.