Two-stage registration


Hello! I apologize beforehand for my lack of expertise, especially in describing what I would like to do.

I am working with 7T func and anat data, as well as 3T anat data for a single subject, different sessions (data structure below). I would like to first coregister the subject’s 7T bold and T1w images, and then do a subsequent registration to the subject’s 3T T1w.

I found a FLIRT FAQ where registration of imageA to imageB to imageC is shown using the command line (see below), but I can’t figure out a way to replicate this in fmriprep. Can it be done?

How do I do a two-stage registration using the command line?

The command line calls made in a two-stage registration of imageA to imageB to imageC are as follows:

flirt [''desired options''] -in ''imageA'' -ref ''imageB'' -omat ''transf_A_to_B.mat''
flirt [''desired options''] -in ''imageB''-ref ''imageC'' -omat ''transf_B_to_C.mat''
convert_xfm -omat ''transf_A_to_C.mat'' -concat ''transf_B_to_C.mat'' ''transf_A_to_B.mat''
flirt -in ''imageA'' -ref ''imageC'' -out ''imageoutput'' -applyxfm -init ''transf_A_to_C.mat''

The above steps perform two registrations (the first two steps) saving the respective transformations as .mat files, then concatenate the transformations using convert_xfm, then apply the concatenated transformation to resample the original image using flirt. Note that the first two calls to flirt would normally require the cost function or degrees of freedom (dof) to be set in the desired options. In the final call to flirt the option -interp is useful for specifying the interpolation method to be used (the default is trilinear).

Also note that the FLIRT GUI outputs the command line calls used to effect the two stage registration, and will be similar to the above, although they will include specification of many of the default settings.

Version I will use:




My folder structure:

└── sub-01
    ├── ses-2023s3T
    │   └── anat
    │       ├── T1w
    │       └── T2w
    └── ses-2023s7T
        ├── anat
        │   └── T1w
        └── func
            └── bold

Hi @ariveradom and welcome to neurostars!

Can you explain why you wan to do registration like this? Is the default registration performed by fMRIPrep not working well for you?


Hi Steven, thanks for replying. The reason is for this dataset we currently have more confidence segmenting 3T anatomical images (though we hope to eventually be able to do so with 7T images).

Hi @ariveradom,

In that case, would you want to run fMRIPrep while ignoring the 7T T1w data? You can use a --bids-filter-file for that.


Hi @Steven,
Sorry for the delay in responding. I did think of that, but I was wondering if there still was a way to automatically implement multi-stage registration.

If there’s no current way to do so (and if what I’m thinking makes at least a little sense), perhaps I could run smriprep with registration based only on the 7T images, and then fmriprep with the --anat_derivatives <PATH> pointing to the warped 7T images?


Hi @ariveradom,

Defining something specific like this is not possible in fMRIPrep. fMRIPrep does do its own multistage registration so that all transformations and registrations (e.g., Bold–> T1 → Standard Space) are performed in a single-shot, to minimize interpolation. But you cannot tell fMRIPrep to do Bold → 7T T1 → 3T T1 → Standard Space, if I a understanding you correctly.

Sorry, I might be misunderstanding here; I thought the goal was to not use the 7T T1 images. This option would be ignoring the 3T images.


Yes, this is what I was trying to get at!

Do you know if there is a workaround that I could do?

My --anat_derivatives <PATH> question was me trying to think of a way, but I wasn’t sure if I was way off.

I was hoping I could do something like what I mentioned in my original post (FLIRT FAQ where registration of imageA to imageB to imageC is shown using the command line (FLIRT/FAQ - FslWiki)).

If your goal is to just get everything aligned, maybe you fMRIPrep while ignoring the 7T data, and then run a rigid registration between 7T and preprocessed 3T after the fact? All of the BOLD–>T1 registrations are just rigid 6 degrees of freedom rotation and translation, no scaling. How you are doing susceptibility distortion correction will really be what determines how well the boundaries of your BOLD align with your T1, especially in 7T data. Have you yet tried running fMRIPrep with all data?

Gotcha, thank you. For now will then just run fmriprep using 7T bold and 3T anat! Thanks again, @Steven.