Skip to content

Commit

Permalink
Merge pull request #192 from nel-lab/lazy-tiff-changes
Browse files Browse the repository at this point in the history
allow manually setting shape
  • Loading branch information
kushalkolar committed Apr 5, 2023
2 parents 5bb418b + b8e9eb1 commit 59fa5ae
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions mesmerize_core/arrays/_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class LazyTiff(LazyArray):
def __init__(self, path: Union[Path, str]):
def __init__(self, path: Union[Path, str], shape: Tuple[int] = None):
"""
Lazy reader for tiff files. WIP, works for some tiff files.
Try ``tifffile.memmap`` first before trying ``LazyTiff``
Expand All @@ -18,18 +18,25 @@ def __init__(self, path: Union[Path, str]):
----------
path: str or Path
path to tiff file
shape: Tuple[int]
manually set shape
"""

self._tif = tifffile.TiffFile(path)
tiffseries = self._tif.series[0].levels[0]

# TODO: someone who's better with tiff can help on this
if len(self._tif.pages) == 1:
n_frames = len(self._tif.series)
if shape is None:
# TODO: someone who's better with tiff can help on this
if len(self._tif.pages) == 1:
n_frames = len(self._tif.series)
else:
n_frames = len(self._tif.pages)

self._shape = (n_frames, *tiffseries.shape)
else:
n_frames = len(self._tif.pages)
self._shape = shape

self._shape = (n_frames, *tiffseries.shape)
self._dtype = tiffseries.dtype.name

@property
Expand Down

0 comments on commit 59fa5ae

Please sign in to comment.