Trial-group calibration and per-subject risk control for fMRI-to-image retrieval
Abstract
We develop a decoder-agnostic risk-control layer for fMRI-to-CLIP retrieval that accounts for repeated decisions from a shared trial. Learn-Then-Test on trial groups, using a floored loss and betting bound, selects a confidence threshold for a target accepted-set error rate. In 300 synthetic calibrations evaluated against a large simulated reference sample, the corrected rule exceeds its certified bound in 4.0% of runs at nominal 5%, with accepted coverage 0.833 against an oracle maximum of 0.87. The floored loss gives an acceptance-dependent risk bound whose inflation must be reported. Treating ten correlated decisions per trial as independent produces a 23.3% violation rate. An intersection–union fixed-sequence test extends certification to every calibrated subject; in a four-subject synthetic experiment it reduces the probability of any violation from 1.00 to 0.045. A feedback controller and an anytime-valid monitor address deployment with observed outcomes. The monitor alarms on 0.5% of at-target synthetic streams and detects a shift to risk 0.18 in 92% of runs. Existing real-data comparisons cover seven decoder arms and four NSD subjects but use the legacy calibrator and decision-level splits. Corrected real-data evaluation remains pending.
Keywords: brain decoding · fMRI · selective prediction · conformal risk control · Learn-Then-Test · distribution shift
1Introduction
Decoding images from fMRI has improved quickly. Retrieval of the viewed image from a few hundred candidates is now close to saturated for well-scanned subjects in the Natural Scenes Dataset (NSD) [1, 2]. The field evaluates decoders on average accuracy. A deployed decoder is used one trial at a time, often on a person it was not trained on, and the property that matters there is different. When the decoder answers, how often is it wrong, and does it know when to stay silent?
Selective prediction [3] and distribution-free risk control [4, 5] give that question a precise form. Choose a confidence threshold; accept trials above it; certify that the error rate among accepted trials is at most a target \rho with probability at least 1 - \delta. This paper builds such a layer for fMRI-to-CLIP retrieval, wraps it around several decoders, and evaluates its risk control.
The contribution combines trial-group calibration, subject-specific certification and sequential monitoring. Synthetic experiments with reference-sample risk estimates isolate the effect of within-trial dependence. Existing real-data runs provide preliminary decoder comparisons and motivate a corrected evaluation on trial-level splits.
2Setting
2.1Decoders and the retrieval task
Each NSD trial is a vector of voxel responses to one viewed image. A decoder maps it to the CLIP image-embedding space [6] and ranks a gallery of candidate images by similarity. We use four NSD subjects (subj01, 02, 05, 07) and seven decoder arms: ridge regression, a mixture density network, a conditional VAE, a flow-matching posterior estimator, and a contrastive encoder with three uncertainty signals (softmax, MC-dropout, and a deep ensemble [7]). The confidence score of a decision is the arm's own uncertainty measure. On the full 1,282-image test gallery, top-1 accuracy ranges from 0.008 to 0.177. These decoders are an order of magnitude weaker than current reconstruction-focused systems [2], so every result here is a property of the abstention rule applied to weak decoders. The rule itself is decoder-agnostic.
For the tested decoders, full-gallery top-1 accuracy is low, so the main task is a k-way surrogate: the true image against k - 1 = 7 random distractors. Each trial is drawn ten times with different distractor sets. Those ten decisions share one fMRI response, so they are strongly correlated.
2.2The guarantee
Let \lambda be a confidence threshold and R(\lambda) the population error rate among accepted decisions. A calibrator uses n calibration trials to choose \hat\lambda such that
We use target \rho = 0.1 and \delta = 0.05. Coverage is the accepted fraction. Equation Eq. (1) states the target guarantee; the default floored procedure certifies the adjusted bound below, so its violation rates must be interpreted against that bound.
3Dependence experiment
The legacy rule treats each of the ten k-way draws as an independent calibration point. It scans all thresholds and returns the most permissive one whose empirical accepted risk, adjusted by a bound computed as if the points were independent, is below \rho. To test it we simulate calibration sets of 384 trials, the per-subject size, each with ten draws whose correlation matches the real task. We then estimate the population risk of the returned threshold on a separate 300,000-trial simulated reference sample; the reported violation rates therefore also carry reference-sample uncertainty.
| Calibration rule | P(R > \text{bound}) | Coverage | Empty |
|---|---|---|---|
| Legacy rule, all draws | 0.233 | 0.850 | 0.000 |
| Exact bound, unprotected scan, all draws | 0.233 | 0.849 | 0.000 |
| Legacy rule, one draw per trial | 0.043 | 0.804 | 0.000 |
| LTT, exact bound, one draw per trial | 0.050 | 0.685 | 0.140 |
| LTT, floored betting bound (default) | 0.040 | 0.833 | 0.000 |
Replacing the approximate bound with an exact binomial bound leaves the violation rate unchanged in this experiment. Using one draw per trial restores near-nominal behavior, implicating within-trial dependence. This comparison alone cannot establish validity of unrestricted threshold scanning. Varying the number of correlated draws from 3 to 30 produces legacy-rule violation rates of 19–38%; the corrected rule remains at 2–5% in those tests.
4Risk-control methods
4.1A calibrator on trial groups
The grouped calibrator applies Learn-Then-Test [4] to a fixed order of thresholds, stopping at the first non-rejection. Valid per-threshold tests and an order fixed independently of the certification data allow fixed-sequence control. The betting bound [8] acts on bounded group-average losses under its sampling assumptions. Repeated NSD presentations of the same image must be kept together across calibration and evaluation; within-trial grouping alone is insufficient when stimuli repeat.
For error indicator E, acceptance indicator a_\lambda, working target \alpha and floor c, the implemented loss is
Writing A_\lambda=P(a_\lambda=1), certification of \mathbb{E}[\ell_\lambda]\leq0 implies, for positive acceptance,
The floor permits certification near the abstain-all end but inflates the risk bound as acceptance falls. A fixed target requires deflating the working target using a justified lower bound on population acceptance. Plugging in empirical acceptance alone leaves uncertainty in that denominator. The alternative exact-binomial procedure uses one decision per group and a separate tuning split, with an uninflated target and more empty outputs. In Table 1 the default rule has 4.0% violations of its certified bound at coverage 0.833, which is 3.7 percentage points below the oracle’s 0.87. Sensitivity runs report violation rates 0.01–0.07 with Monte Carlo uncertainty. A complete certificate must state the floor, working target, acceptance assumptions and resulting bound.
A useful baseline takes one draw per trial with the legacy rule: it records a 4.3% violation rate and 0.804 coverage. The grouped LTT method improves coverage by 2.9 percentage points in this comparison and supports the extensions below.
4.2A certificate for every person
A pooled guarantee is a statement about the average subject. A decoder deployed on one person needs a statement about that person. We certify one shared threshold inside every subject at once with an intersection–union test [9]. For a fixed candidate threshold, the global null is that at least one subject violates its applicable bound. Rejecting every subject-level null at level \delta rejects that union null at level \delta. Selecting a threshold additionally uses the fixed-sequence protocol. With the floored loss, each subject’s bound includes its own acceptance-dependent inflation.
| Certificate | P(\text{any subject violates}) | Coverage | Worst-subject risk |
|---|---|---|---|
| Pooled | 1.000 | 0.839 | 0.123 |
| Per-subject, Bonferroni | 0.005 | 0.758 | 0.079 |
| Per-subject, intersection–union | 0.045 | 0.769 | 0.085 |
The per-subject formulation targets the maximum risk across the calibrated subjects, providing a guarantee aligned with individual deployment.
4.3Deployment without exchangeability
Zero-shot transfer can break exchangeability, placing the new subject outside the scope of the source calibration guarantee. We provide two tools for that regime. An online controller adjusts the threshold from per-decision feedback and keeps the accepted-set risk under a deterministic bound for every sequence, in the spirit of adaptive conformal inference [10]. When the stream becomes over-confident at trial 2,000, a static threshold's post-shift risk rises to 0.14 while the controller's stays at 0.10. When feedback is scarce, an anytime-valid monitor [11] bets against the hypothesis that the deployed threshold still meets its target. Over 4,000-trial runs, a naive alarm (running mean above target) fires on 86% of streams that sit exactly at target. The monitor fires on 0.5% of them and still detects a shift to risk 0.18 in 92% of runs, with a median delay of about 245 accepted decisions.
4.4Full-gallery shortlists
Low overall top-1 accuracy alone does not determine achievable selective coverage; that also depends on how confidence separates errors. We therefore evaluate a shortlist extension that returns at most m images or abstains, with a risk target among accepted shortlists. On the tested synthetic 1,282-way gallery at top-1 0.27, the singleton rule accepts almost nothing, and accepted coverage grows with m (Figure 1, panel C).

