Using FreeSurfer’s bbregister for Image Registration

I know I post a lot about registration (see here and here) but I believe that image registration is one of the most important components of an MRI processing pipeline. Thankfully, there are some good tools available. FLIRT, FNIRT, bbregister, and ANTS are just a few of the registration tools I’ve used. I’ve found that for intra-individual inter-modal (diffusion to T1 or vice versa) registration, rigid body or even affine (linear) is usually sufficient if the registered scans were acquired at the same scanning session. Even if they were not, linear registrations should be good enough for intra-individual work. Why is this?

Part of the difficulty with the flexibility of nonlinear registrations is that they can be too flexible. This is a problem when you are trying to align diffusion weighted scans to T1 scans, for example. Here are a couple images showing some distortion. This distortion is mostly due to proximity to the air filled sinuses.

A b0 image (no diffusion weighting applied) showing frontal distortion.

One direction from a 64 direction dwi sequence showing temporal distortion.

With very flexible nonlinear registration methods on a skull-stripped brain, the tools try to stretch brain regions to fit; if there is warping or other distortion, we do not get good results. Using a non-skull-stripped brain sometimes fixes the problem but in some cases (intra-individual inter-modal) nonlinear methods are likely overkill.

I’ve been doing trial runs with FreeSurfer’s bbregister in order to see how well it works. It’s relatively simple.

First, the T1(s) of a subject should be processed through the recon-all Freesurfer script. Next, if you want you can use FreeSurfer’s script dt_recon to do preliminary processing of diffusion data. That’s actually the easiest pathway because it will register your diffusion data to your structural data in the process. The matrix file you will need is called register.dat (see screenshot).

If you did not or do not want to run dt_recon (it uses a number of FSL’s diffusion tools), you can create that registration file by hand using bbregister. To do this type a command like this:

bbregister --s sub001 --mov /{path to b0 image}/lowb.nii.gz --reg /{path to where you will save the matrix file}/lowb2orig.dat --dti --init-fsl

What this does is create a .dat (matrix) file that tells an image how to get from diffusion space to FreeSurfer’s conformed space (i.e., the 256x256x256 1x1x1mm space that orig.mgz is in). You could set your --mov as the orig.mgz and add a --target with it set to your b0 (lowb or nodif or whatever the file is called) image. Without a --targ a conformed image (e.g., orig.mgz) is the implied target. I typically make the diffusion image the movable one and then apply the inverse matrix to files in conformed space that I want to be in diffusion space. It seems a little backward but it works well. [Note: I could be mistaken about this but I believe it is the case].

You’ll see something like this in your Terminal:

You can check your results with tkregister2: tkregister2 --mov /{path to b0 image}/lowb.nii.gz --reg /{path to where you will save the matrix file}/lowb2orig.dat --surf

You’ll see something like this in tkregister2:

I’ve yet to get a bad result with good MRI data.

Now you can use this registration matrix to get ROIs from FreeSurfer’s conformed space (this example was made up with an occipital ROI that could have been created in ITK-SNAP; you could also change all of aseg.mgz into diffusion space this way) into diffusion space with mri_vol2vol:

mri_vol2vol --mov /Users/Shared/DWI_MAS/sub001/DATA/nodif.nii.gz --targ /Users/Shared/DWI_MAS/sub001/ROIS/sub001_r_occipital_roi.nii.gz --o /Users/Shared/DWI_MAS/sub001/ROIS/sub001_r_occipital_roi2dwi.nii.gz --reg /Users/Shared/DWI_MAS/sub001/DATA/orig2nodif.dat --inv –-nearest

Note the --inv that specifies to apply the inverse of the matrix (conformed –> diffusion rather than diffusion –> conformed).

It also works for getting FreeSurfer cortical labels into diffusion space with mri_label2vol (note: you’ll want to play around with the --proj option to see what works for you):

mri_label2vol --label /Applications/freesurfer/subjects/sub001/label/lh.entorhinal_exvivo.label --reg /Users/Shared/DWI_MAS/sub001/DATA/nodif2orig.dat --fillthresh .3 --hemi lh --subject sub001 --o /Users/Shared/DWI_MAS/sub001/rois/sub001_l_exvivo_erc.nii.gz --temp /Users/Shared/DWI_MAS/sub001/data/nodif.nii.gz --proj frac 0 1 .1

l_erc_in_dwi_space

There you go! Using bbregister, you can end up with good intra-individual, inter-modal registrations. I went beyond a simple registration but registrations are only really useful as one very important step in a broader imaging process.

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).