def __init__(self, path, memmap_frames=False, verbose=False):
self.path = _ospath.abspath(path)
self.dir = _ospath.dirname(self.path)
base, ext = _ospath.splitext(_ospath.splitext(self.path)[0]) # split two extensions as in .ome.tif
base = _re.escape(base)
pattern = _re.compile(base + '_(\d*).ome.tif') # This matches the basename + an appendix of the file number
entries = [_.path for _ in _os.scandir(self.dir) if _.is_file()]
matches = [_re.match(pattern, _) for _ in entries]
matches = [_ for _ in matches if _ is not None]
paths_indices = [(int(_.group(1)), _.group(0)) for _ in matches]
self.paths = [self.path] + [path for index, path in sorted(paths_indices)]
self.maps = [TiffMap(path, verbose=verbose) for path in self.paths]
self.n_maps = len(self.maps)
self.n_frames_per_map = [_.n_frames for _ in self.maps]
self.n_frames = sum(self.n_frames_per_map)
self.cum_n_frames = _np.insert(_np.cumsum(self.n_frames_per_map), 0, 0)
self.dtype = self.maps[0].dtype
self.height = self.maps[0].height
self.width = self.maps[0].width
self.shape = (self.n_frames, self.height, self.width)
评论列表
文章目录