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.