MIT OpenCourseWare


MATLAB® software is required to view and run the .mat files in this section.

Although not essential, a little experience with and understanding of the basics of MATLAB® will help in these exercises. One source of MATLAB® help and documentation may be found in Manipulating Matrices, which is part of the MATLAB® 6.x documentation. If you don't understand a command in the MATLAB® code fragments you will see below, you can use the help command to get information on it.

The course includes the following six labs:

Lab 0: Introduction to MATLAB® for fMRI

Lab 1: Data Acquisition Lab

Lab 2: Physiology Lab

Lab 3: Improving fMRI Signal Detection using Physiological Data

Lab 4: Diffusion Tensor Imaging Lab

Lab 5: fMRI Data Analysis Tutorial

Lab 6: Cortical and Subcortical Parcellation with MRI

Note that the data and files associated with the labs are not available at this time.

Lab 0: Introduction to MATLAB® for fMRI

This lab consists of some tutorial files that will show you how to use MATLAB® to view brain images and convolve with a hemodynamic response function (HRF).

You will be running through two sets of tutorial exercises in this lab. Each set should take approximately 40 minutes. The first set of exercises gives you a chance to work with MATLAB® command line syntax and introduces some functional MRI terminology and concepts. The second provides an opportunity to use an image visualization software package for interactive exploration of fMRI data.

Lab 1: Data Acquisition Lab

Lab 1 Outline (PDF)

Lab 1 Manual (PDF)

Note that the data and files associated with the labs are not available at this time.

In this analysis lab you will examine time-domain signals from fMRI datasets acquired using different spatial resolutions, imaging rates, and RF receive coils. You will use a MATLAB®-based program called Dview to examine these signals.

Note: Although not essential, a little experience with and understanding of the basics of MATLAB® will help in these exercises. Sources of MATLAB® help and documentation include Manipulating Matrices, which is part of the MATLAB® 6.x documentation. If you don't understand a command in the MATLAB® code fragments you will see below, you can use the help command to get information on it.

The main objectives of the data acquisition and analysis labs are:

  • Familiarization of students with a typical functional MRI scanning environment, from data acquisition to offline visualization and analysis.
  • Acquisition and examination of image data from a phantom (inert test sample) to investigate image intensity non-uniformity, spatial and temporal noise from instrumental sources, and RF receive coil properties.
  • Acquisition and examination of human data to gain familiarity with 3D anatomic visualization using cross-sectional images and compare physiological and instrumental sources of noise.

Lab 2: Physiology Lab

Lab 2 Outline (PDF)

Lab 2 Manual (PDF)

Note that the data and files associated with the labs are not available at this time.

The purpose of this lab is to familiarize you with the effects of global physiological changes on the BOLD signal. It is important to be aware of such effects in fMRI because some experimental protocols may lead to unintentional physiological changes. An example would be a cognitive experiment in which intense concentration or anxiety about performing the task correctly leads subjects to change their breathing. As you will see in this lab, even a modest shift in breathing rate can have a significant effect on the BOLD fMRI signal.

Another reason for studying BOLD responses to global physiological changes is that this is a good way to examine regional differences in BOLD sensitivity. The fractional change in BOLD signal for a given change in blood flow can vary in different parts of the brain, depending on the local density of blood vessels and the physiological state of the particular tissues at rest. It's difficult to study this using neuronal stimulation, because there's no easy way to ensure equivalence of the stimuli used to activate different regions. Respiratory perturbations like the one used in this lab provide a good way to circumvent this problem, because as global perturbations they have a simultaneous and similar effect on all parts of the brain.

In the exercises you will be asked to make a number of observations and answer questions. Your lab report will be the summary of these observations and answers, so be sure to make notes and printouts as you go.

In the exercises you will examine the effects of a relatively modest but sustained change in breathing on the BOLD fMRI signal. In the data acquisition component of this lab, we acquired a number of BOLD EPI datasets including three during which the subject underwent different combinations of breathing change and neuronal activation:

  • Visual stimulation and simultaneous right-hand movement task: in this seven minute long scanning run, the subject was exposed to a visual stimulus throughout the third and fourth minutes. The subject was also instructed to perform repetitive finger tapping movements with her right hand for the two minute period that the visual stimulus was on. During the rest of the scan (the first two minutes and the fifth through seventh minutes) she viewed a uniform grey screen and did not move her hand.

  • Deep breathing, no task: in this run, also seven minutes long, the subject did not receive visual stimulation or move her hand. Instead, she deliberately increased the depth of her breathing for a four minute period during the scan (the second through fifth minutes). Deep breathing lowers the amount of carbon dioxide in the blood, which in turn lowers blood flow throughout the brain (CO2 is a vasodilator). This scan should therefore show us the effects of such a change in blood flow on the BOLD signal in different parts of the brain.

  • Visual stimulation/hand movement plus deep breathing: In this run we combined the events in the two previous scans. That is, the subject breathed more deeply for four minutes and in the middle of this period of hyperventillation she underwent visual stimulation and performed the hand movement task. The purpose of this run is to see how breathing-related effects combine with the responses to visual and motor tasks.

