Regions of Interest (ROIs)¶
When conducting fMRI analyses, we often focus on specific brain regions based on theoretical or empirical questions. These Regions of Interest (ROIs) are defined areas in the brain that we hypothesize to be relevant to a particular cognitive function or task.
By restricting the analysis to ROIs, researchers can improve statistical power, focus on hypothesized brain areas, and extract data for multivariate pattern analyses (MVPA).
Commonly Used ROI Types¶
The following types of ROIs are commonly used in fMRI research:
- Anatomical ROIs: These are based on anatomical landmarks, often derived from standard brain atlases.
- Functional ROIs: Defined based on brain activation patterns observed in functional localizer tasks.
- Spherical ROIs: Spheres around specific MNI coordinates, offering a quick, automated way to generate ROIs.
Example: Creating Spherical ROIs with the GUI¶
You can create spherical ROIs interactively using the MarsBaR toolbox within SPM. Here is the step-by-step procedure:
-
Launch MarsBaR: In the MATLAB command window, type
marsbarto open the MarsBaR GUI. Alternatively, start SPM and select MarsBaR from the toolbox menu. -
Create a new ROI: In the MarsBaR menu, go to ROI definition > Build.
-
Select ROI type: Choose Sphere from the shape options.
-
Enter MNI coordinates: A dialog will ask for the centre coordinates. Enter the X, Y, Z coordinates in MNI space (e.g.,
[42 -54 -18]for right FFA). -
Set the radius: Enter the sphere radius in millimetres (a common choice is 8–10 mm).
-
Label the ROI: Give the ROI a descriptive name (e.g.,
ROI-rFFA_radius-10). -
Save the ROI: MarsBaR saves ROIs in its own
.matformat. To convert to NIfTI for use in other tools:- Go to ROI definition > Export (or ROI definition > Save as image).
- Select the ROI
.matfile and choose an output.niifilename. - Specify the reference image (e.g., a subject's functional image or the MNI template) to define the voxel grid.
Tip
You can create multiple ROIs in sequence by repeating steps 2–7. For bilateral ROIs, create one ROI per hemisphere using mirrored X coordinates (e.g., [-42 -54 -18] and [42 -54 -18]).
Example: Creating Spherical ROIs with a Script¶
Below is an example MATLAB script designed to creare bilateral ROIs. This script leverages MarsBaR and SPM to generate spherical ROIs around given MNI coordinates. The ROIs are saved as NIfTI files, which can be further used in analyses such as multivariate decoding.
Script for Creating Spherical ROIs in MATLAB
| makeROISpheres.m | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
This script will output a folder as follow:
rois
└── radius_5mm
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-Caudatus.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA1.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA2.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-FFA.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-LOC.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-OTJ.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG_OTJ.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTL_OTJ.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-PPA.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-RSC_PCC.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-SMG1.nii
├── hemi-B_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-TPJ.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-Caudatus.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA1.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA2.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-FFA.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-LOC.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-OTJ.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-PCC1.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG_OTJ.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTL_OTJ.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-PPA.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-RSC_PCC.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-SMG1.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-SMG2.nii
├── hemi-L_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-TPJ.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-Caudatus.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA1.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-CoS_PPA2.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-FFA.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-LOC.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-OTJ.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTG_OTJ.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-pMTL_OTJ.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-PPA.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-RSC_PCC.nii
├── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-SMG1.nii
└── hemi-R_space-MNI152NLin2009cAsym_res-2_radius-5mm_label-TPJ.nii
With right (hemi-R), left (hemi-L) and bilateral (hemi-B) masks.
The size of the ROIs is defined in millimeters, and is a list of radii such as m.radii = [5, 10]; (see line 19 of the makeROISpheres.m script).
Warning
The bilateral masks will be generated automatically only when both R and L coordinates are provided for a given ROI. If only R or L coordinates are provided, only the R or L mask will be saved.
HCP Glasser Parcellation (HCP-MMP1.0)¶
The Glasser2016 parcellation (HCP-MMP1.0) provides a comprehensive cortical atlas with 180 ROIs per hemisphere, based on the Human Connectome Project Multi-Modal Parcellation. This parcellation is particularly useful for whole-brain ROI-based analyses such as MVPA, where you want to systematically decode information across all cortical regions.
Using the Glasser atlas in MNI space¶
If you are running your analyses in a common volumetric space (e.g., MNI) — which is the most common approach — you can use a ready-made MNI volumetric version of the Glasser atlas provided by AFNI:
- Atlas file:
MNI_Glasser_HCP_v1.0.nii.gz - Documentation and additional files: MNI_HCP atlas folder
This atlas can be used directly with your MNI-space beta images (e.g., from fMRIPrep with MNI152NLin2009cAsym output space) without any further projection or transformation steps.
Projecting the Glasser atlas to subject space¶
If you need higher-fidelity, subject-specific ROIs — for instance, when running analyses in native subject space — you can project the Glasser parcellation from fsaverage to each individual subject. This involves converting annotation files to labels and mapping them through FreeSurfer's surface registration. The result is a set of volumetric ROIs in each subject's T1 space that respect individual cortical folding patterns.
Automating Glasser projection with HPC-to-subject.sh
If you are using the Glasser parcellation across many subjects, you can automate the projection from fsaverage to subject space using a shell script (e.g., HPC-to-subject.sh). This script typically:
- Converts Glasser annotation files (
.annot) to individual label files. - Maps each label from
fsaverageto the subject's native surface using FreeSurfer'smri_label2volor similar tools. - Transforms the resulting ROIs into the volumetric spaces used by your analysis (e.g., T1w, MNI).
See the top of the script file for usage notes. An example implementation can be found in the chess-expertise-2025 repository.
Intersecting ROI Masks with GLM Results¶
In our lab, we apply an additional refinement step to Region of Interest (ROI) masks to precisely target the most relevant brain voxels. This involves intersecting the mask (e.g., a spherical or anatomical ROI) with the significant activation of a specific contrast. This approach is particularly beneficial for analyses like multivariate pattern analysis (MVPA), where targeted voxel selection is crucial for decoding tasks.
For instance, suppose we want to perform an MVPA to determine if we can distinguish between Female and Male faces in the Fusiform Face Area (FFA). Here’s how we might set up the analysis:
-
Create an Initial ROI Mask:
- First, we create a NIfTI file with values of 1 in the FFA region and 0 elsewhere. This mask can be created either anatomically (using an atlas) or by defining a spherical mask centered on FFA coordinates.
-
Run a First-Level Analysis to Identify Activation in the ROI:
- In SPM, perform a First-Level analysis to obtain significant activation for a relevant contrast, such as Faces vs. Objects. This will produce a t-map that indicates the t values of all voxels for the given contrast.
What contrasts should I use?
- If we use a localizer run (i.e., a run where participants are shown categories for functional localization), then we can set up contrasts based on well-established literature. For example, for the FFA, the Faces > Objects contrast is commonly used; for LOC, Objects > Scrambled is typical.
- If we use the experimental task run (i.e., when participants perform the main task), we generally choose contrasts that reflect overall activity in the region. For example, we might use an All > Rest contrast where all experimental conditions are positive and rest blocks are negative, capturing the regions most active during the task overall.
-
Threshold the Activation Map
- Apply a statistical threshold to the t-map, setting a significance level (e.g., p < .001) to identify the voxels significantly active for the contrast of interest.
-
Intersect Masked and Activated Voxels
- Generate a new ROI that includes only the voxels both significantly active in the contrast and within the initial mask (e.g., sphere or anatomical region).
-
Extract beta values from selected voxels
- We use the generated ROI to filter voxels in the beta images (the
beta_00*.niiimages in the SPM GLM output folder) for further MVPA.
- We use the generated ROI to filter voxels in the beta images (the
This approach has two key benefits:
- Selective Targeting of Relevant Voxels: It ensures that the ROI captures only the voxels relevant for the cognitive function of interest, maximizing information and minimizing potential noise from uninformative voxels.
- Feature Reduction: Reducing the number of features (voxels) helps improve the classifier's performance by mitigating the Curse of Dimensionality (see this article on dimensionality reduction for more info).
Example: Generating Refined ROIs by Intersecting Masks with Activation Maps¶
The following MATLAB script refines ROIs by intersecting an initial mask (e.g., anatomical or spherical) with a subject-specific activation map from an SPM contrast. This approach is particularly valuable for targeted analyses, such as multivariate pattern analysis (MVPA).
Script Workflow¶
- Thresholding: Applies a statistical threshold to the contrast map, identifying only voxels with significant activation.
- Intersection: Intersects these significant voxels with the ROI mask to focus on relevant areas within the predefined region.
- Voxel Count Check: Ensures the resulting ROI contains a minimum number of significant voxels (default: 25). If the voxel count is too low, the significance threshold is incrementally relaxed until the minimum count is met.
- Saving Results: Exports the final ROI in both NIfTI (
.nii) and MATLAB (.mat) formats, making it ready for further analysis.
Finding Contrast Names in SPM
To find the exact names of contrasts in an SPM model, load the SPM.mat file and check SPM.xCon.name. This allows you to confirm the contrast names required for the contrastName field in roisStruct.
Script to Create ROIs from an Image Mask and Statistical Activation Map
| intersectROIandGLM.m | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
This code generates a new folder containing subject-specific ROIs. While previous spherical or anatomical masks were likely generic—created in a standard space (e.g., MNI) and therefore applicable to any subject within that space — these new ROIs are specific for each subject, since they are created by intersecting the generic mask with the subject's unique pattern of activation from the GLM t-map.
Now that you have your beta images (from the GLM) and your ROIs, you have everything you need to run your multi-variate analysis. → MVPA
Atlas Resources and Functional Databases¶
Beyond the Glasser parcellation used in the examples above, many other atlases and databases can be used to define ROIs:
Commonly used atlases¶
| Atlas | Regions | Type | Where to get it |
|---|---|---|---|
| Glasser (HCP-MMP1) | 360 (cortical) | Multi-modal | TemplateFlow or original paper |
| Schaefer | 100–1000 | Functional parcellation | GitHub |
| Harvard-Oxford | 48 cortical + 21 subcortical | Probabilistic anatomical | Distributed with FSL; also in nilearn.datasets |
Functional databases for meta-analytic ROIs¶
| Database | Description | Link |
|---|---|---|
| NeuroSynth | Automated meta-analysis platform. Generate activation maps from thousands of studies using keyword search. | neurosynth.org |
| Neuroquery | Multivariate meta-analysis tool that predicts brain maps from text queries. | neuroquery.org |
| OpenNeuro | Open repository of neuroimaging datasets. Useful for finding localiser data and task contrasts. | openneuro.org |
| Neuroimaging Core Atlas Docs | Practical guide to working with brain atlases. | readthedocs |
Loading atlases in Python
Nilearn provides convenient functions to fetch and load many standard atlases directly:
For a broader overview of atlases and templates, see the Brain Atlases and Templates section on the fMRI landing page.
Extracting Signal from ROIs with Python¶
As an alternative to the MATLAB workflow above, you can use nilearn to extract signal from ROIs:
from nilearn.maskers import NiftiMasker
# Load an ROI mask and extract signal from functional data
masker = NiftiMasker(mask_img='path/to/roi_mask.nii.gz', standardize=True)
signals = masker.fit_transform('path/to/func_bold.nii.gz')
print(f"Extracted signal shape: {signals.shape}") # (n_timepoints, n_voxels)
For atlas-based parcellations (extracting one signal per region):
from nilearn.maskers import NiftiLabelsMasker
masker = NiftiLabelsMasker(labels_img='path/to/schaefer_400.nii.gz', standardize=True)
region_signals = masker.fit_transform('path/to/func_bold.nii.gz')
print(f"Region signals shape: {region_signals.shape}") # (n_timepoints, n_regions)
For more examples, see the nilearn masker documentation.