It’s currently day n of shelter-at-home of covid-19 pandemic times, and I’ve started to dig myself into a hole with fMRI preprocessing using some (relatively) fancy new tools on a fancy supercomputer cluster, which I, fortunately, have access to at Brown. One of the blessings (and/or curse, depending on how you view it) of being a postdoc is that despite these pandemic times, you realize you really have no serious responsibilities and much freedom. In some ways, you can potentially be disposable, but also potentially indispensable depending on the circumstances. That being said, one of the true perks of being a postdoc is that your primary job is to do a lot of data crunching and analysis (and writing), so as long as you have data, it’s not too bad of a gig, and as long as you have a generous PI who is willing to pay for you to analyze the data.
Okay, so given that abundance of time I have to dig into the weeds of fMRI preprocessing, I’ve decided it’s not a terrible time to start documenting some of these analyses adventures, in case it may potentially be useful to others. Also, a colleague of mine who blogs her work regularly (check out her blog on mvpa here) encouraged me to do this a while back when I was fidgeting with using syringe pumps in the scanner. (I highly discourage any PhD candidate from doing this, unless you really enjoy tinkering with equipment). Basically, I’ve spend the last decade of my life tinkering around with different fMRI analyses Softwares, and recently have decided to make the full switch to fMRIPrep to make my life easier — so I suppose that these blogposts in upcoming weeks (months? lets hope not…) will be directly most useful folks who know a think or two (or many) about fMRI, and may want to get their feet wet with using this cool innovative wrapper that makes preprocessing less of a headache. That, and I have a terrible memory, so this will hopefully helpful for me 5 to 10 years down the road. Anyways, since here goes nothing.
So, you want to get started with fMRIprep (on a computer cluster)?
Some basics to get familiar with, if you have limited computer programming background:
- Docker: https://www.docker.com/
- Linux Command Basics: https://help.ubuntu.com/community/UsingTheTerminal
(scroll down to File & Directory commands, this will help you navigate on the Terminal on your server) - Bash Scripting: https://www.shellscript.sh/
- Some Text Editors for editing code (without gouging your eyes out):
- Visual Studio: https://code.visualstudio.com/
- Sublime: https://www.sublimetext.com/
Some Excellent Books on getting started with fMRI analyses:
- Handbook of Functional MRI (Poldrack): http://www.fmri-data-analysis.org/
- fMRI (Bandettini): https://mitpress.mit.edu/books/fmri
(I’ve really loved reading this book, it provides an excellent historical overview of the field in the last 30 years. definitely an enjoyable read to novices and veterans alike!) - Functional Magnetic Resonance Imaging (Huettel): http://sites.sinauer.com/fmri3e/index.html
(This is a classic textbook, but incredibly dense! If you’re into the physics of fMRI, this is definitely the book for you) - Statistical Analysis of fMRI Data (Ashby): https://mitpress.mit.edu/books/statistical-analysis-fmri-data-second-edition
Here are some more Brown-specific resources:
- XNAT: https://bnc.brown.edu/xnat/ (MRI Data Storage)
- Oscar: https://docs.ccv.brown.edu/oscar/ (Brown’s supercomputer, Note that if you are a Brown user, you will need to request an account)
- Behavioral Neuroimaging Core (BNC)User Manual: https://docs.ccv.brown.edu/bnc-user-manual/
- BNC Github Repository: https://github.com/brown-bnc/bnctools
fMRIPrep Resources
- fMRIprep Docs: https://fmriprep.readthedocs.io/en/stable/
(I highly recommend reading this paper if you are interested in looking under the hood to understand which functions are being implemented) - fMRIprep Github Repository: https://github.com/poldracklab/fmriprep
- Neurostars Forum: https://neurostars.org/( a great place to ask questions and/or see if your questions have already been answered by experts)
Since I’ll be working on our university’s supercomputer, I’ll likely provide more detailed instructions regarding those types of analyses, but if you plan to run some of these analyses from a local computer, you can easily apply much of the scripts using “bash” instead of “sbatch” commands, since you won’t have parallel computing available. The only downside is that your computer may sound like a rocket when you’re running such analyses, and it may take a longer time for your scripts to finish. I will probably have separate blog posts that address each of these steps as I do them, so stay tuned if your appetite for fMRI preprocessing is still growing. Nevertheless, hopefully, this will be useful to some of your hypothetical readers *fingers crossed.*
Some general high-level steps to consider
Step 1: Exporting Data and Converting to BIDS
- Brain Imaging Data Structure (BIDS): https://bids.neuroimaging.io/
(basically a fancy way to implement a standard for naming files) - Heudiconv: https://github.com/nipy/heudiconv
(this is useful tool to incorporate to get your data into BIDS format)
Step 2: Validating that your MRI dataset is BIDS-compatible
- Getting Started with the BIDS Validator (easy):
- Installing the Validator and running on your computer (medium/hard):
- BIDs Validator Github Repository: https://github.com/bids-standard/bids-validator
(Optional) Step 2a: Quality Control checks for your MRI dataset
- Run mriqc: https://mriqc.readthedocs.io/en/stable/
(While this step is not required to run fMRIprep, it can be a helpful way to visualize and check that your data are of high quality!)
Step 4: Run fMRIprep on your MRI dataset using singularity or docker containers
- Singularity: https://fmriprep.readthedocs.io/en/stable/singularity.html
- Docker: https://fmriprep.readthedocs.io/en/stable/docker.html
It is worth noting that there are still a few quirks to this seemingly magical tool. Although fMRIPprep is pretty good automating most of the preprocessing steps, here are some things that it does NOT do automatically. It is still possible to implement these steps, it just requires a bit of tweaking, and such things would be good to consider in the data processing steam in the future.
- Spatial Smoothing
- A useful reference: http://jpeelle.net/mri/image_processing/smoothing.html
(This is just a fancy of way of saying we’re going to blur your data with a gaussian kernal to reduce false-positive results and improve signal to noise).
- A useful reference: http://jpeelle.net/mri/image_processing/smoothing.html
- Fieldmap correction
- https://fmriprep.readthedocs.io/en/stable/sdc.html
(These will differ depending on whether you have a gradient or spinecho fieldmap)
- https://fmriprep.readthedocs.io/en/stable/sdc.html
I think I’ve inundated you with enough links for now. I will probably update this post as I think of more resources. Feel free to leave a comment below for suggestions on resources or anything I may have missed!