NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Previous topic

neurospin.group.spatial_relaxation_onesample

This Page

neurospin.image.image

Module: neurospin.image.image

Inheritance diagram for nipy.neurospin.image.image:

Classes

Image

class nipy.neurospin.image.image.Image(obj, affine=None, world=None, background=0)

Bases: object

Image class.

An image is a real-valued mapping from a regular 3D lattice which is related to the world via an affine transformation. It can be masked, in which case only in-mask image values are kept in memory.

Methods

set
transform
values
__init__(obj, affine=None, world=None, background=0)

The base image class.

Parameters :

data: ndarray :

n dimensional array giving the embedded data, with the first three dimensions being spatial.

affine: ndarray :

a 4x4 transformation matrix from voxel to world.

world: string, optional :

An identifier for the real-world coordinate system, e.g. ‘scanner’ or ‘mni’.

background: number, optional :

Background value (outside image boundaries).

affine
background
data
dtype
inv_affine
set(values)

values can be either a 1d array with size equal to self.size or a 3d array with shape equal to self.shape.

shape
size
transform(transform, grid_coords=False, reference=None, dtype=None, interp_order=1)

Apply a transformation to the image considered as ‘floating’ to bring it into the same grid as a given ‘reference’ image. The transformation is assumed to go from the ‘reference’ to the ‘floating’.

transform: nd array

either a 4x4 matrix describing an affine transformation

or a 3xN array describing voxelwise displacements of the reference grid points

precomputed : boolean True for a precomputed transformation, False for affine

grid_coords : boolean

True if the transform maps to grid coordinates, False if it maps to world coordinates

reference: reference image, defaults to input.

values(coords=None, grid_coords=False, dtype=None, interp_order=1)

Return interpolated values at the points specified by coords.

Parameters :

coords: sequence of 3 ndarrays, optional :

List of coordinates. If missing, the image mask is assumed.

grid_coords: boolean, optional :

Determine whether the input coordinates are in the world or grid coordinate system.

Returns :

output: ndarray :

One-dimensional array.

world

MaskedImage

class nipy.neurospin.image.image.MaskedImage(obj, affine=None, world=None, mask=None, shape=None, background=0)

Bases: nipy.neurospin.image.image.Image

__init__(obj, affine=None, world=None, mask=None, shape=None, background=0)
affine
background
data
dtype
inv_affine
mask
set(values)

If values is a 1d array with size equal to self.size, a MaskedImage instance is returned.

If values is a 3d array with shape equal to self.shape, a (non-masked) Image instance is returned.

shape
size
transform(transform, grid_coords=False, reference=None, dtype=None, interp_order=1)

Apply a transformation to the image considered as ‘floating’ to bring it into the same grid as a given ‘reference’ image. The transformation is assumed to go from the ‘reference’ to the ‘floating’.

transform: nd array

either a 4x4 matrix describing an affine transformation

or a 3xN array describing voxelwise displacements of the reference grid points

precomputed : boolean True for a precomputed transformation, False for affine

grid_coords : boolean

True if the transform maps to grid coordinates, False if it maps to world coordinates

reference: reference image, defaults to input.

values(coords=None, grid_coords=False, dtype=None, interp_order=1)

Return interpolated values at the points specified by coords.

Parameters :

coords: sequence of 3 ndarrays, optional :

List of coordinates. If missing, the image mask is assumed.

grid_coords: boolean, optional :

Determine whether the input coordinates are in the world or grid coordinate system.

Returns :

output: ndarray :

One-dimensional array.

world

Functions

nipy.neurospin.image.image.apply_affine(T, xyz)

T is a 4x4 matrix. xyz is a Nx3 array of 3d coordinates stored row-wise.

nipy.neurospin.image.image.apply_affine_to_tuple(affine, XYZ)
Parameters :

affine: ndarray :

A 4x4 matrix representing an affine transform.

coords: tuple of ndarrays :

tuple of 3d coordinates stored row-wise: (X,Y,Z)

nipy.neurospin.image.image.asNifti1Image(im)
nipy.neurospin.image.image.inverse_affine(affine)
nipy.neurospin.image.image.subgrid_affine(affine, slices)
nipy.neurospin.image.image.validate_coords(coords)

Convert coords into a tuple of ndarrays