Resting-state fMRI processing

This module performs all pre-processing of a subject’s resting-state functional MRI (rsfMRI) scans, in preparation for the construction of functional connectomes. This pipeline is optimized for spin-echo images with reverse phase encoding used for distortion correction. The pipeline is mainly based on tools from FSL and AFNI for volumetric processing, and FreeSurfer and Workbench for surface-based mapping. For increased functionality, micapipe can also handle protocols in which a single fieldmap is acquired.



Prerequisites 🖐🏼

You need to run -proc_structural, -proc_freesurfer and -post_structural before this stage

  • Remove first five TRs and reorient to LPI
  • Reorients to standard
  • Perform motion correction within rsfMRI scan and provided fieldmaps by registering each volume to the scan’s own average
  • Calculate motion outliers
  • Apply distortion correction on motion-corrected images
  • Calculate binary mask from motion and distortion corrected volume
  • High-pass filtering of rsfMRI timeseries to remove frequencies below 0.01Hz
  • Run Multivariate Exploratory Linear Optimized Decomposition into Independent Components (MELODIC) on filtered timeseries
  • Compute linear and non-linear registrations between fMRI and T1-nativepro space, as well as boundary-based registration between fMRI and native Freesurfer space
  • Run FMRIB’s ICA-based Xnoiseifier (ICA-FIX) using specified training file. Note that if ICA-FIX is not found on the user’s system, or if MELODIC failed, ICA-FIX will be skipped and further processing will be performed using high-pass filtered timeseries
  • Calculate global and tissue-specific signal from processed timeseries (can be used for global-signal regression)
  • Compute motion confounds matrix from processed timeseries, to remove effects of frames with large motion in the timeseries
  • Register processed timeseries to native cortical surface. Minimially pre-processed (i.e. motion and distortion corrected) timeseries are also registered to the native cortical surface to compute statistics such as temporal signal-to-noise
  • Surface-template registration of native surface timeseries (fsaverage5, conte69)
  • Native surface, fsaverage5, and conte69-mapped timeseries are each smoothed with a 10mm Gaussian kernel
  • Use previously computed registrations to align cerebellar and subcortical parcellation to fMRI space
  • Regress motion spikes (and tissue-specific or global signal variables, if specified by user) from cerebellar, subcortical, and cortical timeseries in linear model
  • Concatenate cerebellar, subcortical, and parcellated cortical timeseries and compute correlation matrix


$ mica-pipe -sub <subject_id> -out <outputDirectory> -bids <BIDS-directory> -proc_rsfmri

Docker command:

$ docker -proc_rsfmri

Optional arguments:

-proc_rsfmri has several optional arguments:

Optional argument Description
-mainScanStr <str> String to manually identify the main scan for rsfMRI processing (eg. func/sub-001_<mainScanStr>.nii.gz). Default string is task-rest_acq-AP_bold.
-fmri_pe <path> Full path to the main phase encoding scan for rsfMRI processing. Default string is task-rest_acq-APse_bold.
-fmri_rpe <path> Full path to the reverse phase encoding scan for rsfMRI processing. If the path is wrong topup will be skipped! Default string is task-rest_acq-PAse_bold.
-mainScanRun <num> If multiple resting-state scan runs exist in the BIDS rawdata, you must specify which scan to process using this flag (e.g. ‘1’).
-phaseReversalRun <num> If multiple phase encoding runs exist in the BIDS directory (only main phase is checked), you must specify which file to process using this flag (e.g. ‘1’).
-topupConfig <path> Specify path to config file that should be used for distortion correction using topup. Default is ${FSLDIR}/etc/flirtsch/b02b0_1.cnf.
-smoothWithWB Specify this option to use workbench tools for surface-based smoothing (more memory intensive), The default smoothing is performed with freesurfer tools: mri_surf2surf.
-regress_WM_CSF Specify this option to perform white matter and CSF signal regression of timeseries. Default = no white matter and CSF signal regression.
-GSR Specify this option to perform global signal regression of timeseries. By default, no global regression is performed.
-noFIX Specify this option to skip ICA-FIX processing. By default, FIX will run with the default training file.
-icafixTraining <path> Path to specified ICA-FIX training file for nuisance signal regression (file.RData). Default is ${MICAPIPE}/functions/MICAMTL_training_15HC_15PX.RData.
-regAffine Specify this option to perform an Affine registration ONLY from rsfMRI to T1w. By default, rsfMRI processing in micapipe performs a non linear registration using ANTs-SyN. We recommend this option for rsfMRI acquisitions with low resolution and/or low SNR.
-sesAnat <str> If longitudinal data is provided, this flag allows to register the current functional session to the desired anatomical session

Distortion correction ✅

