This page covers a variety of fMRI preprocessing and analysis methods used in the lab. What this page includes:

  • Data organization

  • Reorienting in SPM

  • Skull stripping in FSL

  • FSL resting state fMRI analysis pipeline

  • SPM task-based fMRI analysis pipeline

Data Organization

Once you have the data in the lab's Discovery share, you'll want to organize your study folder into a systemic format. Your fMRI data should already be in BIDS format. Suggested folder organization:


Reorienting in SPM

No matter what kind of fMRI data you have, you’ll need to reorient the structural and functional volume before you can proceed with other analysis steps. This involves adjusting the pitch, yaw, and roll to make sure the brain isn’t tilted off axes, and setting the origin to the anterior commissure. Here’s how to do it:

  1. Navigate to data folder on Discovery

  2. Launch SPM

    • Launch MATLAB

    • addpath(‘/dartfs-hpc/rc/lab/M/MeyerM/spm12’)

    • In MATLAB, type spm

    • In the SPM menu, click on “fMRI”

    • In new window, click on “Display”

  3. Open subject’s anatomical image

  4. Adjust pitch, roll, and yaw

    • Roll & yaw should be adjusted so vertical crosshair lines up with midline of brain

    • Pitch should be adjusted so the two endpoints of the corpus callosum line up with the horizontal crosshair line

    • Generally use numbers between -1 to 1, but will probably be small adjustments for the most part

    • Reminder of what pitch, yaw & roll are:


5. Set origin to anterior commissure (AC)

  • Zoom in as needed

  • Move crosshair to AC

  • Click “Set origin”

  • Check that the origin has been correctly set by clicking at a random place in the brain, then click “reset.” The crosshairs should move back to the AC

  • This video from Andy’s Brain Blog explains how to find the AC, if you need help

6. Apply reorientation parameters to anatomical & all functional images

  • Click “Reorient images”

  • Select anatomical image & all functional images (their names should all appear in the bottom of the pop-up window

  • A window asking if you want to save the reorientation matrix will pop up. Click “no” (unless you want to save that info)

Skull Stripping in FSL

No matter what kind of fMRI data you have, you’ll also need to skull-strip (aka brain extract) the structural volume before you can proceed with other analysis steps. You can find a script to do this on our lab GitHub.

Always, ALWAYS check the new image to make sure the skull stripping worked properly. If you find the stripping to be too aggressive or lenient, tweak the FIT parameter. To check how skull stripping went:

  1. Navigate to subject’s anatomical folder

  2. Launch FSLview

    • fslview_deprecated&

  3. Open subject’s original structural image

    • Ctrl + shift + O

    • Select image that does not end in “brain”

  4. Layer subject’s skull-stripped structural image on top of it

    • Ctrl + A

    • Select image that ends in “brain”

  5. Check for missing brain

    • If you see any chunks of brain matter, especially PFC, in the original image that get cut off in the skull-stripped image, tweak the FIT parameter and reprocess that subject

  6. Check for non-brain matter

    • If you see chunks of non-brain matter, e.g. dura or skull, in the skull-stripped image, tweak the FIT parameter and reprocess that subject. HOWEVER, if doing so ends up cutting off brain matter, it’s fine to leave bits of dura in


FSL Resting state fmri pipeline

All scripts for this pipeline are located on the lab GitHub. For instructions, see the detailed README file.

SPM task-based fmri pipeline

For instructions on setting up scripts and using this pipeline, see this tutorial by Meghan. (Also below)