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.