Skip to content
Priscila Thalenberg Levi edited this page Mar 4, 2025 · 6 revisions

fMRIPrep

fMRIPrep is a powerful, freely available fMRI preprocessing pipeline. It performs basic processing steps (e.g., co-registration, normalisation, unwarping, noise component extraction, etc). These steps can be implemented by choosing flags available here.

Basically, fMRIPrep allows you to take your raw dataset to a point where it is ready for statistical analysis or further neural and noise signal separation. And one reason why we've chosen to use a toolbox like fMRIPrep is to ensure reproducibility and allow replicability in our analysis. These issues are specifically highlighted in a study where 70 independent teams differed in their analytical workflow and results despite working with the same dataset and hypothesis.

You can activate it on MASSIVE by calling module load fmriprep

An example of how to set out your script if you have pre-Freesurfered data and multiecho bold:

Hypothetically, all you really need is BIDSified data for fMRIPrep to work*.

You will need some BOLD data, and ideally some T1 data to register the bold data to. It is intended that fMRIPrep read your directory structure and the kinds of data you have available, and then change the processing steps to suit your particular circumstances. For example, perhaps you have Phase Difference and Magnitude Images in your fieldmap directories in one dataset, and Pepolar fieldmaps in another; the fMRIPrep process will adapt accordingly - and you will receive a boilerplate after the preprocessing which steps through what exactly fMRIPrep has done.

*A special note here: just because this is how it is intended to work, does not mean that you should treat fMRIPrep like a black box (as many others do!). If you set things out incorrectly and still get output (error free output does not necessarily mean that your results are appropriate!), you will not know that there has been an issue. fMRIPrep may also struggle with certain types of data. For example, fMRIPrep (as of 07/2023) does not handle multiecho data very well by itself - and you will need to adapt the pipeline using the –me-output-echos flag and then run a script from the tedana website before proceeding with your preprocessing steps: https://tedana.readthedocs.io/en/stable/faq.html.

fMRIPrep is always being updated. I highly recommend consulting the “What’s new” documentation to ensure that you are using the most up to date version prior to analyses: https://fmriprep.org/en/stable/changes.html.

fMRIprep on anatomical data:

  • All T1w images are conformed to RAS orientation and a common voxel sizze. In case of multiple T1w images, all of them are mergged and averaged to a single reference template using FreeSurfer's mri_robust_template
  • The T1w reference image is skull-stripped usin Nipype implementation of antsBrainExtraction
  • The T1w reference image is N4bias feild corrected for intensity non-uniformity (INU)
  • Brain extraction is performed on the T1w reference image, and a brian mask is created uning ANTs
  • Brain tissue segmentation into GM, WM, and CFL using FSL fast
  • Surface reconstruction (T2w is used if available) using FreeSurfer
  • Non-linear spatial normalization of T1w images to brain atlas/standard spaces (e.g., MNI) using ANTsRegistration

fMRIprep on functional data:

  • Reference image: single-band reference ('sbref') image associated with the BOLD series is used if available. Otherwise, an average of dummy scans or a median of motion corrected subset of volumes is used. If multi-echo data is supplied, a T2^ driven corregistration is used. Here TEDANA T2* workflow is used to generate an adaptive T2* map and optimally weighed combination of supplied echo times. This optimally combined echoes is used in all the preprocessing steps.
  • Brain mask: Reference image is used to create a brain mask for BOLD signal in native space (i.e. subject's space).
  • Head motion correction: FSL mcflirt used to exstimate head motion using brain mask
  • Slice timing corection: ADNI 3dTShift is used to realign slices to the middle of each TR
  • Susceptibility distortion correction:
    • GRE-seq using Nipype
    • Reverse PE: AFNI's 3DQwarp
    • Fieldmap-less correction
  • A new preprocessed image is generated in native space following, HMC, STC, and SDC (if performed) for a one-shot interpolation using Lanczos kernel
  • EPI to T1w registration: FreeSurfer's BBR register using to align the BOLD reference image of each run to T1w reference image (native space) or increase of multi-echo data, the <--t2s-coreg> flag enables the use of a T2* map instead of the BOLD reference image
  • EPI to standard space: pre-processed images from above re tranformed to a standard space (e.g., MNI) and fsaverage (if FreeSurfer is enabled)
  • Confounds estimation: noise components, motion parameters, and global signals are estimated from the preprocessed image
  • Denoising can be performed with ICA-AROMA

Checking the output:

Here is an example of what the output structure:

Screenshot 2025-03-04 142102

The good thing about fMRIPrep is that it will spit out an intuitive .html doc for your subjects following analyses (located at fmriprep/derivatives/fmriprep). You should comb through these documents to ensure that there is nothing out of the ordinary. You should check that, in general, there are not any obvious discrepancies or errors in the:

  • Brain mask and brain tissue segmentation of the T1w: just make sure the lines are in general tracing things correctly without going into the skull or space outside the head
  • Spatial normalisation of the T1w ref to MNI: just make sure that the images are well aligned in the same space (hover your mouse over the image and it will toggle)
  • Surface recon: just make sure the lines are in general tracing things correctly without going into the skull or space outside the head
  • T2 map: just make sure the lines are in general tracing things correctly without going into the skull or space outside the head
  • Alignment of functional and anatomical MRI data: just make sure the lines are in general tracing things correctly without going into the skull or space outside the head

You should also read through the boilerplate in the Methods section to ensure that it looks like fMRIPrep has executed steps that make sense for your data. For example, if you included fieldmap data for SDC, does fMRIPrep run SDC using that data (per what is desired?).

Finally, scroll to the bottom of the document - and make sure that there are no errors to report in the Errors section.

If you get stuck, it is definitely worth checking out NeuroStars and Github - there may be existing forums which can point you in the right direction.

Extra resources

Have a look at Nibabies: fMRIprep for infant imaging data.

https://fmriprep.org/en/stable/workflows.html

https://github.com/poldracklab/fmriprep

https://www.youtube.com/watch?v=J0npRWV2zTY

https://fmriprep.readthedocs.io/en/stable/usage.html

https://neurostars.org/t/combining-fmriprep-with-me-ica-from-tedana/3710/8

Clone this wiki locally