Manipulations

Common interface for transforms.

class nitransforms.manip.TransformChain(transforms=None)[source]

Implements the concatenation of transforms.

append(x)[source]

Concatenate one element to the chain.

Example

>>> chain = TransformChain(transforms=TransformBase())
>>> chain.append((TransformBase(), TransformBase()))
>>> len(chain)
3
asaffine()[source]

Combine a succession of linear transforms into one.

classmethod from_filename(filename, fmt='X5', reference=None, moving=None)[source]

Load a transform file.

insert(i, x)[source]

Insert an item at a given position.

Example

>>> chain = TransformChain(transforms=[TransformBase(), TransformBase()])
>>> chain.insert(1, TransformBase())
>>> len(chain)
3
>>> chain.insert(1, TransformChain(chain))
>>> len(chain)
6
map(x, inverse=False)[source]

Apply a succession of transforms, e.g., \(y = f_3(f_2(f_1(f_0(x))))\).

Example

>>> chain = TransformChain(transforms=[TransformBase(), TransformBase()])
>>> chain([(0., 0., 0.), (1., 1., 1.), (-1., -1., -1.)])
[(0.0, 0.0, 0.0), (1.0, 1.0, 1.0), (-1.0, -1.0, -1.0)]
>>> chain([(0., 0., 0.), (1., 1., 1.), (-1., -1., -1.)], inverse=True)
[(0.0, 0.0, 0.0), (1.0, 1.0, 1.0), (-1.0, -1.0, -1.0)]
>>> TransformChain()((0., 0., 0.))  
Traceback (most recent call last):
TransformError:
property transforms

Get the internal list of transforms.

nitransforms.manip.load(filename, fmt='X5', reference=None, moving=None)

Load a transform file.