def open_tiff(file: str, sktiff: bool) -> Tuple[Union[TiffFile, ScanImageTiffReader], int]: """ Returns image and its length from tiff file with either ScanImageTiffReader or tifffile, based on 'sktiff'""" if sktiff: tif = TiffFile(file) Ltif = len(tif.pages) else: tif = ScanImageTiffReader(file) Ltif = 1 if len(tif.shape()) < 3 else tif.shape()[0] # single page tiffs return tif, Ltif
def open_tiff(file, sktiff): """ opens tiff with either ScanImageTiffReader or tifffile returns tiff and its length """ if sktiff: tif = TiffFile(file) Ltif = len(tif.pages) else: tif = ScanImageTiffReader(file) tsize = tif.shape() if len(tsize) < 3: # single page tiffs Ltif = 1 else: Ltif = tif.shape()[0] return tif, Ltif