labs.datasets.transforms.affine_utils

Module: labs.datasets.transforms.affine_utils

Functions working with affine transformation matrices.

Functions

nipy.labs.datasets.transforms.affine_utils.apply_affine(x, y, z, affine)[source]

Apply the affine matrix to the given coordinate.

Parameters

x: number or ndarray

The x coordinates

y: number or ndarray

The y coordinates

z: number or ndarray

The z coordinates

affine: 4x4 ndarray

The affine matrix of the transformation

nipy.labs.datasets.transforms.affine_utils.from_matrix_vector(matrix, vector)[source]

Combine a matrix and vector into a homogeneous transform.

Combine a rotation matrix and translation vector into a transform in homogeneous coordinates.

Parameters

matrix : ndarray

An NxN array representing the rotation matrix.

vector : ndarray

A 1xN array representing the translation.

Returns

xform : ndarray

An N+1xN+1 transform matrix.

See also

to_matrix_vector

nipy.labs.datasets.transforms.affine_utils.get_bounds(shape, affine)[source]

Return the world-space bounds occupied by an array given an affine.

nipy.labs.datasets.transforms.affine_utils.to_matrix_vector(transform)[source]

Split a transform into it’s matrix and vector components.

The tranformation must be represented in homogeneous coordinates and is split into it’s rotation matrix and translation vector components.

Parameters

transform : ndarray

Transform matrix in homogeneous coordinates. Example, a 4x4 transform representing rotations and translations in 3 dimensions.

Returns

matrix, vector : ndarray

The matrix and vector components of the transform matrix. For an NxN transform, matrix will be N-1xN-1 and vector will be 1xN-1.