Brain Template Creation with ANTs

These instructions use FA images to create an FA template using the software package ANTs (http://stnava.github.io/ANTs/); the process should work well with other image modalities.

First we can use FLIRT to register a group of 4 brains (semi-randomly chosen by looking at the slicesdir output created from an initial step of TBSS; the 4 brains chosen were ones that appeared to be straightest and least affected by artifact) to a common space (in this case MNI152 2mm) using a linear registration with 12 dof.

flirt -in /path/to/FA/directory/con001_fa_brain.nii.gz -ref /usr/local/fsl/data/standard/MNI152_T1_2mm_brain -out /path/to/FA/directory/con001_fa_brain2MNI152 -omat /path/to/FA/directory/con001_fa_brain2MNI152 -bins 256 -cost corratio -searchrx -180 180 -searchry -180 180 -searchrz -180 180 -dof 12 -interp trilinear –v

That is repeated for each of the four brains (you can pick another number but I used four to be semi-representative of my sample). This step can also be looped with a simple for statement.

I then used c3d (fslmaths could also be used) to create a mean FA image from the four aligned brains.

c3d *_brain2MNI152.nii.gz -mean -o con_mean_fa.nii.gz

#create mean image from four aligned images. Make sure you are in the directory or that you specify the whole path to the files.

4subject_mean_FA

Then use ANTs to create a template. In my case I used 80 MRI images to create the template. Note, you will need to do minor edits of the template creation script (provided with the ANTs installation in the bin directory). The first part of the script looks like this (this is my edited version, specific for my ANTs installation):

function setPath {
cat <<SETPATH
------------------------------------------------------------
Error locating ANTS
------------------------------------------------------------
It seems that the ANTSPATH environment variable is not set. Please add the ANTSPATH variable. This can be achieved by editing the .bash_profile in the home directory.

Add: ANTSPATH=/Applications/antsbin/bin

Or the correct location of the ANTS binaries.
Alternatively, edit this script ( `basename $0` ) to set up this parameter correctly.
SETPATH
exit 1
}
# Uncomment the line below in case you have not set the ANTSPATH variable in your
# environment.
export ANTSPATH=${ANTSPATH:=”/Applications/antsbin/bin/”} # EDIT THIS

Below is the command I used to run the script and create the template brain.

/path/to/FA/template/directory/antsMultivariateTemplateConstruction2.sh -d 3 -o template_ -c 2 -j 4 -z /path/to/FA/template/directory/initial_template/con_mean_fa.nii.gz *.nii.gz

#I ran the script using the following flags: -d 3 (3D image); -c 2 (use localhost multiprocessors; i.e., not a parallel computing environment); -j 4 (use #up to 4 processors at a time); -z is input initial template; *.nii.gz warps all brains in the directory (skull-stripped FA images in my case) into the template. Make sure that is including only what you want it to include.

This runs for a while – days at a minimum on a fast late 2012 iMac – with this many brains. The template can then be used for a registration target as a study-sepcific image. I’ve found that using a study-specific template potentially yields better results, especially for TBSS. Others have published on this:

Bach, M., Laun, F. B., Leemans, A., Tax, C. M., Biessels, G. J., Stieltjes, B., & Maier-Hein, K. H. (2014). Methodological considerations on tract-based spatial statistics (TBSS). NeuroImage100, 358-369.

Keihaninejad, S., Ryan, N. S., Malone, I. B., Modat, M., Cash, D., Ridgway, G. R., et al. (2012). The Importance of Group-Wise Registration in Tract Based Spatial Statistics Study of Neurodegeneration: A Simulation Study in Alzheimer’s Disease. PLoS One, 7(11), e45996. doi:10.1371/journal.pone.0045996

The FA template result is below.

 

80brain_FA_template

Just for fun, here is a 3D rendering of the FA template. Image rendered in Freeview.

3D_FA_template_FA__2__9

About Jared Tanner

I have a PhD in Clinical and Health Psychology with an emphasis in neuropsychology at the University of Florida. I previously studied at Brigham Young University. I am currently a Research Assistant Professor at the University of Florida. I spend the bulk of my research time dealing with structural magnetic resonance images of the brain. My specialty is with traditional structural MR images, such as T1-weighted and T2-weighted images, as well as diffusion weighted images. I also look at the cognitive and behavioral functioning of individuals with PD and older adults undergoing orthopedic surgery. Funding for the images came from NINDS K23NS060660 (awarded to Catherine Price, University of Florida). Brain images may not be used without my written permission (grant and software requirements).