Region Of Interest analysis of BOLD data

[This article was first published on macsci, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


For my research I do Region-Of-Interest (ROI) analyses of BOLD fMRI data. That is, we look at how brain activity develops in certain predefined brain regions during an experiment. On this site I describe a script that automates these analyses, using SPM, MarsBaR, Matlab, & R.

Let’s start with a short example of an Region-Of-Interest analysis: When you let a person look at a stimulus, you will find a certain pattern of brain activation in the fusiform gyrus (the ROI here, it does visual processing):


At scan 1 the stimulus was presented; you can see that the BOLD response is sluggish, only 3 scans later (= 4.5 seconds) the activity reaches its peak. How do we get from the raw scanner data to such graphs, how are these ROI-analyses done?

fMRI analyses are often performed using the software package SPM (Statistical Parametric Mapping, Wellcome Trust Centre for Neuroimaging). For doing Region-Of-Interest analyses in SPM, the toolbox MarsBaR was developed. MarsBaR can be used to define ROIs, and to get the raw BOLD data from such regions (MarsBaR can also be used for more sophisticated analyses, see the MarsBaR website).

While MarsBaR is really useful as it is, it gets a little tedious to do the analyses by hand. As I often do the same sort of analyses (analyzing 16 predefined regions, see, I automized the whole procedure as a shell script, called jpbplot. The script calls an R file, which, in turn, executes a matlab function that calls SPM and MarsBaR.

The script takes as input four arguments: the design of your experiment (more on that below), the ROI(s) you want to analyze, the names of your conditions, and the scans you want to use as a baseline. For example, to analyze a visual and a manual ROI with a two condition design, you could execute the following in a terminal window:

jpbplot experimentDesign.df visual_roi.mat,motor_roi.mat condition1_condition2 1,2

which will give you two pdf-files: the average bold response in each ROI


(see the example on the right) and the bold response per participant in each ROI. Furthermore, it will output a data file with the raw bold values in your ROI(s), per participant and condition, which can be used for further analyses.

As described above, you have to tell the script which ROIs it has to analyze. The ROIs that can be used have to be made with MarsBaR, 16 example ROIs are included in the zip-file containing jpbplot. These are the regions that are used for ACT-R fMRI research; as a shortcut you can use ‘ACT-R’ instead of these ROI-names when you call the script. For example, this will analyze all ACT-R regions:

jpbplot experimentDesign.df ACT-R condition1_condition2 1,2

You also have to provide the script with a ‘design’-file, containing your experimental design. The design-file contains a list of your raw scan-files on disk, linking those files to participant number, condition, and scan within a trial. Thus, say one trial takes 3 scans (= 6 seconds), and you have two conditions that can both be EASY and HARD, the top of the design file may look like this (the first 5 trials of the first participant):

1 EASY HARD 1 /Volumes/fMRI/pp1/functional/smoothed_00001
1 EASY HARD 2 /Volumes/fMRI/pp1/functional/smoothed_00002
1 EASY HARD 3 /Volumes/fMRI/pp1/functional/smoothed_00003
1 EASY EASY 1 /Volumes/fMRI/pp1/functional/smoothed_00004
1 EASY EASY 2 /Volumes/fMRI/pp1/functional/smoothed_00005
1 EASY EASY 3 /Volumes/fMRI/pp1/functional/smoothed_00006
1 HARD HARD 1 /Volumes/fMRI/pp1/functional/smoothed_00007
1 HARD HARD 2 /Volumes/fMRI/pp1/functional/smoothed_00008
1 HARD HARD 3 /Volumes/fMRI/pp1/functional/smoothed_00009
1 EASY HARD 1 /Volumes/fMRI/pp1/functional/smoothed_000010
1 EASY HARD 2 /Volumes/fMRI/pp1/functional/smoothed_000011
1 EASY HARD 3 /Volumes/fMRI/pp1/functional/smoothed_000012
1 HARD EASY 1 /Volumes/fMRI/pp1/functional/smoothed_000013
1 HARD EASY 2 /Volumes/fMRI/pp1/functional/smoothed_000014
1 HARD EASY 3 /Volumes/fMRI/pp1/functional/smoothed_000015

Thus, each line contains the participant number, the two conditions, the scan-within-a-trial, and the filename of the scan file (in that order; trials are not numbered, it is assumed that the the scan-files are listed in the order in which they were acquired). If you have more or less than two conditions you simply include more or less columns: if you have only one condition, you could leave out the 3rd column, if you have 12 conditions, columns 2-13 would describe the conditions. The list should contain all scan-files you want to analyze; each trial must have the same number of scans (you can remove scans for subsequent analyses using the raw data file that is part of jpbplot’s output). A complete example.df is included in the zip-file.

jpbplot is based on jmfplot, which can be used for the same kind of analyses, but uses different analysis and ROI software than SPM and MarsBaR. jmfplot was developed by Jon M. Fincham.

If you would like to use jpbplot, you can find a zip-file here with the scripts and ROIs. The zip-file also contains a readme.txt which explains how to install jpbplot and describes the design file in a little more detail. If you have any questions, don’t hesitate to email me!


To leave a comment for the author, please follow the link and comment on their blog: macsci. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)