Skip to content

Transformations

John Bogovic edited this page Mar 15, 2019 · 7 revisions

Nomenclature and conventions

Bridging transformations are named with a prefix of the form: TARGET_SOURCE, where TARGET is the name of one template space, and SOURCE is the name of another [1]. This transform:

  • maps point coordinates in TARGET space to SOURCE space.
  • Is used to transform images in SOURCE space to TARGET space.

[1] Following the convention set forth in the NeuroAnatomy Toolbox's bridging registrations.

Relationship to ANTs conventions

Deformable registration with ANTs for TARGET and SOURCE generates output three output files, an "Affine" file, a "Warp" file, and an "InverseWarp" file. In this case the TARGET_SOURCE transform consists of these operations, in order:

  1. Apply the transform defined by the "Warp" field file
  2. Apply the transform defined by the "Affine" file.

Similarly, the inverse transformation "SOURCE_TARGET" consists of these operations, in order:

  1. Apply the inverse of the transform defined by the "Affine" file.
  2. Apply the transform defined by the "InverseWarp" field file

Using transformations

This library provides several scripts for applying spatial transformations to images or points / skeletons.

Images

When possible, use ANTs' WarpImageMultiTransform, antsApplyTransforms, or CMTK's reformatx to apply transformations generated by ANTs and CMTK, respectively.

In other cases, the script renderTransformed may be helpful.

Skeletons

The R package nat has great tools for analyzing skeletons, including transforming them with CMTK-compatible transformations. For other transforms, see below for scripts that convert transforms to CMTK-compatible formats.

Use the script transformSwc to transform skeletons stored as swc files.

Points

When possible, use ANTs' antsApplyTransformsToPoints, or CMTK's streamxform to transform points.

In other cases, the script transformPoints may be helpful in transforming arbitrary points and point-lists.

Bridging transformations

We provide a number of spatial transformations that convert images or points/skeletons from one template space to another.

Supported transformation types

This library supports transformations created by both the ANTs and CMTK image registration packages as well as several custom formats.

This library makes it possible to apply the inverse of most types of readable transformations, though some need to be estimated iteratively, which we recommend avoiding if possible. See this page for details.

ANTs

Affine

We do not support arbitrary affine transforms written by ANTs - a few different conventions / formats are possible. Rather, convert the affines to homogenious matrix and write plain text file using the ANTs utility: ConvertTransformFile.

Displacement fields

We support ANTs displacement fields as gzip-compressed Nifti files.

CMTK

Affine

We do not support arbitrary affine transforms written by CMTK. Rather, convert the affines to homogenious matrix and write plain text file using the CMTK utility: dof2mat

Displacement field

CMTK parametrizes the non-linear part of its spatial transformation with B-Splines, usually stored as a compressed text file. We do not currently support this format directly. However, one can convert from this format to a displacement field using the script: cmtk2DField.

Bigwarp

Thin plate splines produced by BigWarp are readable and apply-able. These are stored as plain-text (csv) files of point correspondences (with some extra book-keeping).

Transform conversion

ANTs to CMTK

The script antsAffine2Cmtk converts the affine component of an ANTs transform to CMTK's format. antsDfield2Cmtk converts a displacement field generated by ANTs to a nrrd file that CMTK understands.