# Presentation: 268211

## FMRI Data Analysis:Principles &Practice

**Robert W Cox, PhD**
**SSCC**** ****/**** ****NIMH**** ****/**** ****NIH**** ****/**** ****DHHS**** ****/**** ****USA**** ****/**** ****EARTH**

**Kiel ****–**** 25 May 2007**

**http****:****//****afni.nimh.nih.gov****/****pub****/****tmp****/****Kiel2007****/**

## Ultimate Conclusions First

- FMRI data analysis is built upon many assumptions, arbitrary parameters, and complex software
- Don’t believe the functional activation maps blindly — check the results by “playing” with the data
- FMRI is an intricate process, from acquisition to analysis to interpretation
- Doing it well requires a _**team**_ of experts who work well together

## Warnings & Caveats

- This talk: brief outline of a complex topic
- I usually spend a week teaching this stuff*!*
- Almost everything I say herein has an exception, or a complication, or both
*and*, opinions differ on some of these issues

## Principles: Modeling

- Data analysis always takes place in the context of a mathematical / statistical model
- Model relates the properties of the system being observed to the numbers that are actually measured
- Sometimes the model is implicit in the analysis algorithm, rather than being explicitly stated
- Model must take into account properties of the measurement system
- Models relating FMRI signals to neural activity are complex and tentative

## Principles: Data Quality

- FMRI data are full of rubbish (Abfall):
- Signal changes with neuronal activation are small (similar to noise magnitude)
- MRI signal is several levels of indirection away from neuronal changes of interest
- Numerous other signal fluctuations of non-neural origin have similar or greater magnitude:
- Ghosting, warping, small head movements, scanner imperfections, heartbeat, breathing, long-term drifts, signal dropouts, signal spikes, *et cetera*

## Conclusions from Principles

- It is better to state the mathematical model rather than implicitly rely on an algorithm
- To understand what is being computed
- It is important to try to reduce the rubbish in the data
- Reduce it at the source *and* in the analysis
- More data is better (to average out the rubbish)
- It is important to examine the processed data visually at each step in the analysis, to ensure that nothing bad has happened
- You should understand the process and results

## The Data

- 10,000..50,000 image voxels inside brain (resolution  2-3 mm)
- 100..1000+ time points in each voxel (time step  2 s)
- Some of which may be heavily contaminated by subject movement
- Also know timing of stimuli delivered to subject (*etc*)
- Behavioral, physiological data?
- Hopefully, some hypothesis
- What are you looking for?

## Sample Data: Visual Area V1

- _Sample Data: Visual Area V1_

## Same Data as Last Slide

- Blowup of central time series graph:
- about 7% signal change with a _**very**_
- powerful periodic neural stimulus

- This is _**really**_ good data; _N.B._: repetitions differ

**Block design experimental paradigm: visual stimulation**

## Event-Related Data

_**Event-Related Data**_

-  White curve = Data (first 136 TRs)
-  Orange curve = Model fit (R2 = 50%)
-  Green = Stimulus timing

**Four different visual stimuli**

- Very good fit  for ER data (R2=10-20% more usual).
- Noise is as big as BOLD!

## Alternate subject’s neural state between 2 (or more) conditions using sensory stimuli, tasks to perform, ...
Can only measure relative signals, so must look for changes in the signal between the conditions
Acquire MR images repeatedly during this process
Search for voxels whose signal time series (up-&-down) matches stimulus time series pattern (on-&-off)
Signal changes due to neural activity are small
Need about 1000 images in time series (in each slice)  takes about 1 hour to get fully reliable activation maps
Must break image acquisition into shorter “runs” to give the subject and scanner some break time
Other small effects can corrupt the results  postprocess the data to reduce these effects & be careful 

- Can only measure relative signals, so must look for *changes* in the signal between the conditions
- Acquire MR images repeatedly during this process
- Search for voxels whose signal time series (up-&-down) matches stimulus time series pattern (on-&-off)
- Signal changes due to neural activity are small
- Need about 1000 images in time series (in each slice)  takes about 1 hour to get fully reliable activation maps
- Must break image acquisition into shorter “runs” to give the subject and scanner some break time
- Other small effects can corrupt the results  postprocess the data to reduce these effects & be careful

- _How FMRI Experiments Are Done_

## FMRI experiment design
Single subject or group study?  Event-related, block, hybrid event-block? 
How many types of stimuli?  How many of each type?  Timing (intra- & inter-stim)?
Will experiment show what you are looking for?  (Hint: bench tests)
How many subjects do you need for group analysis? (Hint: answer does not have 1 digit)
Time series data analysis (individual subjects)
Assembly of images into 4D datasets; Visual & automated checks for bad data
Registration of time series images (attempt to correct for subject motion)
Smoothing & masking of images; Baseline normalization; Censoring bad data
Catenation of imaging runs into one big dataset
Fit statistical model of stimulus timing+hemodynamic response to time series data
Fixed-shape or variable-shape response models
Segregation into differentially active blobs
Thresholding on statistic + clustering and/or Anatomically-defined ROI analysis
Visual examination of maps and fitted time series for validity and meaning
Group analysis (inter-subject)
Spatial normalization to Talairach-Tournoux atlas (or something like it)
Smoothing of fitted parameters
Automatic global smoothing + voxel-wise analysis or ROI averaging
ANOVA to combine and contrast activation magnitudes from the various subjects
Visual examination of results (usually followed by confusion)
Write paper, argue w/ co-authors, submit paper, argue with referees, publish paper, ...

- Single subject or group study?  Event-related, block, hybrid event-block?
- How many types of stimuli?  How many of each type?  Timing (intra- & inter-stim)?
- Will experiment show what you are looking for?  (Hint: bench tests)
- How many subjects do you need for group analysis? (Hint: answer does not have 1 digit)
- Time series data analysis (individual subjects)
- Assembly of images into 4D datasets; Visual & automated checks for bad data
- Registration of time series images (attempt to correct for subject motion)
- Smoothing & masking of images; Baseline normalization; Censoring bad data
- Catenation of imaging runs into one big dataset
- Fit statistical model of stimulus timing+hemodynamic response to time series data
- Fixed-shape _or_ variable-shape response models
- Segregation into differentially active blobs
- Thresholding on statistic + clustering _and/or_ Anatomically-defined ROI analysis
- Visual examination of maps and fitted time series for validity and meaning
- Group analysis (inter-subject)
- Spatial normalization to Talairach-Tournoux atlas (or something like it)
- Smoothing of fitted parameters
- Automatic global smoothing + voxel-wise analysis _or_ ROI averaging
- ANOVA to combine and contrast activation magnitudes from the various subjects
- Visual examination of results (usually followed by confusion)
- Write paper, argue w/ co-authors, submit paper, argue with referees, publish paper, ...

- _FMRI Experiment Design and Analysis_

*All on one slide** **!*

## Experiment Design - Blocks

-  Hemodynamic (FMRI) response
-  peak = 4-6 s after neural activation
-  width = 4-5 s for brief (< 1 s) activation
-  **** two separate activations less than 12-15 s apart will have their responses overlap and add up (approximately)
-  Block design experiments: Extended activation, or multiple closely-spaced (< 2-3 s apart) activations
- Multiple FMRI responses accumulate  big response
- _But_: can’t distinguish separate but closely-spaced activations
- Stimulus = “**subject sees a face for 1 s, presses button #1 if male, #2 if female**”; faces every 2 s for a 20 s block, then 20 s of “**rest**”, *etc*.
- What to do about trials where the subject makes a mistake?
- Neurally different than correct trials, but there is no way to separate out the activations when the hemodynamics blurs so much in time.

## Experiment Design - Event-Related

-  Separate activations in time so can model FMRI response from each separately, as needed
-  Need to make inter-stimulus gaps vary (“jitter”) if there is any time overlap in their FMRI response curves: if events are closer than 12-15 s in time
- Otherwise, tail of event #x always overlaps head of event #x+1 in same way  amplitude of response in tail of #x can’t be told from response in head of #x+1
- You cannot treat every single event as a distinct entity whose response is to be calculated separately!
- You must group events into classes, and assume that all events in the same class evoke the same response.
-  Approximate rule: 25**+** events per class (with emphasis on the ‘**+**’)
- There is just too much noise in FMRI to be able to get an accurate activation map from a single event!

## Experiment Design - Block/Event

-  Long “blocks” are situations where you set up some continuing condition for the subject
-  Within a block, multiple distinct events; *Example*:
- Event stimulus is a picture of a face
- Block condition is instruction on what the subject is to do when he sees the face:
-  Condition A: press button #1 for male, #2 for female
-  Condition B: press button #1 if face is angry, #2 if face is happy
-  Event stimuli in the two conditions may be identical
-  It is the instructional+attentional modulation between the two conditions that is the goal of such a study
-  Perhaps you have two groups of subjects (patients and controls) which respond differently in bench tests
-  You want to find neural substrates for these differences

## 3D Individual Subject Analysis

- Assemble images into 4D datasets (e.g., NIfTI-1)

- Check images for quality (visual & automatic)

- Register (realign) images

- Smooth images spatially

- Mask out non-brain parts of images

- Normalize time series baseline to 100 (for %-izing)

- Fit stimulus timing+hemodynamic model to time series
- Catenates imaging runs, removes residual movement effects, computes response sizes and inter-stimulus contrasts

- Segregate into differentially “activated” blobs

- Look at results, and **think** (e.g., play with thresholds)

**to3d**
_***OR***_
**can do at NIH scanners**

**afni + 3dToutcount + 3dDespike**

**3dvolreg**
_***OR***_
**3dWarpDrive**

**3dAutomask + 3dcalc (optional)**

**3dTstat + 3dcalc**
** ****(optional: could**
**  ****be done post-fit)**

_**3dDeconvolve**_

**Alphasim + 3dmerge**
_***OR***_
**Extraction from ROIs**

**afni**
_***AND***_
**your personal brain**

*... **to group analysis (next page)*

**3dmerge**
_***OR***_
**3dBlurToFWHM**

**(optional)**

## Normalize datasets

- to Talairach “space”

- Smooth fitted
- response amplitudes

- Use ANOVA to combine + contrast results

- Project 3D /results to
- cortical surface models

- Construct cortical
- surface models

- Average fitted
- response amplitudes
- over ROIs

- View and understand results;
- Write paper;
- Start all over

_***OR***_

_***OR***_

- Datasets of results
- from individual
- subject analyses

**Group Analysis: in 3D or on folded 2D cortex models**

## Fundamental Principles Underlying Most FMRI Analyses (esp. GLM): HRF  Blobs

-  _**H**_emodynamic _**R**_esponse _**F**_unction
- Convolution model for *temporal* relation between stimulus and response
-  Activation _**Blobs**_
- Contiguous *spatial* regions whose voxel time series fit HRF model
*e.g.*, Reject isolated voxels even if HRF model fit is good there

## Temporal Models:Linear Convolution

**Additivity Assumption**:
- Input = 2 separated-in-time activations
**** Output = separated-in-time **sum** of 2 copies of the 1-stimulus response
- Additivity: approximately true, and improved by caffeine! (Tom Liu, ISMRM 2007)
- FMRI response to single stimulus is called the _**H**_emodynamic _**R**_esponse **F**unction (**HRF**)
- Also: _**I**_mpulse _**R**_esponse _**F**_unction (IRF)

## Hemodynamic Model

- Measured MRI value in each voxel is sum of:
- Slowly drifting baseline
- Hemodynamic response that is linearly proportional to “neural activity”, delayed and blurred in time
- Non-neural physiological “noise” due to respiration and blood flow pulsations through the cardiac cycle
- Residual effects from uncorrectable subject motion and unmeasured scanner hardware fluctuations
- White noise from random (thermal) currents in the body and the scanner
- Imaging is assumed perfect (no rubbish)
- Or at least is fixed up in preprocessing steps

## Linear shift-invariant model for single voxel time series:

h(t) = hemodynamic response at time t 		after neural activity
s() = neural activity at time 

*h*(*t*) = hemodynamic response at time *t* 		_after_ neural activity
*s*() = neural activity at time **

- _Hemodynamic Model_

*time*

- data
*=Z*(*t*)

## HRF Model Response to 3 Separate Brief Activations

## Ways to Use This Model

- Assume *s*(*t*) is known, and then
- Assume *h*(*t*) is known except for amplitude  correlation method or fixed shape regression
- Assume shape of *h*(*t*) is also unknown  deconvolution (variable shape) method
- Assume several different classes of *s*(*t*)’s and correspondingly several different *h*(*t*)’s  generic linear model (GLM)
- Assume *h*(*t*) is known, and find *s*(*t*)
-  inverse  FMRI
- Try to find both *h*(*t*) and *s*(*t*)
-  blind deconvolution

## HRF = mathematical model relating what we know (stimulus timing and image data) to what we want to know (location, amount, ..., of neural activity)
Given data, use this model to solve for unknown parameters in the neural activity (e.g., where, how much, ...)
Solving: via multivariate regression
Then test for statistical significance
The basis for most published FMRI

- Given data, use this model to solve for unknown parameters in the neural activity (*e.g.*, where, how much, *...*)
- Solving: via multivariate regression
- Then test for statistical significance
- The basis for most published FMRI

- _FMRI as Pattern Matching_

## HRF Model Equations

- Simplest model: fixed shape
-  Unknown = *a*  [*b* & *c* fixed]

- Next simplest model: derivative allows for time shift
-  Unknowns = *a*0*** ***and*** ****a*1  [*b* & *c* fixed]

- Expansion in a set of
- fixed basis functions {*q*(*t** *)}
- (e.g., Splines, sines, ...);
- Unknowns = {*w**q*}

## Multiple Stimulus Classes

- Need to calculate HRF (amplitude or amplitude+shape) separately for each class of stimulus
- Novice FMRI researcher pitfall: try to use too many stimulus classes
- Event-related FMRI: need 25**+** events per stimulus class
- Block design FMRI: need 10+ blocks per stimulus class

## Spatial Models of Activation

- 10,000..50,000 image voxels in brain
- Don’t really expect activation in a single voxel (usually)
- Curse of multiple comparisons:
- If have 10,000 statistical tests to perform, and 5% give false positive, would have 500 voxels “activated” by pure noise — way **way** too much!
- Can group voxels together somehow to manage this curse

## Spatial Grouping Methods

- Smooth data in space before analysis
- Apply threshold based on smoothness
- Average data across anatomically-selected regions of interest ROI (before or after analysis)
- Labor intensive (*i.e.*, send more postdocs)
- Reject isolated small clusters of above-threshold voxels after analysis

## Spatial Smoothing of Data

-  Reduces number of comparisons
-  Reduces noise (by averaging)
-  Reduces spatial resolution
- Can make FMRI results look PET-ish
- In that case, why bother gathering high resolution MR images?
-  Smart smoothing: average only over nearby brain or gray matter voxels
- Uses resolution of FMRI cleverly
- _Or_: average over selected ROIs
- _Or_: cortical surface based smoothing

**}**

**Good things**

## Spatial Clustering

- Analyze data, create statistical map (*e.g.*, ***t*** statistic in each voxel)
- Threshold map at a lowish ***t*** value, in each voxel separately
- Threshold map by rejecting clusters of voxels below a given size
- Can control false-positive rate by adjusting ***t*** threshold and cluster-size thresholds together

## Cluster-Based Detection

- _Cluster-Based Detection_

## Allowing for “Noise”

- Physiological “noise”
- Heartbeat & respiration affect signal
- Can monitor and try to cancel out
- Subject head movement
- After realignment, some effects remain
- Can include in regression model to reduce effects
- Task-correlated motion: clever design can help ...
- Low frequency drifts ( 0.01 Hz)
- Need to include in baseline model
- Scanner glitches can produce gigantic (10 ) spikes in data
- Can try to automatically “squash” these

## Rubbish: Things to Look For

- Errors in setting up the scans
- Be consistent if scanning same subject on multiple days (*e.g.*, same FOV, slice thickness)
- Large head movements
- More than a few mm or few degrees
- Stimulus correlated motion: brain “cap”
- Spikes in the data time series
- Scanner drifts
- Short term: During long imaging runs
- Long term: Hardware slowly degrading
- Set up an FMRI quality check system!
- Palliative: real-time image acquisition

## Playing with Your Results

-  Unthresholded ***F***-statistic in grayscale
-  Animation: loops from very strict threshold to very non-strict
-  No spatial clustering

## Correcting for speech-related motion

**Overt Speech – 2 block design experiments **

***Overt speech results in large task-related motion artifacts...***

**Overt Speech – event-related design **

- (30s task / 30s rest) (motion highly correlated)

**Blocked / Event-Related**
**(low correlation with motion)**

***...******These can be reduced by changing the task paradigm***

***R.M. Birn***

## Differential activation of frontal and temporal cortex by phonemic and category fluency

**S**

**Animals**

***“******Name words that start with the letter S”***

***“******Name as many animals as you can”***

**= more active for “letters”**

**= more active for “categories”**

***Task-related motion artifacts reduced by using 10s ON****** ******/****** ******10s OFF block design***