Lab 3: Improving fMRI Signal Detection using Physiological Data

This Lab examines two ways that physiological data can be used to improve fMRI signal detection.

Lab Overview

The organization of the data for this lab is as follows:

Part I: Cardiac Gating

Part II: Clustered Volume Acquisition (CVA)

  • Combining CVA and cardiac gating
  • CVA and temporal sampling

Cardiac Gating

Part I of this Lab focuses on cardiac gating. This technique uses a subject's EKG recorded during an experiment to improve fMRI signal detection. Cardiac gating is used to overcome a technical difficulty associated with functionally imaging brainstem structures. This difficulty arises because there is considerable cardiac-related, pulsatile brainstem motion. Cardiac gating avoids this problem by (1) synchronizing image acquisitions to the subject's heart beat, then (2) correcting image signal strength to account for the variability in interimage interval (TR) that results from fluctuations in heart rate (Guimaraes et. al., 1998).

In this Lab, the effects of cardiac gating are examined for structures in the auditory system. Sounds are processed extensively within auditory brainstem structures, and cardiac gating is important for investigating this processing. The Lab will focus on two particular auditory structures. One is the inferior colliculus. This brainstem structure is a major site of converging projections from both lower and higher brain centers. The second structure is Heschl's gyrus, the site of primary auditory cortex.

Clustered Volume Acquisition (CVA)

Part II of this Lab examines a technique for minimizing the effects of scanner acoustic noise on auditory activation. This technique is called clustered volume acquisition (CVA). Unlike cardiac gating, CVA does not use physiological data recorded during each experiment to improve signal detection. However, the technique is based directly on physiological data, specifically general information concerning the temporal characteristics of fMRI responses (i.e., response latency, duration).

There are two main types of acoustic noise in the imaging environment (Ravicz et al., 2000; Ravicz and Melcher, 2001). One is an on-going noise produced by the pumping of coolant to the magnet. The second, more intense noise is intermittent. It is produced by the scanner gradient coils each time an image is acquired. The noise can pose difficulties for studies using sound stimuli by (1) masking the stimuli, and (2) inducing brain activity that is not related to the stimuli (this noise-related brain activity acts to suppress the fMRI signal changes produced by the intended sound stimuli).

CVA provides a way to reduce the effects of the most problematic noise, namely the noise produced by the gradient coils. CVA involves imaging a volume of slices in a "cluster" and leaving a quiet interval between clusters (Edmister et. al., 1999; Hall et. al., 1999). With this paradigm, the masking effects of the gradient noise can be avoided by presenting sound stimuli during the quiet interval. In addition, the suppressive effect of the gradient noise on auditory activation can be avoided by (1) making the duration of the image cluster shorter than the onset time of the fMRI response to the first image in the cluster, and (2) making the time between clusters (TR) longer than the fMRI response to a cluster.

The benefits of CVA for detecting activation in auditory cortex were illustrated in lecture. In this Lab, you will examine how these benefits can be extended to subcortical structures by combining CVA with cardiac gating. When CVA is used with a long TR (e.g., 8 sec), image signals are sampled far less frequently than in most fMRI studies. The implications of this lower temporal resolution for experimental design will also be examined in this Lab.

  • Part IIa: Combining CVA with Cardiac Gating

    Animal work has shown that the representation of sound in neural firing patterns changes considerably from brainstem to cortex. Suppose you want to examine these changes in humans using fMRI. In other words, you want to sample activation in the various auditory cortical areas that cover the superior temporal lobe (i.e. use multislice imaging) and, simultaneously, detect activation in subcortical auditory structures. This can be accomplished by combining cardiac gating (to optimize detection of brainstem activation) with CVA (to avoid the contaminating effects of the gradient noise). This part of the Lab considers issues related to combining these two techniques.

  • Part IIb: CVA and temporal sampling

    While the contaminating effects of acoustic scanner noise can be reduced using CVA with a long TR (e.g., 8+ sec), the price is diminished temporal resolution. This part of the lab (a) illustrates a potential pitfall of this lower temporal resolution, and (b) examines ways this pitfall can be avoided by controlling the timing between image acquisitions and the auditory stimulation paradigm.

