March 7, 2019: mincANTS is now simply referred to as ANTS.


This page provides parameters for ANTS that could give a reasonable transformation between two atlases.

Mutual Information (MI) is generally used for inter-modality registrations and cross correlation (CC) is used for intra modality registrations. If you have two MRI atlases that have different contrast in just one or two structures, it is faster to segment those structures and then run the registration with CC.

Ex-vivo atlas to in-vivo atlas (both MRI)

Here the assumption is that you want to register an ex-vivo atlas to an in-vivo atlas in order to obtain labels for the in-vivo atlas. In this example:

  • invivo-atlas.mnc (minc file for the in-vivo atlas)
  • exvivo-atlas.mnc (minc file for the ex-vivo atlas)
  • 125 micron (resolution of the in-vivo data)

Manual lsq6

Start with a manual lsq6 alignment using register. The first argument to register is the target, the second the source. Your command would look like this:

> register invivo-atlas.mnc exvivo-atlas.mnc

Place anywhere between 4 to about 8 tag points, and save the transform. Apply to the exvivo-atlas.mnc file

> mincresample -like invivo-atlas.mnc -transformation lsq6_trans_from_register.xfm exvivo-atlas.mnc exvivo-atlas_lsq6.mnc

Non-linear ANTS call

Create the gradient magnitude files necessary for ANTS

> mincblur -fwhm 0.125 -gradient exvivo-atlas_lsq6.mnc exvivo-atlas_lsq6_fwhm_0.125
> mincblur -fwhm 0.125 -gradient invivo-atlas.mnc invivo-atlas_fwhm_0.125

Then run the ANTS call

If you have a mask, you can add the following flag to the ANTS call to include the mask:

-x mask.mnc

And keep in mind that this example deals with 125 micron files. Change the gradient blurring kernel with respect to the resolution of your input files!

> ANTS 3 \
-m CC[exvivo-atlas_lsq6.mnc,invivo-atlas.mnc,1,4] \
-m CC[exvivo-atlas_lsq6_fwhm_0.125_dxyz.mnc,invivo-atlas_fwhm_0.125_dxyz.mnc,1,4] \
-o ANTS_trans_from_exvivo_to_invivo_SyN_0.4_Gauss_4_1_radius_4.xfm \
-i 100x100x100x100 \
-t SyN[0.4] \
-r Gauss[4,1] \
--number-of-affine-iterations 0

Alternatively you can run the command with slightly different settings for the SyN and Gauss parameters (this allows for less deformation):

> ANTS 3 \
-m CC[exvivo-atlas_lsq6.mnc,invivo-atlas.mnc,1,3] \
-m CC[exvivo-atlas_lsq6_fwhm_0.125_dxyz.mnc,invivo-atlas_fwhm_0.125_dxyz.mnc,1,3] \
-o ANTS_trans_from_exvivo_to_invivo_SyN_0.1_Gauss_2_1.xfm \
-i 100x100x100x100 \
-t SyN[0.1] \
-r Gauss[2,1] \
--number-of-affine-iterations 0

Or try it with Mutual Information:

> ANTS 3 \
-m MI[exvivo-atlas_lsq6.mnc,invivo-atlas.mnc,1,32] \
-m CC[exvivo-atlas_lsq6_fwhm_0.125_dxyz.mnc,invivo-atlas_fwhm_0.125_dxyz.mnc,1,3] \
-o ANTS_trans_from_exvivo_to_invivo_MI_SyN_0.1_Gauss_3_1.xfm \
-i 100x100x100x100 \
-t SyN[0.1] \
-r Gauss[3,1] \ 
--number-of-affine-iterations 0

Example script for ANTS registration

Here is a simple bash script that parses command line arguments to register two minc files and outputs an XFM.

#!/bin/bash

# usage
# save this file: example 'reg_scr.sh'
# mark it as executable:
#  > chmod +x reg_scr.sh
# To register a file (source.mnc) to another file (target.mnc) and save the transform (source_to_target.xfm).
# The source and target files have masks (source_mask.mnc and target_mask.mnc) to speed up registrations and make them more accurate.
#  > ./reg_scr.sh source.mnc source_mask.mnc target.mnc target_mask.mnc source_to_target.xfm
 
parse_arr=( "$@" )
 
srcfl=${parse_arr[0]}
srcmsk=${parse_arr[1]}
tgtfl=${parse_arr[2]}
tgtmsk=${parse_arr[3]}
xfmfl=${parse_arr[4]}


srcfl_aff='source_affine.mnc'
srcmsk_aff='source_affine_mask.mnc'

xfm_aff='source_to_target_affine.xfm'
xfm_warp='source_to_target_warp.xfm'

# run affine registration
antsRegistration -d 3 \
   -o "${xfm_aff%.*}" \
   -x [${srcmsk},${tgtmsk}] \
   -a 1 -z 1 \
   -t Affine[0.25] \
   -m MI[${srcfl},${tgtfl},1,32,Regular,0.25] \
   --convergence [1000,1e-6,10] --shrink-factors 1 --smoothing-sigmas 0mm \
   --minc -v 1 --use-histogram-matching 1

# affine resample source and mask
mincresample -quiet -like ${tgtfl} -transform ${xfm_aff} ${srcfl} ${srcfl_aff}
mincresample -nearest -label -quiet -like ${tgtfl} -transform ${xfm_aff} ${srcmsk} ${srcmsk_aff}

# run non-affine registration
antsRegistration -d 3 \
   -o "${xfm_warp%.*}" \
   -x [${srcmsk_aff},${tgtmsk}] \
   -a 1 -z 1 \
   -t SyN[0.1,2,0] \
   -m MI[${srcfl_aff},${tgtfl},1,32,Regular,0.25] \
   --convergence [1000x1000x1000x1000,1e-6,10] \
   --shrink-factors 8x4x2x1 \
   --smoothing-sigmas 0.2x0.1x0.05x0mm \
   --minc -v 1 --use-histogram-matching 1

# concatenate affine and non-affine transformations
xfmconcat ${xfm_aff} ${xfm_warp} ${xfmfl}

# remove temporary files
rm ${srcfl_aff} ${srcmsk_aff} 
rm ${xfm_aff} ${xfm_aff%.*}_inverse.xfm
rm ${xfm_warp} ${xfm_warp%.*}_inverse.xfm
rm ${xfm_warp%.*}_grid_0.mnc ${xfm_warp%.*}_inverse_grid_0.mnc

To see if it worked successfully

Use mincresample -like target.mnc -transform source_to_target.xfm source.mnc source_transformed.mnc

Compare source_transformed.mnc and target.mnc and see if they overlap.