alt

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

SchemeDescriptionProsCons
Holdโ€‘out70/30 splitSimpleSensitive to split
Repeated holdโ€‘outMultiple random 70/30 splitsReduces varianceStill oneโ€‘way
kโ€‘foldSplit into k folds, train on kโ€‘1, test on 1Balanced training/testingRequires k GLMs
Leaveโ€‘oneโ€‘subjectโ€‘out (LOSO)Train on all but one subject, test on leftโ€‘outGold standard for group decodingComputationally 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)

  1. Load data: 3โ€‘D array (time ร— voxels ร— subjects).
  2. Convert to long format.
  3. Compute betaโ€‘series (LSA or LSS).
  4. Fit LPM on training set โ†’ obtain ฮฒ.
  5. Predict probabilities on test set โ†’ logistic transform if desired.
  6. Compute AUC per leftโ€‘out subject.
  7. Average AUC across folds โ†’ final performance estimate.

8. Common Pitfalls & Remedies

IssueSymptomFix
MulticollinearityExtreme ฮฒ magnitudes, unstable predictionsReduce dimensionality, use ridge/LASSO, or LSS
Overโ€‘fittingHigh training accuracy, low test AUCCrossโ€‘validate, regularize, limit voxel count
Class imbalanceAccuracy โ‰ˆ majority classUse AUC, reโ€‘sample, or classโ€‘weighting
Runโ€‘level biasSystematic shifts across runsDemean X per run; keep Y raw for binary outcome
Nonโ€‘independent observationsInflated test statisticsUse 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.