Course Overview and Introduction
Last updated on 2022-11-15 | Edit this page
Estimated time: 25 minutes
This document is based on the slides here Google Slides
Functional Neuroimaging in Python
Welcome to the Functional Neuroimaging Analysis in Python workshop! In this workshpo we’ll get you up to speed with the current tools and techniques used in the analysis of functional MRI (fMRI) data. The primary goals of this workshop are:
- Understand how neuroimaging data is stored, and how it helps us perform analysis
- Gain familiarity with the issues surrounding the analysis of fMRI data, and how we can combat it in pre-processing and analysis
- Learn how to analyze neuroimaging data, working from beginning to end
- Get comfortable with Python as a tool for analysis and visualization of data
The Central Objective
This workshop is designed to teach you the basics and work up to performing an intra-network functional connectivity analysis of the Default Mode Network in individuals with Schizophrenia and compare them to a Control population.
All of this sounds fancy, but we’ll explain in depth what this looks like in practice as the course goes along.
A breakdown of material
The material covered will be:
- Preprocessing fMRI data
- Exploring fMRIPrep preprocessing pipeline outputs using pyBIDS
- Introduction to Nilearn and Image manipulation
- Integrating functional time-series data
- Parcellating your data
- Confound cleaning fMRI time-series signals
- Functional Connectivity Analysis
Pre-processing
You’re a researcher who’s collected some nice MR images, and put in some work organizing your data into a BIDS dataset. Now you’re rarin’ to go and want to play with some data and get some science done. However, fMRI data is messy, there are a ton of issues that you need to overcome before you can even begin to analyze your data, this is called pre-processing. Here are some of the issues:
- We have whole head images, we just want the brain
- Your fMRI image and T1 (anatomical) image are not aligned with each other
- Your fMRI image is distorted due to changing magnetic fields in some areas of the brain
- People move, the fMRI image is misaligned through time
- Movement influences the fMRI signal itself! We want brain signals not motion signals
- All subject images aren’t aligned with each other, and furthermore have different brain shapes and sizes. How can we perform a group analysis (i.e averaging etc..) if all our samples are different from one another? We need to normalize our data
This seems like a lot of problems to deal with… A pictoral guide of what dealing with these problems looks like follows below:
Visual Guide to Pre-processing T1 images
First we’ll want to deal with our structural data; this is called the T1 image. Preprocessing the T1 image consists of the following steps:
- Brain extraction - we want to analyze brains, not skulls
- Normalization - since brains are different across people, we need a method to make them look more alike so we can perform group analysis. This is achieved using a non-linear warp which squishes and pulls the brain to look like a template image
Visual Guide to Pre-processing fMRI data
With fMRI data things are a bit more complicated since you have to deal with:
- Motion across time
- Distortion artifacts due to magnetic field inhomogeneities
The following steps are required (at minimum!):
- Brain extraction - again we’re only interested in the brain
- Motion correction - we need to align the fMRI data across time
- Susceptibility Distortion Correction (SDC) - we need to correct for magnetic field inhomogeneities
- Alignment to the T1 image - aligning to the T1 image allows us to perform the *squishy/pully” normalization to make everyone’s brain more alike
- Confound regression - not only does motion misalign brains it also corrupts the signal with motion signal artifacts, this also needs to be cleaned!
So how does one begin to even accomplish this? Traditionally, neuroimagers used a plethora of tools like, but not limited to: FSL, AFNI, FREESURFER, ANTS, SPM. Each with their own quirks and file format requirements.
Unfortunately this is difficult to navigate, and each tool develops new techniques to better peform each of these pre-processing steps. Luckily, if your data is in a BIDS Format, there exists a tool, fMRIPrep, which does this all for you while using the best methods across most of these tools!. An image below from their website depicts the processing steps they use:
Ultimately, fMRIPrep is an end-to-end pipeline - meaning that you feed it your raw organized data and it’ll produce a bunch of outputs that you can use for analysis! What follows below are explanations of what those outputs are:
fMRIPrep anatomical outputs
Native Space
- sub-xxxxx_T1w_brainmask.nii - a binary mask which can be used to pull out just the brain
- sub-xxxxx_T1w_preproc.nii - the fully cleaned T1 image which has not been normalized
MNI (Normalized) Space
- sub-xxxxx_T1w_space-MNI152NLin2009cAsym_brainmask.nii.gz - also a brain mask, but warped to fit a template brain (the template is MNI152NLin2009cAsym)
- sub-xxxxx_T1w_space-MNI152NLin2009cAsym_class-(CSF/GM/WM)_probtissue.nii.gz - probability values for each of the tissue types. We won’t get into too much detail with this one
- sub-xxxxx_T1w_space-MNI152NLin2009cAsym_preproc..nii - the cleaned up T1 image that has been squished and warped into the MNI152NLin2009cAsym template space
fMRIPrep functional outputs
As above we have both Native and Normalized versions of the fMRI brain, we have a mask of each one as well as the preprocessed fMRI brain.
Note: These have not been cleaned of motion artifacts. They have only been aligned, distortion corrected, and skull-stripped.
fMRIPrep also outputs a sub-xxxxx_task-…_confounds.tsv tab-delimited spreadsheet which contains a set of nuisance regressors that you can use to clean the signal itself of motion artifacts. We’ll explore this in a later section.
End
In the next section we’ll start exploring the outputs generated by fMRIPrep to get a better handle of how to use them to manipulate images, clean motion signals, and perform analysis!
Key Points
- fMRI data is dirty and needs to be cleaned, aligned, and transformed before being able to use
- There are standards in place which will allow you to effortlessly pull the data that you need for analysis