5Real-data results
All real-data numbers were produced with the legacy rule on decision-level splits and may overstate coverage and control (Table 3). The recorded contrastive-encoder arms accept roughly twice as many decisions as the posterior-estimator arms, and the deep ensemble adds 5.5 coverage points over softmax. These are descriptive legacy comparisons. Shared use of an invalid calibrator does not establish that the ordering will survive corrected calibration and splitting.
| Decoder arm | Accepted coverage | Realized risk |
|---|---|---|
| Contrastive encoder + deep ensemble | 0.924 | 0.096 |
| Contrastive encoder + MC-dropout | 0.869 | 0.096 |
| Contrastive encoder + softmax | 0.869 | 0.096 |
| Flow-matching posterior | 0.452 | 0.094 |
| Conditional VAE | 0.447 | 0.094 |
| Ridge | 0.405 | 0.094 |
| Mixture density network | 0.313 | 0.093 |
Zero-shot cross-subject deployment is where the layer visibly fails. In leave-one-subject-out transfer, two of four held-out subjects exceed the target (realized risk 0.116 and 0.125). Recalibrating on 100 to 200 trials from the new subject restores coverage to 0.71–0.80. On BOLD5000 [12] the decoder is so much weaker (top-1 0.017) that coverage collapses to 0.04; only the ensemble's first rank replicates.
6Discussion and limitations
The dependence experiment shows that the calibration unit materially affects risk control in repeated-measurement data. Grouped calibration provides a natural interface for this structure. Its real-data value should be assessed with explicit trial and session splits, calibrated baseline methods and uncertainty over independent subjects.
The cross-subject result is the most practically important negative. A pooled guarantee averages over people, and the failures we saw are conditional-validity failures. The per-subject certificate addresses this for calibrated subjects. For new subjects, online control and monitoring provide additional tools when feedback is available; target-subject recalibration is another option.
The limitations are substantial. Real-data numbers predate the repaired calibrator and must be regenerated from the posterior dumps. The transfer leg is leave-one-out over four people. The decoders are weak; plugging in a current state-of-the-art backbone is the largest lever on the empirical story and has not been done.
7Conclusion
Trial-group calibration, intersection–union subject certification and sequential monitoring provide a common framework for selective fMRI retrieval. Synthetic experiments support near-nominal risk control under the tested assumptions. Corrected real-data experiments and stronger decoder backbones are the next steps toward an empirical brain-decoding result.
Data and code availability
Code, configuration, synthetic audits and result files are public in the repository linked from the paper page. NSD is available under its data-use terms; derived caches and posterior dumps are regenerable with the provided scripts. scripts/run_paper.sh regenerates every number and figure; SMOKE=1 runs the pipeline end to end on synthetic dumps.
References
- E. J. Allen, G. St-Yves, Y. Wu, et al. A massive 7T fMRI dataset to bridge cognitive neuroscience and artificial intelligence. Nature Neuroscience, 25(1):116–126, 2022.
- P. S. Scotti, M. Tripathy, C. K. T. Villanueva, et al. MindEye2: Shared-subject models enable fMRI-to-image with 1 hour of data. In Proceedings of the 41st International Conference on Machine Learning, 2024.
- Y. Geifman and R. El-Yaniv. Selective classification for deep neural networks. In Advances in Neural Information Processing Systems 30, 2017.
- A. N. Angelopoulos, S. Bates, E. J. Candès, M. I. Jordan, and L. Lei. Learn then test: Calibrating predictive algorithms to achieve risk control. arXiv preprint arXiv:2110.01052, 2021.
- A. N. Angelopoulos, S. Bates, A. Fisch, L. Lei, and T. Schuster. Conformal risk control. In International Conference on Learning Representations, 2024.
- A. Radford, J. W. Kim, C. Hallacy, et al. Learning transferable visual models from natural language supervision. In Proceedings of the 38th International Conference on Machine Learning, PMLR 139:8748–8763, 2021.
- B. Lakshminarayanan, A. Pritzel, and C. Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. In Advances in Neural Information Processing Systems 30, 2017.
- I. Waudby-Smith and A. Ramdas. Estimating means of bounded random variables by betting. Journal of the Royal Statistical Society: Series B, 86(1):1–27, 2024.
- R. L. Berger. Multiparameter hypothesis testing and acceptance sampling. Technometrics, 24(4):295–300, 1982.
- I. Gibbs and E. J. Candès. Adaptive conformal inference under distribution shift. In Advances in Neural Information Processing Systems 34, 2021.
- A. Ramdas, P. Grünwald, V. Vovk, and G. Shafer. Game-theoretic statistics and safe anytime-valid inference. Statistical Science, 38(4):576–601, 2023.
- N. Chang, J. A. Pyles, A. Marcus, A. Gupta, M. J. Tarr, and E. M. Aminoff. BOLD5000, a public fMRI dataset while viewing 5000 visual images. Scientific Data, 6:49, 2019.