From Slicer Wiki
Jump to: navigation, search
Home < Modules:BRAINSFit

Return to Slicer 3.6 Documentation

Gallery of New Features

Module Name


User Interface

General Information

Module Type & Category

Type: CLI

Category: Registration

Authors, Collaborators & Contact

  • Author1: Hans Johnson, University of Iowa
  • Contributor1: Kent WIlliams, University of Iowa
  • Contact: Hans Johnson, hans-johson at

Module Description

BRAINSFit is a program for mutual information registration of brain imaging data using ITK classes. It is based on an example program included in the ITK distribution,

Insight/Examples/Registration/ImageRegistration8.cxx This program is the most functional example of multi-modal 3D rigid image registration provided with ITK. ImageRegistration8 is in the Examples directory, and also sec. 8.5.3 in the ITK manual. We have modified and extended this example in several ways:

  • defined a new ITK Transform class, based on itkScaleSkewVersor3DTransform which has 3 dimensions of scale but no skew aspect.
  • implemented a set of functions to convert between Versor Transforms and the general itk::AffineTransform and deferred converting from specific to more general representations to preserve transform information specificity as long as possible. Our Rigid transform is the narrowest, a Versor rotation plus separate translation.
  • Added a template class itkMultiModal3DMutualRegistrationHelper which is templated over the type of ITK transform generated, and the optimizer used.
  • Added image masks as an optional input to the Registration algorithm, limiting the volume considered during registration to voxels within the brain.
  • Added image mask generation as an optional input to the Registration algorithm when meaningful masks such as for whole brain are not available, allowing the fit to at least be focused on whole head tissue.
  • Added the ability to use one transform result, such as the Rigid transform, to initialize a more adaptive transform
  • Defined the command line parameters using tools from the Slicer [ 3] program, in order to conform to the Slicer3 Execution model.

Added the ability to write output images in any ITK-supported scalar image format.


The BRAINSFit distribution contains a directory named TestData, which contains two example images. The first, test.nii.gz is a NIfTI format image volume, which is used the input for the CTest-managed regression test program. The program makexfrmedImage.cxx, included in the BRAINSFit distribution was used to generate test2.nii.gz, by scaling, rotating and translating test.nii.gz. You can see representative Sagittal slices of test.nii.gz (in this case, the fixed image, test2.nii.gz (the moving image), and the two images ’checkerboarded’ together to the right. To register test2.nii.gz to test.nii.gz, you can use the following command:

BRAINSFit --fixedVolume test.nii.gz \
--movingVolume test2.nii.gz \
--outputVolume registered.nii.gz \
--transformType Affine

A representative slice of the registered results image registered.nii.gz is to the right. You can see from the Checkerboard of the Fixed and Registered images that the fit is quite good with Affine transform-based registration. The blurring of the registered images is a consequence of the initial scaling used in generating the moving image from the fixed image, compounded by the interpolation necessitated by the transform operation.

You can see the differences in results if you re-run BRAINSFit using Rigid, ScaleVersor3D, or ScaleSkewVersor3D as the ----transformType parameter. In this case, the authors judged Affine the best method for registering these particular two images; in the BRAINS2 automated processing pipeline, Rigid usually works well for registering research scans.

Quick Tour of Features and Use

A list panels in the interface, their features, what they mean, and how to use them. For instance:

  • Required Input Parameters
    • Fixed Image Volume: The fixed image for registration by mutual information optimization.
    • MovingImage Volume: The moving image for registration by mutual information optimization.
    • Transform Type: One of the four rigid ITK 3D transform types -- or BSpline -- to use in parameter optimization descent. BRAINSFit always optimizes mutual information, but the kind of descent varies with the transform type. The valid types are, Rigid, ScaleVersor3D, ScaleSkewVersor3D, Affine, and BSpline. Specifiying more than one in a comma separated list will initialize the next stage with the previous results. (default: Rigid)
  • Transform Configuration Parameters
    • Initialize Transform Mode: Determine how to initialize the transform center. GeometryOn on assumes that the center of the voxel lattice of the images represent similar structures. MomentsOn assumes that the center of mass of the images represent similar structures. CenterOfHead attempts to use the top of head and shape of neck to drive a center of mass estimate. Off assumes that the physical space of the images are close, and that centering in terms of the image Origins is a good starting point. This flag is mutually exclusive with the initialTransform flag. (default: Off)
    • Infererior Cut Off From Center: the cut-off below the image centers, in millimeters, (default: 1000)
    • Initial Tranform: Filename of transform used to initialize the registration.
  • Important Registration Parameters
    • Number Of Iterations: The maximum number of iterations to try before failing to converge. Use an explicit limit like 500 or 1000 to manage risk of divergence. (default: 1500)
    • Number Of Samples: The number of voxels sampled for mutual information computation. Increase this for a slower, more careful fit. You can also limit the sampling focus with ROI masks and ROIAUTO mask generation. (default: 100000)
    • Minimum Step Size: Each step in the optimization takes steps at least this big. When none are possible, registration is complete. (default: 0.005)
    • Tranform Scale: How much to scale up changes in position compared to unit rotational changes in radians -- decrease this to put more rotation in the search pattern. (default: 1000)
    • Re-proportion Scale: ScaleVersor3D 'Scale' compensation factor. Increase this to put more rescaling in a ScaleVersor3D or ScaleSkewVersor3D search pattern. 1.0 works well with a translationScale of 1000.
    • Skew Scale: ScaleSkewVersor3D Skew compensation factor. Increase this to put more skew in a ScaleSkewVersor3D search pattern. 1.0 works well with a translationScale of 1000.
    • Number Of Grid Subdivisions: The number of subdivisions of the BSpline Grid to be centered on the image space. Each dimension must have at least 3 subdivisions for the BSpline to be correctly computed.
    • Maximum B-SPline Displacement: Sets the maximum allowed displacements in image physical coordinates for BSpline control grid along each axis. A value of 0.0 indicates that the problem should be unbounded. NOTE: This only constrains the BSpline portion, and does not limit the displacement from the associated bulk transform. This can lead to a substantial reduction in computation time in the BSpline optimizer.
  • Control of Mask Processing
    • Mask Processing Mode:What mode to use for using the masks. If ROIAUTO is choosen, then the mask is implicitly defined using a otsu forground and hole filling algorithm. The Region Of Interest mode (choose ROI) uses the masks to define what parts of the image should be used for computing the transform.
    • Output Fixed Mask: Computed mask for Fixed Image (ROIAUTO Mode only)
    • Output Movming Mask: Computed mask for Moving Image (ROIAUTO Mode only)
    • Input Fixed Mask: Fixed Image Mask (ROI only)
    • Input Moving Mask: Moving Image Mask (ROI Only)
User Interface


Notes from the Developer(s)


BRAINSFit depends on Slicer3 (for the SlicerExecutionModel support) and ITK.


TODO: Link to BRAINS3 and/or Slicer3 dashboard tests.

Known bugs

Links to known bugs in the Slicer3 bug tracker

Usability issues

Follow this link to the Slicer3 bug tracker. Please select the usability issue category when browsing or contributing.

Source code & documentation

Links to the module's source code:

Source code:

Doxygen documentation:

More Information


Include funding and other support here.


Publications related to this module go here. Links to pdfs would be useful.