← Back to Course Home

fMRI GLM & Convolution Studio

Construct cognitive paradigm timelines, convolve stimulus events with the canonical Hemodynamic Response Function (HRF) to build the Design Matrix (X), inject noise and drift, and solve the General Linear Model (Y = Xβ + ε) in real time. Colour the noise with physiological oscillations and AR(1) temporal autocorrelation, then switch the estimator to prewhitened GLM and audit the null false-positive rate to see exactly how much ordinary least squares over-states its own significance when the residuals are not independent.

Experimental Design:
Stimulus Paradigm u(t) & Convolved BOLD Regressors: Task A (Orange) vs. Task B (Blue) × Canonical HRF
Voxel Time Series Y(t) (Noisy Dots) & Overlaid OLS Model Fit Ŷ = Xβ̂ (Purple Line)
Power Spectrum of the Residuals Used for Inference (white) vs. the Task A Regressor (orange), showing where your signal sits relative to drift, respiration and the aliased cardiac peak
True βA vs. Estimated β̂A
2.00 → 1.98
True βB vs. Estimated β̂B
1.00 → 1.04
Contrast cTβ̂
+0.94
t-statistic
t = 4.82
Significance (p-value)
p < 0.0001
Variance Inflation (VIF)
1.02
Residual AR(1) ρ̂
0.00
Null FPR @ α = 5%
not yet audited
Statistical Contrast c:
Model: Y = βAXA + βBXB + βdriftXdrift + β0
Estimator:

Core Concepts of the fMRI General Linear Model (GLM):

1. Convolution with the HRF: Neural events induce metabolic activity that triggers a sluggish, delayed blood-oxygenation response peaking 5–6 seconds later, followed by an undershoot. We convolve our stimulus timing vectors u(t) with the canonical double-gamma Hemodynamic Response Function h(t) to predict what the BOLD response should look like: Xi(t) = (ui ∗ h)(t).

2. Detection Power vs. Estimation Efficiency: Block designs create massive cumulative signal swings by stringing events together, yielding very high statistical detection power (large t-statistics). However, they cannot isolate the shape of single events. Jittered event-related designs separate events with variable intervals, allowing the HRF to be estimated accurately (high estimation efficiency) at the cost of reduced overall raw signal amplitude.

3. Multicollinearity & Variance Inflation (VIF): When two conditions always occur in rapid succession (e.g. in the Collinear preset where Task B immediately follows Task A), their convolved regressors become heavily correlated (r → 1). In the GLM, high collinearity blows up the covariance matrix (XTX)−1, inflating the standard error of parameter estimates (β̂) and destroying our statistical ability to distinguish Task A from Task B!

4. Nuisance Regressors: Real MRI scans suffer from low-frequency hardware drifts and heating. By including a linear drift column in the design matrix X, the GLM separates baseline drifts from true task-related neural activations.

5. Physiological Noise & Aliasing: Respiration (≈ 0.25 Hz) and the cardiac cycle (≈ 1.1 Hz) modulate the BOLD signal through chest-motion field shifts and pulsatile inflow. At a TR of 0.5 s the sampling rate is 2 Hz, so respiration is sampled properly but the cardiac term is undersampled and folds back to |1.1 − 2.0| = 0.9 Hz. That aliased peak cannot be filtered out at its true frequency, because its true frequency was never in the data. Raising the physiological slider and watching the spectrum panel shows why longer TRs make this worse, and why cardiac and respiratory traces are recorded during scanning so they can be modelled as nuisance regressors (RETROICOR) rather than filtered blindly.

6. Temporal Autocorrelation & Prewhitening: BOLD noise is not independent from volume to volume: neighbouring time points are correlated, which an AR(1) process with coefficient ρ captures reasonably well. OLS still gives unbiased β̂, but its standard errors assume independence, so it divides by a variance that is too small and the t-statistic comes out inflated. The fix is to prewhiten, applying the transform y*[i] = y[i] − ρ̂y[i−1] to both Y and every column of X, which restores white residuals and honest standard errors. Press Audit Null False-Positive Rate to measure this directly: the audit re-runs the current design 500 times with both task effects set to zero and counts how often each estimator claims p < 0.05. A calibrated test finds 5%. Turn ρ up and watch OLS drift far above that while the prewhitened GLM holds.

7. Where this simulation stops: ρ̂ here is the lag-1 autocorrelation of the OLS residuals, which is biased slightly toward zero because the design has already been projected out of those residuals. Production packages (SPM's AR(1), FSL FILM) add bias corrections and pool the estimate across neighbouring voxels for stability. Push ρ up past about 0.8 and run the audit: the prewhitened GLM improves enormously on OLS but no longer lands exactly on 5%, because it is whitening with a ρ̂ that is slightly too small. Prewhitening also only removes the autocorrelation it models: a strong periodic physiological component is not AR(1), so with the physiological slider high the audit will show residual inflation that no amount of whitening removes. That is a modelling problem, not an estimation problem.