Overview#
CaliBrain studies how uncertainty estimates behave in simulation-controlled EEG/MEG inverse source imaging. The package is designed for experiments where the latent neural source activity is known, the sensor measurements are simulated through a forward model, and inverse solvers are evaluated by asking whether their posterior uncertainty is empirically calibrated.
Scientific background#
In EEG/MEG source imaging, a sensor measurement matrix (Y in mathbb{R}^{M times T}) is modeled as
where (L) is the leadfield, (X) is source activity, (E) is sensor noise, (M) is the number of sensors, and (T) is the number of time samples. The inverse problem is ill-posed because many source configurations can explain the same sensor data. A useful inverse method should therefore report not only a point estimate (hat{X}), but also an uncertainty estimate that can be checked against simulated ground truth.
CaliBrain focuses on coverage calibration. For a nominal coverage level (c), the package constructs credible intervals or ellipsoids and estimates empirical coverage,
A calibrated uncertainty model satisfies (hat{g}(c) approx c) over the nominal coverage grid.
Current workflow stages#
The current CaliBrain workflow is organized around the following stages:
SourceSimulatorgenerates source-level ground truth.LeadfieldBuilderloads or constructs a leadfield.SensorSimulatorprojects sources to sensors and adds noise.SourceEstimatorapplies an active inverse solver:gamma_map_sflexgamma_lambda_map_sflexBMNBMN_joint
UncertaintyEstimatorconverts posterior summaries into calibration-ready intervals or ellipsoids.UncertaintyCalibratorfits and evaluates isotonic recalibration maps.Workflow scripts batch these operations across runs, then aggregate and calibrate on disk.
Main features#
Controlled source simulation with fixed and free orientations.
Sensor simulation through fixed or free-orientation leadfields.
Inverse solvers for sFLEX Gamma-MAP, Bayesian minimum norm, and joint noise-learning variants.
Posterior summary storage with a manifest-based workflow for reproducible aggregation.
Experiment-level calibration with isotonic nominal-coverage recalibration.
Calibration metrics, EMD-based source-space metrics, and paper-style calibration figures.
Typical use cases#
Benchmarking inverse solvers under controlled signal-to-noise ratios.
Comparing fixed and free-orientation source models.
Testing calibration transfer across subjects, source sparsity levels, and noise settings.
Producing reproducible calibration curves for simulation studies.
Inspecting storage and uncertainty representations used by calibration.
Workflow architecture#
CaliBrain separates expensive simulation from downstream analysis. The current workflow scripts implement three explicit disk-backed stages:
data_generationwrites posterior summaries and a manifest;aggregationreduces summaries into calibration-ready datasets;calibrationconsumes only those aggregated datasets and writes calibration summaries.
This structure keeps large numerical artifacts explicit, makes split definitions inspectable, and allows calibration analyses to be rerun without regenerating simulated data.