Data input and output
Dealing with volumetric data can be done by fibretracker
for the most common image formats available.
Currently, it is possible to directly load tiff
, h5
, nii
,txm
and common PIL
formats using one single function.
fibretracker.io
fibretracker.io.load
load(path, dataset_name=None, return_metadata=False, contains=None, force_load=False, dim_order=(2, 1, 0), **kwargs)
Load data from the specified file or directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or PathLike
|
The path to the file or directory. |
required |
dataset_name |
str
|
Specifies the name of the dataset to be loaded in case multiple dataset exist within the same file. Default is None (only for HDF5 files) |
None
|
return_metadata |
bool
|
Specifies whether to return metadata or not. Default is False (only for HDF5 and TXRM/TXM/XRM files) |
False
|
contains |
str
|
Specifies a part of the name that is common for the TIFF file stack to be loaded (only for TIFF stacks). Default is None. |
None
|
force_load |
bool
|
If the file size exceeds available memory, a MemoryError is raised. If force_load is True, the error is changed to warning and the loader tries to load it anyway. Default is False. |
False
|
dim_order |
tuple
|
The order of the dimensions in the volume for .vol files. Default is (2,1,0) which corresponds to (z,y,x) |
(2, 1, 0)
|
**kwargs |
Additional keyword arguments to be passed |
{}
|
Returns:
Name | Type | Description |
---|---|---|
vol |
ndarray
|
The loaded volume
If |
Raises:
Type | Description |
---|---|
MemoryError
|
if the given file size exceeds available memory |
Example
Source code in fibretracker/io/read_file.py
fibretracker.io.normalize
Normalize the volume to the range [0, 1] using min-max scaling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The volume to normalize. |
required |
Returns:
Name | Type | Description |
---|---|---|
norm_vol |
ndarray
|
The normalized volume. |