This app estimates the noise covariance matrix used for MEG/EEG source reconstruction. Depending on which input is supplied, it calls mne.compute_raw_covariance (empty-room recording or raw), mne.compute_covariance (epochs, using the pre-stimulus baseline), or mne.make_ad_hoc_cov (evoked, diagonal ad-hoc fallback). Channels with abnormal baseline variance can optionally be auto-detected and interpolated before the covariance is computed.
The noise covariance is essential for source reconstruction: it lets the inverse operator properly weight channels and separate brain signal from sensor noise.
The app generates:
- A noise covariance file (
cov.fif) - Diagnostic plots (channel variance, covariance matrix, noise spectra, and — for epochs input — whitened evoked and covariance topomaps)
- An HTML report bundling those plots
- A
product.jsonwith quality-diagnostic messages and plot thumbnails
empty_room(neuro/meeg/mne/raw): Empty-room recording. If present, it takes priority over every other input — the covariance is computed directly from it viamne.compute_raw_covariance. Should be preprocessed (e.g. Maxwell-filtered, band-passed) to match the experimental data (optional).evoked(neuro/meeg/mne/evoked): Evoked data. If noempty_roomis given, this is tried next, but only to build a diagonal ad-hoc covariance viamne.make_ad_hoc_cov, and only whenad_hoc_fallbackistrue— otherwise the app exits with an error (optional; use only if neither epochs nor an empty-room recording is available).epochs(neuro/meeg/mne/epochs): Epoched data. Used, if noempty_room/evokedis given, to estimate the noise covariance from the pre-stimulus baseline viamne.compute_covariance(recommended input) (optional).raw(neuro/meeg/mne/raw): Continuous recording with events, used as a last resort when none of the above is given. Epochs are created internally from the events found in the recording (using thetmin/tmaxconfig values) before computing the covariance the same way as forepochs. Not currently exposed as an input on brainlife.io's web form; settable via a config override (also accepted under the legacy keymne) (optional).
out_dir/cov.fif(neuro/meeg/mne/covariance): Estimated noise covariance matrix, consumed by the inverse-operator app.out_figs/*.png: Diagnostic plots — channel variance (only ifauto_bad_channelsflagged any), covariance matrix, channel noise spectra, and (epochs input only) whitened evoked GFP and covariance topomaps.out_report/report.html(report/html): MNE HTML report bundling the plots above.product.json: Brainlife.io metadata — quality-diagnostic messages (effective rank, condition number, samples/channel, etc.) and base64 thumbnails of the plots.
| key | type | default | description |
|---|---|---|---|
method |
string (enum: shrunk, empirical, diagonal_fixed, auto) |
shrunk |
Covariance estimator passed to mne.compute_covariance/mne.compute_raw_covariance. auto tries shrunk then falls back to empirical. |
tmin |
string | "" (→ None) |
Lower time bound (seconds) for the baseline/analysis window. Empty or "None" = epoch start (epochs input) / recording start (raw/empty-room input). |
tmax |
string | "" (→ None) |
Upper time bound (seconds) for the baseline/analysis window. Empty or "None" = epoch end (epochs input) / recording end (raw/empty-room input). |
rank |
string | "" (→ None, auto-detect) |
Rank estimation. None/empty = auto-detect from data, info = from measurement info (e.g. after Maxwell filtering), full = assume full rank, or a JSON dict, e.g. {"eeg": 45}. |
auto_bad_channels |
boolean | false |
Automatically flag channels (per type: EEG/grad/mag) whose baseline variance is far from the per-type median and interpolate them before computing the covariance. |
bad_channel_threshold |
number | 5 |
Multiplier on the per-type median baseline variance above which a channel is flagged bad (channels below median/100 are also flagged as dead). Used only when auto_bad_channels is true. |
ad_hoc_fallback |
boolean | false |
If true, allows falling back to a diagonal ad-hoc covariance (mne.make_ad_hoc_cov) when only evoked data is available. If false (default), that case is a fatal error. |
All parameters are strings on Brainlife. "None" or empty = Python None (MNE default). Any number = that time in seconds.
Epochs (compute_covariance) |
Raw / empty-room (compute_raw_covariance) |
|
|---|---|---|
| tmin=None | first sample of epoch | 0 (MNE default) |
| tmax=None | last sample of epoch | end of recording |
| tmin/tmax=float | that time in seconds | that time in seconds |
- method: Use
shrunkif you have enough data (>5 samples per channel). Useempiricalifshrunkfails. Useautoto try both. - tmin/tmax: For event-related designs, use
tmin=None, tmax=0.0to use only the pre-stimulus baseline. Leave both asNone/empty to use the full epoch/recording. - rank: Leave as
None/empty unless you know the data rank (e.g. after Maxwell filtering or ICA, the rank is reduced). Useinfoif Maxwell filtering was applied.
- Open the app page on brainlife.io (bl.app.891).
- Select an Epochs object as input (recommended), or an empty-room Raw recording for the most accurate estimate; Evoked is an optional fallback input.
- Set
method,tmin/tmax,rank, and the bad-channel options as needed — the defaults work for most datasets. - Submit the app. Outputs appear as
out_dir/cov.fif, with the quality-diagnostics report inout_report/report.htmlonce the process finishes.
Example config.json:
{
"epochs": "/path/to/epochs-epo.fif",
"empty_room": "",
"evoked": "",
"raw": "",
"method": "shrunk",
"tmin": "",
"tmax": "0.0",
"rank": "",
"auto_bad_channels": false,
"bad_channel_threshold": 5,
"ad_hoc_fallback": false
}Run:
singularity exec docker://brainlifemeeg/mne:1.12.1 python3 main.pyThe app reports:
- Effective rank: How many independent dimensions the covariance captures
- Condition number: Ratio of largest to smallest eigenvalue (>1e12 warns of poor estimation)
- Samples/channel ratio: Whether there's enough data for reliable estimation (warns if <5)
- Eigenvalue spectrum / covariance plots: Visual check for rank and noise structure
This app is step 2 of the source reconstruction pipeline:
[Forward Model] --> [Noise Covariance] --> [Inverse Operator] --> [Source Estimate]
- Hayashi, S., Caron, B.A., Heinsfeld, A.S. et al. brainlife.io: a decentralized and open-source cloud platform to support neuroscience research. Nat Methods 21, 809–813 (2024). https://doi.org/10.1038/s41592-024-02237-2
- Gramfort, A., Luessi, M., Larson, E., et al. MEG and EEG data analysis with MNE-Python. Front. Neurosci. 7, 267 (2013). https://doi.org/10.3389/fnins.2013.00267
- Engemann, D.A., Gramfort, A. Automated model selection in covariance estimation and spatial whitening of MEG and EEG signals. NeuroImage 108, 328–342 (2015). https://doi.org/10.1016/j.neuroimage.2014.12.040
brainlife.io is publicly funded and for the sustainability of the project it is helpful to acknowledge the use of the platform. We kindly ask that you acknowledge the funding below in your code and publications.
Copyright (c) 2026 MEEG Brainlife team. Licensed under AGPL-3.0, see license.txt.