asldro.containers package¶
Submodules¶
asldro.containers.image module¶
Classes for image encapsulation Used to create a standard interface for ND images which can be instantiated with either NIFTI files or using numpy arrays
-
class
asldro.containers.image.
BaseImageContainer
(data_domain: str = 'SPATIAL_DOMAIN', image_type=None, metadata=None, **kwargs)¶ Bases:
abc.ABC
An abstract (interface) for an ND image. Defines a set of accessors :param data_domain: defines the data domain as SPATIAL_DOMAIN or INVERSE_DOMAIN (default is SPATIAL_DOMAIN) :param image_type: the image type. Must be one of: - REAL_IMAGE_TYPE - IMAGINARY_IMAGE_TYPE - MAGNITUDE_IMAGE_TYPE - PHASE_IMAGE_TYPE - COMPLEX_IMAGE_TYPE if this is not specified, it will be set to REAL_IMAGE_TYPE for scalar image dtypes and COMPLEX_IMAGE_TYPE for complex dtypes :param metadata: a metadata dictionary which is associated with the image data. This might contain, for example, timing parameters associated with the image acquisition.
-
abstract property
affine
¶ Return a 4x4 numpy array with the image affine transformation
-
abstract
as_nifti
() → asldro.containers.image.NiftiImageContainer¶ Return the image container as a NiftiImageContainer. If the container is already a NiftiImageContainer, return self
-
abstract
as_numpy
() → asldro.containers.image.NumpyImageContainer¶ Return the image container as a NumpyImageContainer. If the container is already a NumpyImageContainer, return self
-
clone
() → asldro.containers.image.BaseImageContainer¶ Makes a deep copy of all member variables in a new ImageContainer
-
abstract property
has_nifti
¶ Returns True if the image has an associated nifti container
-
abstract property
image
¶ Return the image data as a numpy array
-
property
metadata
¶ Get the metadata
-
abstract property
shape
¶ Returns the shape of the image [x, y, z, t, etc]
-
abstract property
space_units
¶ Uses the NIFTI header xyzt_units to extract the space units. Returns one of: ‘meter’ ‘mm’ ‘micron’
-
abstract property
time_step_seconds
¶ Return the time step in seconds
-
abstract property
time_units
¶ Uses the NIFTI header xyzt_units to extract the time units. Returns one of: ‘sec’ ‘msec’ ‘usec’
-
abstract property
voxel_size_mm
¶ Returns the voxel size in mm
-
abstract property
-
class
asldro.containers.image.
NiftiImageContainer
(nifti_img: Union[nibabel.Nifti1Image, nibabel.Nifti2Image] = None, **kwargs)¶ Bases:
asldro.containers.image.BaseImageContainer
A container for an ND image. Must be initialised with a nibabel Nifti1Image or Nifti2Image
-
property
affine
¶ Return a 4x4 numpy array with the image affine transformation
-
as_nifti
() → asldro.containers.image.NiftiImageContainer¶ Returns self
-
as_numpy
() → asldro.containers.image.NumpyImageContainer¶ Return the NiftiImageContainer as a NumpyImageContainer.
-
property
has_nifti
¶ Returns True if the image has an associated nifti container
-
property
header
¶ Returns the NIFTI header if initialised from a NIFTI file, othewise returns None
-
property
image
¶ Return the image data as a numpy array. Returns data in the type it is created (i.e. won’t convert to float64 as .get_fdata() will)
-
property
nifti_type
¶ Return the type of NIFTI data contained here (nib.Nifti1Image or nib.Nifti2Image)
-
property
shape
¶ Returns the shape of the image [x, y, z, t, etc]
-
property
space_units
¶ Uses the NIFTI header xyzt_units to extract the space units. Returns one of: ‘meter’ ‘mm’ ‘micron’
-
property
time_step_seconds
¶ Return the time step in seconds
-
property
time_units
¶ Uses the NIFTI header xyzt_units to extract the time units. Returns one of: ‘sec’ ‘msec’ ‘usec’
-
property
voxel_size_mm
¶ Returns the voxel size in mm
-
property
-
class
asldro.containers.image.
NumpyImageContainer
(image: numpy.ndarray, affine: numpy.ndarray = numpy.eye, space_units: str = 'mm', time_units: str = 'sec', voxel_size=numpy.array, time_step=1.0, **kwargs)¶ Bases:
asldro.containers.image.BaseImageContainer
A container for an ND image. Must be initialised with a a numpy array and some associated metadata.
-
property
affine
¶ Return a 4x4 numpy array with the image affine transformation
-
as_nifti
() → asldro.containers.image.NiftiImageContainer¶ Return the NumpyImageContainer as a NiftiImageContainer.
-
as_numpy
() → asldro.containers.image.NumpyImageContainer¶ Returns self
-
property
has_nifti
¶ Returns True if the image has an associated nifti container
-
property
header
¶ Returns the NIFTI header if initialised from a NIFTI file, othewise returns None
-
property
image
¶ Return the image data as a numpy array
-
property
shape
¶ Returns the shape of the image [x, y, z, t, etc]
-
property
space_units
¶ Uses the NIFTI header xyzt_units to extract the space units. Returns one of: ‘meter’ ‘mm’ ‘micron’
-
property
time_step_seconds
¶ Return the time step in seconds
-
property
time_units
¶ Uses the NIFTI header xyzt_units to extract the time units. Returns one of: ‘sec’ ‘msec’ ‘usec’
-
property
voxel_size_mm
¶ Returns the voxel size in mm
-
property