Base

Common interface for transforms.

class nitransforms.base.ImageGrid(image)[source]

Class to represent spaces of gridded data (images).

property affine

Access the indexes-to-RAS affine.

property header

Access the original reference’s header.

index(x)[source]

Get the image array’s indexes corresponding to coordinates.

property inverse

Access the RAS-to-indexes affine.

property ndcoords

List the physical coordinates of this gridded space samples.

property ndindex

List the indexes corresponding to the space grid.

ras(ijk)[source]

Get RAS+ coordinates from input indexes.

class nitransforms.base.SampledSpatialData(dataset)[source]

Represent sampled spatial data: regularly gridded (images) and surfaces.

property ndcoords

List the physical coordinates of this sample.

property ndim

Access the number of dimensions.

property npoints

Access the total number of voxels.

property shape

Access the space’s size of each dimension.

class nitransforms.base.SpatialReference[source]

Factory to create spatial references.

static factory(dataset)[source]

Create a reference for spatial transforms.

class nitransforms.base.SurfaceMesh(dataset)[source]

Class to represent surface meshes.

check_sphere(tolerance=1.001)[source]

Check sphericity of surface. Based on https://github.com/Washington-University/workbench/blob/7ba3345d161d567a4b628ceb02ab4471fc96cb20/src/Files/SurfaceResamplingHelper.cxx#L503

class nitransforms.base.TransformBase(reference=None)[source]

Abstract image class to represent transforms.

apply(*args, **kwargs)[source]

Apply the transform to a dataset.

Deprecated. Please use nitransforms.resampling.apply instead.

map(x, inverse=False)[source]

Apply \(y = f(x)\).

TransformBase implements the identity transform.

Parameters:
  • x (N x D numpy.ndarray) – Input RAS+ coordinates (i.e., physical coordinates).

  • inverse (bool) – If True, apply the inverse transform \(x = f^{-1}(y)\).

Returns:

y – Transformed (mapped) RAS+ coordinates (i.e., physical coordinates).

Return type:

N x D numpy.ndarray

property ndim

Access the dimensions of the reference space.

property reference

Access a reference space where data will be resampled onto.

to_filename(filename, fmt='X5')[source]

Store the transform in BIDS-Transforms HDF5 file format (.x5).

exception nitransforms.base.TransformError[source]

A custom exception for transforms.