= 'data_examples/example_tiff.tiff'
file_path = aics_image_reader(file_path)
test_img, _ test_img.shape
I/O
ScalarImage
ScalarImage (*args, **kwargs)
Image whose pixel values represent scalars.
See :class:~torchio.Image
for more information.
Image Readers
tiff2torch
tiff2torch (file_path:str)
Load tiff into pytorch tensor
aics_image_reader
aics_image_reader (path)
*Reads an image from the specified path using AICSImage library.
Parameters: path (str): The file path to the image.
Returns: tuple: A tuple containing the image data and its affine transformation matrix. The image data is a NumPy array representing the image. The affine transformation matrix is a 4x4 NumPy array.*
Details | |
---|---|
path | The file path to the image |
Hierarchical Data Format
split_hdf_path
split_hdf_path (file_path, hdf5_exts:(<class'fastcore.foundation.L'>,<class'list'>)= ['.h5', '.hdf5'])
Type | Default | Details | |
---|---|---|---|
file_path | The path to the HDF5 file to split | ||
hdf5_exts | (<class ‘fastcore.foundation.L’>, <class ‘list’>) | [‘.h5’, ‘.hdf5’] | List of filename extensions |
hdf5_reader
hdf5_reader (dataset=None, patch=0, hdf5_exts:(<class'fastcore.foundation.L'>,<class'list'>)=['. h5', '.hdf5'])
Initialize self. See help(type(self)) for accurate signature.
Type | Default | Details | |
---|---|---|---|
dataset | NoneType | None | The dataset to load |
patch | int | 0 | The patch to load from the dataset |
hdf5_exts | (<class ‘fastcore.foundation.L’>, <class ‘list’>) | [‘.h5’, ‘.hdf5’] | List of filename extensions |
Images can be loaded by explicitly writing dataset name and path number…
from bioMONAI.visualize import plot_image
= './data_examples/0450_1.hdf5'
file_path ='clean'
dataset_name=10
patch_num
= hdf5_reader(dataset=dataset_name, patch=patch_num)(file_path)
im , _ 0]) plot_image(im[
… or enconding them in the path, where datasets are subfolders and patches the image files. The latter being compatible with image_reader
syntaxis.
= file_path + '/' + dataset_name + '/' + '%d'%(patch_num)
f = hdf5_reader()(f)
im , _ 0]) plot_image(im[
Preprocessing
Load and preprocess
= _load_and_preprocess(f)
org_img, _, _
0].shape, im.shape) test_eq(org_img.data[
Read multichannel data
= _multi_channel([f], only_tensor=True);
t 0].shape, im.shape) test_eq(t[
t.shape
Image reader
image_reader
image_reader (file_path:(<class'str'>,<class'pathlib.Path'>,<class'fastco re.foundation.L'>,<class'list'>), dtype=<class 'torch.Tensor'>, only_tensor:bool=True, **kwargs)
*Loads and preprocesses a medical image.
Args: file_path: Path to the image. Can be a string, Path object or a list. dtype: Datatype for the return value. Defaults to torchTensor. reorder: Whether to reorder the data to be closest to canonical (RAS+) orientation. Defaults to False. resample: Whether to resample image to different voxel sizes and image dimensions. Defaults to None. only_tensor: To return only an image tensor. Defaults to True.
Returns: The preprocessed image. Returns only the image tensor if only_tensor is True, otherwise returns original image, preprocessed image, and original size.*
Type | Default | Details | |
---|---|---|---|
file_path | (<class ‘str’>, <class ‘pathlib.Path’>, <class ‘fastcore.foundation.L’>, <class ‘list’>) | Path to the image | |
dtype | _TensorMeta | Tensor | Datatype for the return value. Defaults to torchTensor |
only_tensor | bool | True | To return only an image tensor |
kwargs |
0].shape, im.shape) test_eq(image_reader(f)[