From Slicer Wiki
Revision as of 22:07, 4 June 2010 by Hjmjohnson (talk | contribs)
Jump to: navigation, search
Home < Modules:BRAINSDemonWarp

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

Author: This tool was developed by Hans Johnson and Greg Harris.


Module Description

Program title BRAINSDemonWarp
Program version 1.0
Program documentation-url


The module registers the template (moving) image onto the physical space of the target (fixed) image. The resultant deformation fields and metric values can be written to a file. The program uses the Insight Toolkit ( for all the computations, and can operate on any of the image file types supported by that library.

Use Cases, Examples

The inputs to the BrainDemonsWarp program are the target image, the template image and the optional parameters. These parameters define the arguments for histogram matching and multi resolution registration. The outputs are the deformation field, output image, checkerboard image of the output and the fixed image and the x,y,z displacement vectors. If we specify debug option we can get the outputs at different stages. The filter is templated over the input image type, real image type and the output image types. We implement the algorithm by parsing the input, preprocessing them and registering the processed images.

  1. Parsing - The images are initialized by the ValidationInputParser. This function reads in the arguments from the parameter file. It sets the histogram bins, match points, number of levels in the multi resolution registration, shrink factors and number of iterations at each levels. If the orientations of the images are different it sets the orientation of the moving image to that of the fixed image.
  2. PreProcessing - In the next step the DemonsPreProcessor preprocesses the images by resampling the template image to target image space. The intensity mismatch problem is solved by histogram matching the images. Histogram matching is done only if the command line option -e is set. ItkHistogramMatchingImageFilter is used to perform this function. Another important step in preprocessing is skull stripping. Skull stripping is done only if the command line option -maskProcessingMode is set to BOBF. We have written an itk filter, named itkBOBFFilter for this purpose. This filter takes in an input image and a whole brain mask and outputs a Brain Only Background Filled(BOBF) image. The non-brain parts in the image are filled with the user specified background value. All computations are performed in the precision of float data.
  3. Registration - The resulting moving Image and the fixed image are given as inputs to the demons registrator.It uses the MultiResolutionPDEDeformableRegistration filter with NN extrapolation as interpolator and implements the demons deformable algorithm by computing the deformation field which will map a moving image onto a fixed image. It is assumed that the vector elements behave like floating point scalars. Each vector in the deformation field represent the distance between a geometric point in the input space and a point in the output space. The output image is generated by warping the input image with the deformation field using the ItkWarpImageFilter. WarpImageFilter warps an existing image with respect to a given deformation field. Typically the mapped position does not correspond to an integer pixel position in the input image. Interpolation via an image function is used to compute values at non-integer positions. We have used the LinearInterpolateImageFunction for our application. To write the output image we cast the image to the user specified output pixel type.

Quick Tour of Features and Use

  • Input Image Files
    • Moving Image Volume [--movingVolume][-m]: Required: input moving image
    • Fixed Image Volume [--fixedVolume][-f]: Required: input fixed target image
  • Output Files
    • Output Image Volume [--outputVolume][-o]: Required: output resampled moving image.
    • Output Deformation Field Volume [--outputDeformationFieldVolume][-O]: Required: output deformation field vector image.
  • Thirion Registration Parameters
    • Registration Filter Type [--registrationFilterType]: Registration Filter Type: Demons|FastSymmetricForces|Diffeomorphic|LogDemons|SymmetricLogDemons
    • Deformation field smoothing sigma [--smoothDeformationFieldSigma][-s]: A gaussian smoothing value to be applied to the deformation feild/
    • Input Type [--inputPixelType]: Input Volumes Pixel Type: float|short|ushort|int|uchar
    • Output Type [--outputPixelType]: Output Volume Pixel Type: CopyInputPixelType|float|short|ushort|int|uchar
    • Interpolation Mode [--interpolationMode]: Type of interpolation to be used when applying transform to moving volume. Options are Linear, NearestNeighbor, BSpline, or WindowedSinc
  • Advanced Options
    • Displacement Field Prefix [--outputDisplacementFieldPrefix]: Displacement Field filename prefix for x y and z component images
    • Output Checkerboard Volume [--outputCheckerboardVolume]: Checkerboard image volume
    • Checkerboard Pattern Subdivisions [--checkerboardPatternSubdivisions]: Number of Checkerboard subdivisions in all 3 directions
    • Center Volumes [--forceCoronalZeroOrigin]: Flag to indicate that all images being read in must have their spatial centers matched.
    • Warp Normalized Images [--outputNormalized]: Flag to warp and write the normalized images to output. In normalized images the image values are fit-scaled to be between 0 and 1
    • Write Intermediate Images [--outputDebug][-v]: Flag to write the images after each step
    • Mask Processing Mode [--maskProcessingMode]: What mode to use for using the masks: NOMASK|ROIAUTO|ROI|BOBF. If ROIAUTO is choosen, then the mask is implicitly defined using a otsu forground and hole filling algorithm. Where the Region Of Interest mode uses the masks to define what parts of the image should be used for computing the deformation field. Brain Only Background Fill uses the masks to pre-process the input images by clipping and filling in the background with a predefined value.
    • Input Fixed Mask Filename [--fixedBinaryVolume]: Mask filename for desired region of interest in the Fixed image.
    • Input Moving Mask Filename [--movingBinaryVolume]: Mask filename for desired region of interest in the Moving image.
    • BOBF Lower Threshold [--lowerThresholdForBOBF]: Lower threshold for performing BOBF
    • BOBF Upper Threshold [--upperThresholdForBOBF]: Upper threshold for performing BOBF
    • BOBF Background Replacement Value [--backgroundFillValue]: Replacement value to overwrite background when performing BOBF
    • Seed For BOBF [--seedForBOBF]: coordinates in all 3 directions for Seed when performing BOBF
    • Seed For BOBF [--neighborhoodForBOBF]: neighborhood in all 3 directions to be included when performing BOBF
    • Median Filter Size [--medianFilterSize]: Median filter radius in all 3 directions
    • Initial Deformation Field Volume [--initializeWithDeformationField]: Initial deformation field vector image file name
    • Initial Transform Filename [--initializeWithTransform]: Initial Transform filename
    • Number of Histogram Bins [--numberOfHistogramBins]: the number of histogram levels
    • Number of Match Points [--numberOfMatchPoints]: the number of match points
    • Number of Pyramid Levels [--numberOfPyramidLevels][-n]: the number of pyramid levels
    • the iteration count for each pyramid level [--arrayOfPyramidLevelIterations][-i]: the iterations for each pyramid level
    • Moving Shrink Factors [--minimumFixedPyramid]: the Shrink factor for the first level of the fixed image pyramid
    • Moving Shrink Factors [--minimumMovingPyramid]: the Shrink factor for the first level of the moving image pyramid
    • Gradient Type [--gradient_type][-t]: Type of gradient used for computing the demons force (0 is symmetrized, 1 is fixed image, 2 is moving image)
    • Update field smoothing [--upFieldSmoothing][-g]: Smoothing sigma for the update field at each iteration
    • Max Step Length [--max_step_length][-l]: Maximum length of an update vector (0: no restriction)
    • Histogram Match [--histogramMatch][-e]: Histogram Match the input images. This is suitable for images of the same modality that may have different absolute scales, but the same overall intensity profile.
    • Turn off Diffeomorphism [--use_vanilla_dem][-a]: Run vanilla demons algorithm


Notes from the Developer(s)



On the Dashboard, these tests verify that the module is working on various platforms:

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: BRAINSDemonWarp

Doxygen documentation:

More Information


Include funding and other support here.


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