To begin, you will examine the time course of activation in auditory cortex at high temporal resolution (~2 sec) for two example sounds. You will then consider the implications of sampling these time courses at a lower temporal resolution. The example sounds were trains of repeated noise bursts (a stimulus commonly used in auditory neurophysiologic and psychoacoustic investigations). The "noise" of each burst sounds like the static from a radio that is not tuned to a station. For one sound, bursts occurred in a train at a low rate (2/sec). For the other, the rate was high (35/sec). Each burst was ~25 ms long. A detailed examination of the responses to these stimuli can be found in Harms and Melcher, 2002.

Guidelines for Laboratory Report

Your laboratory report should contain answers to the questions specified below. Do not repeat the lab instructions and avoid lengthy introductions. Your report should not exceed 4 pages. Conclude your report with a few sentences summarizing what you learned in the lab.


Guimaraes, A. R., et al. "Imaging Subcortical Auditory Activity in Humans." Human Brain Mapping 6 (1998): 33-41.

Hall, D. A., et al. "Sparse Temporal Sampling in Auditory fMRI." Human Brain Mapping 7 (1999): 213-223.

Edmister, W. B., et al. "Improved Auditory Cortex Imaging Using Clustered Volume Acquisitions." Human Brain Mapping 7 (1999): 89-97.

Harms, M. P., and J. R. Melcher. "Sound Repetition Rate in the Human Auditory Pathway: Representations in the Waveshape and Amplitude of fMRI Activation." J. Neurophysiol. 88 (2002): 1433-1450.

Ravicz, M. E., et al. "Acoustic Noise During Functional Magnetic Resonance Imaging." J. Acoust. Soc. Am. 108 (2000): 1-14.

Ravicz, M. E., and J. R. Melcher. "Isolating the Auditory System from Acoustic Noise During Functional Magnetic Resonance Imaging: Examination of Noise Conduction Through Ear Canal, Head, and Body." J. Acoust. Soc. Am. 109 (2001): 216-231.

Lab 4: Diffusion Tensor Imaging Lab

Lab 4 Manual & Questions (PDF)

Note that the data and files associated with the labs are not available at this time.


In recent years, diffusion tensor imaging (DTI) has emerged as a powerful method for investigating white matter architecture in health and disease. Some common applications include measuring the structural integrity of white matter, mapping white matter fiber orientation, and tracking white matter pathways.

While most MRI methods generate univariate (i.e., scalar) images, for example, T1 or T2 maps, DTI produces multivariate (i.e., tensor-valued) images. Hence, DTI poses a number of interesting image reconstruction and visualization challenges. Accordingly, while the specific objective of this lab is to familiarize you with DTI reconstruction and analysis, the more general goal is to acquaint you with multivariate data visualization and analysis.

For background reading for this lab please read:

Le Bihan, D., J. F. Mangin, C. Poupon, C. A. Clark, S. Pappata, N. Molko, and H. Chabriat. "Diffusion Tensor Imaging: Concepts and Applications." J Magn Reson Imaging 13, 4 (Apr. 2001): 534-546.

Also, please familiarize yourself with three-dimensional graphics navigation in MATLAB® using the camera toolbar.

Lab 5: fMRI Data Analysis Tutorial

Lab 5 Manual & Questions (PDF)

Note that the data and files associated with the labs are not available at this time.


These laboratory exercises complement the lectures and assigned readings on statistical analysis of fMRI data. The goals of this tutorial are to help you with the following:

  • Understanding temporal and spatial correlation in fMRI data;
  • Understanding how to construct a statistical model for fMRI data;
  • Identifying sources of noise and their contribution to fMRI signals; and
  • Understanding the effects of motion correction and spatial filtering on the outcome of statistical analysis of fMRI data.


The data was acquired on a a Siemens 3 T scanner using a head coil and the following acquisition parameters:

TR = 2 s

TE = 30 ms

alpha = 90°

in-plane resolution = 4mm x 4mm (256 mm FOV on 64x64 matrix)

180 time points

21 slices, each 4mm thick with 1mm gap (acquired in interleaved order)


There were 20 epochs of 18 seconds (9 TRs) each. During each epoch, a visual pattern was shown during the first two seconds (1 TR). The pattern consisted of a flashing checkerboard annulus (ring) pattern against a gray background. For the rest of the epoch (16 seconds/8 TRs), only the gray background was present, along with a black dot for fixation.

Lab 6: Cortical and Subcortical Parcellation with MRI

Lab 6 Manual and Questions (PDF)

Note that the data and files associated with the labs are not available at this time.


This Lab examines ways in which different brain anatomical structures can be classified based on the signal intensity of high spatial resolution anatomical MR images acquired with different contrast weightings.

Organization of the Lab

  • You will run a MATLAB® program that loads some images (T1 and proton density maps).
  • You will be asked questions about these images.
  • To answer these questions you will have to process the images using simple MATLAB® functions that you will have to write for this purpose.