7.1.1. algotom.io.converter
¶
Module for converting data type:
Convert a list of tif files to a hdf/nxs file.
Extract tif images from a hdf/nxs file.
Emulate an HDF5-like interface for TIF files in a folder.
Functions:
|
Convert a folder of tif files to a hdf/nxs file. |
|
Extract tif images from a hdf/nxs file. |
- algotom.io.converter.convert_tif_to_hdf(input_path, output_path, key_path='entry/data', crop=(0, 0, 0, 0), pattern=None, **options)[source]¶
Convert a folder of tif files to a hdf/nxs file.
- Parameters
input_path (str) – Folder path to the tif files.
output_path (str) – Path to the hdf/nxs file.
key_path (str, optional) – Key path to the dataset.
crop (tuple of int, optional) – Crop the images from the edges, i.e. crop = (crop_top, crop_bottom, crop_left, crop_right).
pattern (str, optional) – Used to find tif files with names matching the pattern.
options (dict, optional) – Add metadata. E.g options={“entry/angles”: angles, “entry/energy”: 53}.
- Returns
str – Path to the hdf/nxs file.
- algotom.io.converter.extract_tif_from_hdf(input_path, output_path, key_path, index=(0, -1, 1), axis=0, crop=(0, 0, 0, 0), prefix='img')[source]¶
Extract tif images from a hdf/nxs file.
- Parameters
input_path (str) – Path to the hdf/nxs file.
output_path (str) – Output folder.
key_path (str) – Key path to the dataset in the hdf/nxs file.
index (tuple of int or int.) – Indices of extracted images. A tuple corresponds to (start,stop,step).
axis (int) – Axis which the images are extracted.
crop (tuple of int, optional) – Crop the images from the edges, i.e. crop = (crop_top, crop_bottom, crop_left, crop_right).
prefix (str, optional) – Prefix of names of tif files.
- Returns
str – Folder path to the tif files.
- class algotom.io.converter.HdfEmulatorFromTif(folder_path, ncore=1)[source]¶
Bases:
object
Emulate an HDF5-like interface for TIF files in a folder, allowing indexed and sliced data access.
- Parameters
folder_path (str) – Path to the folder containing TIFF files.
ncore (int, optional) – Number of cores to use for parallel processing. The default is 1 (sequential processing).
Examples
>>> hdf_emulator = HdfEmulatorFromTif('C:/path/to/tif/files', ncore=4) >>> print(hdf_emulator.shape) >>> last_image = hdf_emulator[-1] >>> image_stack = hdf_emulator[:, 0:4, :]
- property shape¶
- property dtype¶