From cafd3867e2455e66e652586279a43aa4f9a590c3 Mon Sep 17 00:00:00 2001 From: Dohyeon Lee Date: Wed, 17 Jul 2024 15:01:40 +0900 Subject: [PATCH] flexible tiling --- TCFile/TCFile_class.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TCFile/TCFile_class.py b/TCFile/TCFile_class.py index 28d0b5a..b9a3184 100644 --- a/TCFile/TCFile_class.py +++ b/TCFile/TCFile_class.py @@ -4,6 +4,7 @@ import h5py import warnings import hdf5plugin +import re def TCFile(tcfname:str, imgtype): if imgtype == '3D': @@ -185,12 +186,14 @@ def __getitem__(self, key: int) -> np.ndarray: data = np.zeros(self.data_shape, data_type) tile_count = get_data_attr('NumberOfTiles') - for tile_idx in range(tile_count): - tile_path = f'{data_path}/TILE_{tile_idx:03d}' + tile_path_list = [ p for p in tcf_io.keys() if re.match(r'^TILE_\d+$', p)] + tile_path_list.sort() + for p in tile_path_list: + tile_path = f'{data_path}/{p}' get_tile_attr = lambda attr_name: self.get_attr(tcf_io, tile_path, attr_name) sampling_step = get_tile_attr('SamplingStep') if sampling_step != 1: - # what?! I don't know why... ask to Tomocube + # what?! I don't know why... ask Tomocube continue offset = list(get_tile_attr(f'DataIndexOffsetPoint{axis}') for axis in ('Z', 'Y', 'X')[3-self.data_ndim:])