NIPY logo

Site Navigation

NIPY Community

Table Of Contents

This Page

neurospin.registration.affine

Module: neurospin.registration.affine

Inheritance diagram for nipy.neurospin.registration.affine:

Classes

Affine

class nipy.neurospin.registration.affine.Affine(array=None, radius=100, flag2d=False)

Bases: object

__init__(array=None, radius=100, flag2d=False)
inv()
Return the inverse affine transform.
param
precond
vec12

Rigid

class nipy.neurospin.registration.affine.Rigid(array=None, radius=100, flag2d=False)

Bases: nipy.neurospin.registration.affine.Affine

__init__(array=None, radius=100, flag2d=False)
inv()
Return the inverse affine transform.
param
precond
vec12

Similarity

class nipy.neurospin.registration.affine.Similarity(array=None, radius=100, flag2d=False)

Bases: nipy.neurospin.registration.affine.Affine

__init__(array=None, radius=100, flag2d=False)
inv()
Return the inverse affine transform.
param
precond
vec12

Functions

nipy.neurospin.registration.affine.preconditioner(radius)

Computes a scaling vector pc such that, if p=(u,r,s,q) represents affine transformation parameters, where u is a translation, r and q are rotation vectors, and s is the vector of log-scales, then all components of (p/pc) are roughly comparable to the translation component.

To that end, we use a radius parameter which represents the ‘typical size’ of the object being registered. This is used to reformat the parameter vector (translation+rotation+scaling+shearing) so that each element roughly represents a variation in mm.

nipy.neurospin.registration.affine.rotation_mat2vec(R)

Inverse operation of rotation_vec2mat.

The algorithm is based on a quaternion representation, exploiting the fact that the rotation vector r = theta*n associated with a quaternion (x,y,z,w) statisfies:

x = sin(theta/2) nx y = sin(theta/2) ny z = sin(theta/2) nz w = cos(theta/2)

1 - 2y^2 - 2z^2 2xy - 2zw 2xz+ 2yw |
R = | 2xy + 2zw 1 - 2x^2 - 2z^2 2yz - 2xw |
2xz - 2 yw 2yz + 2xw 1 - 2x^2 - 2y^2 |
nipy.neurospin.registration.affine.vector12(mat, subtype=2)
Return a 12-sized vector of natural affine parameters: translation, rotation, log-scale, additional rotation (to allow for shearing when combined with non-unitary scales).