Regularised covariance estimators for M/EEG noise covariances, matching MNE-Python's compute_covariance() API. More...
#include "sts_global.h"#include <Eigen/Core>#include <utility>#include <vector>#include <string>

Go to the source code of this file.
Classes | |
| class | STSLIB::StsCovEstimators |
| Regularised covariance estimators (Ledoit-Wolf, OAS, fixed-diagonal, PCA, Factor Analysis, cross-validated auto-select) matching the MNE-Python compute_covariance() API. More... | |
Namespaces | |
| namespace | STSLIB |
| Statistical testing (t-tests, F-tests, cluster permutation, multiple comparison correction). | |
Regularised covariance estimators for M/EEG noise covariances, matching MNE-Python's compute_covariance() API.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors
M/EEG sensor counts routinely exceed the number of clean baseline samples, which makes the unregularised sample covariance rank-deficient and unusable as the C operator in MNE/dSPM/sLORETA inverse solutions. This module provides the same family of regularised estimators as mne.compute_covariance with method='auto', so STSLIB users get a numerically well-conditioned covariance regardless of how undersampled the input is.
Six estimators are exposed: the analytic Ledoit-Wolf shrinkage, Oracle Approximating Shrinkage (OAS), fixed diagonal regularisation \(C+\lambda\,\bar{\sigma}^2 I\), rank-reduced PCA, EM Factor Analysis and a cross-validated auto-selector that picks the estimator with the highest held-out Gaussian log-likelihood. All routines take zero-mean data shaped (n_channels, n_samples) and return a (cov, parameter) pair; the auto-selector additionally returns the index of the winning method.
The Ledoit-Wolf and OAS back-ends are thin wrappers over the scikit-learn-compatible Skigen::LedoitWolf and Skigen::OAS classes so the resulting covariances are numerically identical to those produced by MNE-Python.
References: Ledoit & Wolf (2004), J. Multivariate Anal. 88(2); Chen, Wiesel, Eldar & Hero (2010), IEEE TSP 58(10); Engemann & Gramfort (2015), NeuroImage 108.
Definition in file sts_cov_estimators.h.