***A self-paced overt response fMRI study***

**= equal activity in both tasks**

## Software Tools

- What package to use?
- Sociological answer: the one your neighbors are using (so you can ask them for help)
- Having a support system in place is crucial*!*
- SPM: most widely used at present
*AFNI*: flexible, customizable
- and has the coolest logo
- FSL: solid package from Oxford
- Numerous other good packages out there
- Mix-and-match with NIfTI-1 common data format
- Commercial products: MedX, Brain Voyager

## Second Set of Conclusions

- FMRI data contain features that are about the same size as the BOLD signal *and* are poorly understood
_**Thus**_: There are many “reasonable” ways to analyze FMRI data
- Depending on the assumptions about the brain, the signal, and the noise
_**Conclusions**_: **Understand what you are doing**** &**** Look at your data**
- Or you will do something stupid

## Finally ... Thanks

- The list of people I should thank is not quite endless ...

**MM Klosek.  JS Hyde.  JR Binder.  EA DeYoe.  SM Rao. **
**EA Stein.  A Jesmanowicz.  MS Beauchamp.  BD Ward. **
**KM Donahue.  PA Bandettini.  AS Bloom.  T Ross.**
**M Huerta.  ZS Saad.  K Ropella.  B Knutson.  J Bobholz.**
**G Chen.  RM Birn.  J Ratke.  PSF Bellgowan.  J Frost.  **
**K Bove-Bettis.  R Doucette.  RC Reynolds.  PP Christidis. **
**LR Frank.  R Desimone.  L Ungerleider.  KR Hammett. **
**DS Cohen.  DA Jacobson.  EC Wong. D Glen.**
**   *****And ****** *****YOU,***** the audience***** ...**

**http****:****//****afni.nimh.nih.gov****/****pub****/****tmp****/****Kiel2007****/**