Decoding fMRI: LSA vs LSS
Shared on March 6, 2026
๐ MVPA Decoding & CrossโValidation in fMRI
Key idea: Decoding neural data is a regression problem; classification is simply a thresholded regression.
Takeโhome: Use betaโseries regression (LSA/LSS) โ logistic regression โ AUC โ crossโvalidation (leaveโoneโsubject out).
Executive Summary
The lecture explains how to transform fMRI timeโseries into singleโtrial neural activity estimates (betaโseries), use those estimates to predict behavioral choices, and evaluate the predictive model with proper performance metrics (AUC) and robust crossโvalidation. It also covers common pitfalls such as multicollinearity, overโfitting, and the need for data centering.
Key Takeaways
- GLM flowchart: Stimulus โ HRF convolution โ GLM โ ฮฒโcoefficients (encoding) vs ฮฒโcoefficients โ neural activity โ behavioral prediction (decoding).
- Betaโseries regression
- LSA (Least Squares All): one regressor per trial โ fast, but suffers from collinearity.
- LSS (Least Squares Separate): one GLM per trial โ slower, but more robust to collinearity.
- Linear Probability Model (LPM): OLS regression where Y โ {0,1}; predictions are probabilities.
- Logistic regression: transforms LPM output into [0,1] via the logistic function.
- Accuracy is misleading when class frequencies differ; AUC is a better, thresholdโfree metric.
- Crossโvalidation:
- Holdโout (70/30 split) โ simple but sensitive to split.
- kโfold โ repeated kโfold gives a more stable estimate.
- Leaveโoneโsubjectโout (LOSO) is the gold standard for group decoding.
- Data formatting: convert 3โD timeโseries (subjects ร voxels ร time) into a long format (rows = trials ร voxels ร subjects).
- Demeaning: subtract runโwise means to reduce runโlevel bias; avoid demeaning Y when class balance matters.
- Multicollinearity & overโfitting: highโdimensional voxel sets lead to extreme ฮฒ values; reducing dimensionality or regularizing (e.g., ridge, LASSO) helps.
Detailed Summary
1. Encoding vs Decoding
- Encoding: predict neural response from known stimuli (GLM).
- Decoding: infer stimuli/behaviors from neural data (reverse GLM).
- Both use the same GLM machinery; decoding flips the direction of inference.
2. SingleโTrial Estimation (BetaโSeries)
- Goal: estimate ฮฒ for each trial โ โneural activityโ per event.
- Method:
- Create a regressor matrix where each column is a singleโtrial HRF.
- Fit GLM โ ฮฒ coefficients = trialโwise activity.
- Approaches
- LSA: one GLM with 29 regressors (fast).
- LSS: one GLM per trial (slow but more robust).
3. Regression Models for Binary Outcomes
- Linear Probability Model (LPM):
- Y = Xฮฒ + ฮต, Y โ {0,1}.
- Coefficients unbiased (BLUE) but predictions can fall outside [0,1].
- Logistic Regression:
- Apply logistic function ฯ(Xฮฒ) โ bounded probabilities.
- Equivalent to LPM with a logit link.
4. Performance Metrics
- Accuracy: fraction of correct predictions; inflated if class imbalance.
- AUC (Area Under ROC):
- Thresholdโfree; always 0.5 for random chance.
- Computed by ranking predicted probabilities against true labels.
- Preferred for imbalanced data.
5. CrossโValidation Strategies
| Scheme | Description | Pros | Cons |
|---|---|---|---|
| Holdโout | 70/30 split | Simple | Sensitive to split |
| Repeated holdโout | Multiple random 70/30 splits | Reduces variance | Still oneโway |
| kโfold | Split into k folds, train on kโ1, test on 1 | Balanced training/testing | Requires k GLMs |
| Leaveโoneโsubjectโout (LOSO) | Train on all but one subject, test on leftโout | Gold standard for group decoding | Computationally heavy |
- LOSO is recommended for decoding across subjects because it tests generalization to new participants.
6. Data Preparation
- Long format: one row per trial ร voxel ร subject.
- Columns:
subject,trial,voxel,beta,choice. - Enables vectorized operations and straightforward crossโvalidation indexing.
7. Practical Workflow (Python / MATLAB)
- Load data: 3โD array (
time ร voxels ร subjects). - Convert to long format.
- Compute betaโseries (LSA or LSS).
- Fit LPM on training set โ obtain ฮฒ.
- Predict probabilities on test set โ logistic transform if desired.
- Compute AUC per leftโout subject.
- Average AUC across folds โ final performance estimate.
8. Common Pitfalls & Remedies
| Issue | Symptom | Fix |
|---|---|---|
| Multicollinearity | Extreme ฮฒ magnitudes, unstable predictions | Reduce dimensionality, use ridge/LASSO, or LSS |
| Overโfitting | High training accuracy, low test AUC | Crossโvalidate, regularize, limit voxel count |
| Class imbalance | Accuracy โ majority class | Use AUC, reโsample, or classโweighting |
| Runโlevel bias | Systematic shifts across runs | Demean X per run; keep Y raw for binary outcome |
| Nonโindependent observations | Inflated test statistics | Use permutation tests or mixedโeffects models |
9. Takeโaway Messages
- Decoding is regression: treat binary outcomes as probabilities.
- AUC beats accuracy when classes are imbalanced.
- Crossโvalidation matters: choose a scheme that reflects the generalization you care about.
- Data formatting is critical: long format simplifies modeling and validation.
- Regularization is essential when using many voxels to avoid multicollinearity and overโfitting.
โThe only way to know if a pattern is real is to see it in other data sets.โ โ Emphasis on outโofโsample validation.