Coregistration with BBRegister


I’m attempting to use freesurfer’s BBRegister to coregister a structural image to the functional images of a subject.
So far I did

RECON = Node(ReconAll(directive="all"), name="RECON")
RECON.inputs.subjects_dir = "/freesurfer"
bbreg = Node(BBRegister(init="fsl", contrast_type="t2"), name="bbreg")

when connecting the nodes what file should I specify as the source_file of bbregister, should it be the brainmask from reconall output?

wf.connect(RECON, bbreg, [("brainmask","source_file")])

Also, how can I specify the reference image (the image that doesn’t move) in BBRegister in order to align the anatomical image with the realigned EPIs?



The source_file is the target volume that you want to fit the white surface to. Therefore, it should be a representative 3D image (e.g. the mean across time) of each of your functional images.

Do not forget to point BBRegister to the same subject directory and subject that you used in your RECON step. The reference image will be automatically picked up by BBRegister (so no, you don’t specify the reference).


Thank you @oesteban that was very helpful.
I still have a question though. How can I point to the same subject directory I used in my RECON step? The BBRegister interface in nipype accepts a subject_id input but not a subject_dir.
Also would the reference image automatically picked up by BBRegister be the (skull-stripped) structural (ie brainmask.mgz) from RECON?

BBRegister accepts a subjects_dir input (please note the plural of subject, which may be inconsistent with other freesurfer interfaces in nipype).

Thanks @oesteban, that was it, I overlooked that detail in the documentation for some reason.
I managed to run BBRegister successfully but I’m still not sure if this is working as intended. Maybe I’m misunderstanding completely but if I intend to coregister the mean functional image to the anatomical image after running freesurfer, isn’t the mean functional image the “reference image” and the anatomical the “source image” (I think that’s how SPM define source and reference). Because if the mean functional image is moved (because it’s the source image) then the individual EPIs will not be aligned to this mean functional image anymore (and neither will the anatomical).

Hi @mri,

Your thinking is correct in general, it is unfortunate that the name of the moving image for BBRegister is source_file.

However, it derives from the fact that bbregister implements a registration scheme based on active contours with edges. In other words, maps surfaces (not images) onto images (the source_file in particular).

But that is just a nomenclature issue. Nonetheless, the resulting transform can be applied both ways (it is an invertible affine, after all). With the appropriate command lines, you can either resample the T1w into your EPI space and viceversa.

You may be interested in using FMRIPREP at this point. Or, at least, check out the documentation and code about how we use BBRegister in this exact same application:

More broadly, I find this blog pretty informative:

Thanks @oesteban, that was very helpful!

1 Like