If the script can’t find the fmri_rpe (reverse phase encoding), or fmri_pe (phase encoding) images, distortion correction will be skipped. If you provide the path to the fmri_pe and fmri_rpe images, make sure the paths are correct! The possible scenarios and conditions in which topup is run (or skipped) are presented in the table below:

Inputs Output
fmri_rpe fmri_pe topup
Yes Yes runs using pe and rpe
Yes No runs using main as pe
No No skipped

Notes on ICA-Melodic and ICA-FIX 🛁

FIX and Melodic are used by default to remove nuisance variable signal. However, our default parameters might not suit all databases. Our default training file used for FIX was trained in-house, on a subset of 30 participants (15 healthy controls, 15 patients with drug-resistant epilepsy). Scans were acquires on a 3T Siemens Magnetom Prisma-Fit equipped with a 64-channel head coil. rs-fMRI scans of 7 minutes were acquired using multiband accelerated 2D-BOLD echo-planar imaging (3mm isotropic voxels, TR=600ms, TE=30ms, flip angle=52°, FOV=240×240mm2, slice thickness=3mm, mb factor=6, echo spacing=0.54ms). If your acquisition parameters are similar to this, it may be appropriate for you to use the defaults options in -proc_rsfmri. Otherwise, if your acquisition parameters are drastically different, we recommend you to train your own dataset for FIX, or do not use FIX and try a different method for nuisance variable signal removal. In the next example,FIX and Melodic will be skipped, but global signal, white matter and CSF regressions will be applied:

mica-pipe -sub <subject_id> -out <outputDirectory> -bids <BIDS-directory> \
          -proc_rsfmri -noFIX -regress_WM_CSF -GSR

Longitudinal acquisitions 👶 👦 👨 👨‍🦳

If your database contains multiple sessions (different days) and you wish to register the rsfMRI to the same anatomical session, you should use the -sesAnat flag. For example if you database looks like:

├── ses-func01
│   └── func
├── ses-func02
│   └── func
└── ses-struct01
    └── anat

You should specify -sesAnat struct01 to register each session to the same anatomical volume. In the next example, sessions func01 and func02 will be registered to the anatomical image in struct01:

 mica-pipe -sub 01 -ses func01 -proc_rsfmri -sesAnat struct01 -bids <bidsDir> -out <outDir>
 mica-pipe -sub 01 -ses func02 -proc_rsfmri -sesAnat struct01 -bids <bidsDir> -out <outDir>

Directories created or populated by -proc_rsfmri:

- <outputDirectory>/micapipe/func
- <outputDirectory>/micapipe/func/ICA_MELODIC
- <outputDirectory>/micapipe/func/surfaces
- <outputDirectory>/micapipe/func/volumetric
- <outputDirectory>/micapipe/xfms

Files generated by -proc_rsfmri:

- All outputs generated by MELODIC, or necessary for ICA-FiX, are stored in:

- All volumetric processing outputs are stored in

    - rsfMRI processing json card:

    - Motion confounds processing (<tag> = reversePhaseScan, mainPhaseScan):

    - Motion outliers and metric values:

    - Motion and distortion corrected image:

    - Mean motion and distortion corrected image:

    - Skull-stipped mean motion and distortion corrected image:

    - High-passed, motion and distortion corrected image:

    - Nuisance-signal regressed timeseries (i.e. output of ICA-FIX):

    - Tissue-specific mean signal (<tissue> = CSF, GM, or WM):

    - Global mean signal:

    - Subcortical segmentation in fMRI space:

    - Mean signal in each subcortical parcel:

    - Cerebellar segmentation in fMRI space:

    - Mean signal in each cerebellar parcel:

    - Parcel statistics for cerebellum, to screen for any missing parcels:

- Vertexwise cortical timeseries (<hemi> = rh, lh)
    stored in <outputDirectory>/micapipe/func/surfaces:

    - Motion and distortion corrected timeseries mapped to native cortical surface:

    - Fully pre-processed timeseries mapped to native cortical surface:

    - Timeseries mapped to fsaverage5 template:

    - Timeseries mapped to conte69 template:

    - Vertexwise and smoothed timeseries on conte69 template, following regression of motion spikes:

- Temporal signal-to-noise ratio computed on native cortical surface from motion and distortion correction timesries:

- Functional connectome matrices (r values) generated from smoothed, parcellated timeseries sampled in subcortex, cerebellum, and cortical surface
   <parc> = up to 18 parcellations

    - Conte69 cortical surface:

    - Native cortical surface:

    - Contatenated timeseries sampled in subcortex, cerebellum, and parcellated native cortical surface models:

- rsfMRI registration files are found in <outputDirectory>/micapipe/<sub>/xfms

    - Boundary based registration from rsfMRI space to native freesurfer space:

    - Affine registration between T1w nativepro and rsfmri space:

    - Non-linear registrations between T1w in dwi space to wmNorm in dwi space: