Read
Functions relating to reading image files of different formats.
ReadFunc
Bases: Protocol
Protocol that defines the accepted function signature for "read functions".
Read functions take a file path and read image data into a numpy array.
The first argument MUST be named file_path and be type pathlib.Path, any number
of additional arguments of any type are allowed. The return type MUST be
numpy.typing.NDArray[Any]. For example:
get_read_func(data_type)
Get the read function for the data type.
Parameters:
-
data_type(SupportedData) –Data type.
Returns:
-
callable–Read function.
read_tiff(file_path, *args, **kwargs)
Read a tiff file and return a numpy array.
Parameters:
-
file_path(Path) –Path to a file.
-
*args(list, default:()) –Additional arguments.
-
**kwargs(dict, default:{}) –Additional keyword arguments.
Returns:
-
ndarray–Resulting array.
Raises:
-
ValueError–If the file failed to open.
-
OSError–If the file failed to open.
-
ValueError–If the file is not a valid tiff.
-
ValueError–If the data dimensions are incorrect.
-
ValueError–If the axes length is incorrect.