FMRIPREP: saving forward transforms from BOLD to T1 and/or MNI space

This topic seems to come up from time to time. I would like to have the ability to do transforms from native BOLD space to T1 or MNI space after fmriprep completes, so it would be nice if the transforms were stored in the func directories alongside the preprocessed BOLD files, analogous to the way they are stored in the anat directories.

The few threads I’ve been able to find on this have ended with “there isn’t really a need to do that, since you can do processing in transformed space rather than native space”. While this is true in most cases, I unfortunately have a special case where I actually do need to do processing in native space. I’ve implemented Henning Voss’ hypersampling method (https://arxiv.org/abs/1804.10650) to produce cardiac pulsatility maps, and that requires you to work on the raw BOLD data before motion or slice time correction (since you use the temporal oversampling provided by the slice acquisition rate, and you need to know which acquisition slice each voxel is in). So I end up with maps in native BOLD space that I’d like to get to T1 or MNI space to overlay on the anatomy and match up with other maps (which I can do in T1 or MNI space). I don’t mind if I have to fish the transforms out of the work directory - Satra seemed to say in one of the previous threads that they were in there somewhere - but I can’t find them anywhere - are they ever saved in the current version of fmriprep? They must exist at some point, since the BOLD data is transformed…

As an aside, while I’m only interested in the forward ransform, saving the inverse transform too would probably be a good thing, although I don’t currently have a reason to go from MNI or T1 space to native BOLD. Is the overhead of doing that high? Again, this is in analogy to the transforms stored in the anat directory - having gone to all the trouble to calculate the transforms, it would be nice to save them.

If we look at the FMRIPREP docs we will find a graph of the workflow responsible for bold to T1 coregistration:


On it there is the subworkflow we need - bbreg_wf. You can find the source code for it here. Glancing at the code the node fsl2itk_fwd is performing conversion of the bold2T1w transform from FSL to ITK (ANTs) format (you can use ANTs to apply this transformation). All folders and in working directory are named after workflows and nodes so looking for bold_reg_wf and inside it bbreg_wf should get you to fsl2itk_fwd where the appropriate transform should be.

There is one caveat to be aware of. When we do bold to T1w coregistration we use a reference image constructed (via some heuristics) from the bold timeseries. The same image is used as a motion correction target. Since we apply bold2T1w after applying motion correction transformation this does not matter. However, you will be applying it without the motion correction. In a rare case that our reference image creation heuristic does something funky to the orientation (LAS -> RAS or something like this) you might experience some funky results.

This is just an affine transform so inverting it or applying it in reverse order is very cheap.

1 Like

Ah, ok, great - don’t think I would have found that anytime soon… I can give that a whirl and report back.

1 Like

Actually, we could make it a default - when the T1w output space is required, write out the transforms that need be applied to map T1w into BOLD and vice-versa.

Could you send us a PR? Otherwise, opening an issue would be enough for us to consider this new option.

We would be thrilled to have these registrations available by default as well. Our particular need is to transform retinotopic maps generated in MNI EPI space back to subject-native T1 space for manipulation / template fitting on the individual subject cortical surface.

I opened an issue on the topic (https://github.com/poldracklab/fmriprep/issues/1184), with full credit to @bbfrederick for prompting this!

It would be good to learn more about your use case. Is there a reason why you don’t do all of the analysis in the fsnative (subject native surface space) which can be produced by FMRIPREP upon request?

The reason is that I didn’t know that this is an fmriprep option! We are working closely with Michael Perry to implement fmriprep as a job type on the flywheel system. Michael has rolled a particular implementation of fmriprep that saves out the EPI in volumetric MNI space. I’d appreciate you directing me to an example / docs for producing fsnative output!

You control which spaces are outputted using the --output-space parameter. For example --output-space fsnative T1w will produce outputs on native surface and in native T1w volume, but will skip MNI. More details at http://fmriprep.readthedocs.io/en/latest/usage.html#Workflow%20configuration

1 Like