niftynet.io.image_type module¶
This module defines images used by image reader, image properties are set by user or read from image header.
-
class
niftynet.io.image_type.
DataFromFile
(file_path, name='loadable_data')¶ Bases:
niftynet.io.image_type.Loadable
Data from file should have a valid file path (are files on hard drive) and a name
-
dtype
¶ data type property of the input images :return: a tuple of input image data types
len(self.dtype) == len(self.file_path)
-
file_path
¶ A tuple of valid image filenames, this property always returns a tuple, length of the tuple is one for single image, length of the tuple is larger than one for single image from multiple files. :return: a tuple of file paths
-
get_data
()¶
-
name
¶ A tuple of image names, this property always returns a tuple, length of the tuple is one for single image, length of the tuple is larger than one for single image from multiple files. :return: a tuple of image name tags
-
-
class
niftynet.io.image_type.
ImageFactory
¶ Bases:
object
Create image instance according to number of dimensions specified in image headers
-
INSTANCE_DICT
= {2: <class 'niftynet.io.image_type.SpatialImage2D'>, 3: <class 'niftynet.io.image_type.SpatialImage3D'>, 4: <class 'niftynet.io.image_type.SpatialImage4D'>, 5: <class 'niftynet.io.image_type.SpatialImage5D'>}¶
-
classmethod
create_instance
(file_path, **kwargs)¶ Read image headers and create image instance :param file_path: a file path or a sequence of file paths :param kwargs: output properties for transforming the image data
array into a desired formatReturns: an image instance
-
-
class
niftynet.io.image_type.
Loadable
¶ Bases:
object
interface of loadable data
-
get_data
()¶ loads a numpy array from the image object if the array has less than 5 dimensions it extends the array to 5d (corresponding to 3 spatial dimensions, temporal dim, modalities) ndims > 5 not currently supported
-
-
class
niftynet.io.image_type.
SpatialImage2D
(file_path, name, interp_order, output_pixdim, output_axcodes)¶ Bases:
niftynet.io.image_type.DataFromFile
2D images, axcodes specifications are ignored when loading. (Resampling to new pixdims is currently not supported)
-
get_data
()¶
-
interp_order
¶ interpolation order specified by user :return: a tuple of integers, with each element as an interpolation order of an image file
-
original_affine
¶ affine info from the image header :return: a tuple of affine, with each element as an affine matrix of an image file
-
original_axcodes
¶ axcodes info from the image header more info: http://nipy.org/nibabel/image_orientation.html :return: a tuple of axcodes, with each element as axcodes of an image file
-
original_pixdim
¶ pixdim info from the image header :return: a tuple of pixdims, with each element as pixdims of an image file
-
output_axcodes
¶ output axcodes info specified by user set to None for using the original axcodes in image header, otherwise get_data() change axes of the image array according to this value :return: a tuple of pixdims, with each element as pixdims of an image file
-
output_pixdim
¶ output pixdim info specified by user set to None for using the original pixdim in image header otherwise get_data() transforms image array according to this value :return: a tuple of pixdims, with each element as pixdims of an image file
-
shape
¶ This function read image shape info from the headers The lengths in the fifth dim of multiple images are summed as a multi-mod representation. The fourth dim corresponding to different time sequences is ignored. :return: a tuple of integers as image shape
-
-
class
niftynet.io.image_type.
SpatialImage3D
(file_path, name, interp_order, output_pixdim, output_axcodes)¶ Bases:
niftynet.io.image_type.SpatialImage2D
3D image from a single, supports resampling and reorientation (3D image from a set of 2D slices is currently not supported)
-
get_data
()¶
-
output_axcodes
¶
-
output_pixdim
¶
-
shape
¶
-
-
class
niftynet.io.image_type.
SpatialImage4D
(file_path, name, interp_order, output_pixdim, output_axcodes)¶ Bases:
niftynet.io.image_type.SpatialImage3D
4D image from a set of 3D volumes, supports resampling and reorientation
The 3D volumes are concatenated in the fifth dim (modality dim) (4D image from a single file is currently not supported)
-
get_data
()¶
-
-
class
niftynet.io.image_type.
SpatialImage5D
(file_path, name, interp_order, output_pixdim, output_axcodes)¶ Bases:
niftynet.io.image_type.SpatialImage3D
5D image from a single file, resampling and reorientation are implemented as operations on each 3D slice individually
(5D image from a set of 4D files is currently not supported)
-
get_data
()¶
-