NimbusNimbus
PersonalizerStudioTeamDocs
Sign InSalesContact SalesGet Started
← ← Back to all posts

Riemannian Geometry for EEG BCI: Decoding on the Manifold of Covariance Matrices

October 2, 2026

Every EEG trial produces a covariance matrix — a compact summary of how channels co-vary during a window of brain activity. For decades, BCI engineers have treated these matrices as ordinary vectors, computing Euclidean distances and linear decision boundaries. It works. But it discards something fundamental about what a covariance matrix actually is, and that discarded geometry turns out to matter most exactly when calibration data is scarce.

This post explains why EEG covariance matrices have a natural home on a curved Riemannian manifold, how the Minimum Distance to Mean (MDM) classifier exploits that geometry, and how to put Nimbus Studio's riemann_mdm node to work in a data-efficient decoding pipeline.

Euclidean paths between covariance matrices leave the manifold of valid SPD matrices. Riemannian geodesics stay on it — giving geometrically correct distances.

Why Covariance Matrices Cannot Be Treated as Flat Vectors

A covariance matrix is symmetric positive definite (SPD): it is symmetric by construction, and all its eigenvalues are strictly positive. That last constraint is not a detail — it defines a rigid boundary in the space of all symmetric matrices. The set of SPD matrices of a given size forms a smooth, curved manifold, not a flat subspace.

The geometric consequence is immediate: the straight line connecting two SPD matrices in Euclidean space will, in general, pass through regions containing matrices with zero or negative eigenvalues — matrices that no real EEG dataset could ever produce. Euclidean distances, means, and interpolations can produce geometrically invalid results.

For BCI classification this is not merely philosophical. The Euclidean mean of two covariance matrices representing different mental states may land in a region of SPD space that is "between" the two classes in a misleading sense — swelling eigenvalues, distorting class separability, and degrading classifier performance, especially when training data is sparse.

The Riemannian Manifold of SPD Matrices

Riemannian geometry provides the right toolkit. On the manifold of SPD matrices, the geodesic — the shortest path staying entirely on the manifold — replaces the Euclidean straight line. The length of the geodesic defines the affine-invariant Riemannian metric (AIRM), which for two SPD matrices Σ1\Sigma_1Σ1​ and Σ2\Sigma_2Σ2​ takes the form:

dR(Σ1,Σ2)=∥log⁡(Σ1−1/2 Σ2 Σ1−1/2)∥Fd_R(\Sigma_1, \Sigma_2) = \| \log(\Sigma_1^{-1/2}\, \Sigma_2\, \Sigma_1^{-1/2}) \|_FdR​(Σ1​,Σ2​)=∥log(Σ1−1/2​Σ2​Σ1−1/2​)∥F​

where log⁡\loglog is the matrix logarithm and ∥⋅∥F\|\cdot\|_F∥⋅∥F​ is the Frobenius norm. This distance is invariant to simultaneous congruence transformations — meaning it does not care about the choice of EEG reference or the overall signal scale. That invariance is a powerful inductive bias for cross-session and cross-subject decoding, where amplitude and reference vary but the underlying neural geometry should not.

The Riemannian mean (also called the Fréchet mean) of a set of SPD matrices is the unique matrix that minimises the sum of squared geodesic distances to all members of the set. It can be computed iteratively and remains on the manifold by construction — a property no Euclidean average can guarantee.

If you're deciding when this approach belongs in your stack, it also helps to see how it compares to Euclidean classifiers and classic Riemannian toolkits — and where Nimbus fits in a streaming, uncertainty-aware workflow. See: Why Nimbus SDK? Beyond scikit-learn and pyRiemann for BCI.

Minimum Distance to Mean: A Classifier That Lives on the Manifold

MDM is elegantly simple. During training, it computes one Riemannian mean per class from the calibration covariance matrices. At inference time, a new trial's covariance matrix is assigned to whichever class mean it is geodesically closest to.

y^=arg⁡min⁡k  dR(Σtrial, Σˉk)\hat{y} = \arg\min_k\; d_R(\Sigma_{\text{trial}},\, \bar{\Sigma}_k)y^​=argmink​dR​(Σtrial​,Σˉk​)

There are no hyperparameters to tune, no regularisation weight to cross-validate, and no feature extraction step between raw epoched EEG and the classifier. Each trial goes directly from multichannel signal to covariance matrix to decision. The compact model artifact — a set of class means on the manifold — is tiny and fast to load at deploy time.

The data efficiency is the headline advantage. CSP filters need enough trials to stably estimate spatial covariance across classes; deep networks need hundreds of labelled examples before they outperform simpler baselines. MDM needs far fewer: with as few as 10–20 trials per class it can produce useful class means, because each covariance matrix already encodes all C(C+1)/2C(C+1)/2C(C+1)/2 channel relationships from a CCC-channel trial. The whole trial is the feature.

This dovetails with the broader calibration bottleneck: getting a usable decoder from limited labeled data. For a step-by-step end-to-end workflow in Nimbus Studio, see BCI Calibration with Nimbus Studio: From Hardware to Trained Decoder.

Illustrative decoding accuracy as a function of calibration trials. Riemannian MDM benefits from covariance geometry from the very first sessions, outperforming both CSP+LDA and deep models in the small-N regime.

Building a Riemannian Pipeline in Nimbus Studio

Nimbus Studio's riemann_mdm node handles the full covariance-to-decision pipeline. It accepts epoched EEG directly — computing trial covariance matrices internally — and persists a compact model artifact for evaluation and live deploy. Here is a minimal motor-imagery pipeline:

hardware_device
  → highpass_filter (0.5 Hz)
  → notch_filter (50/60 Hz)
  → rereferencing (CAR)
  → epoching (event-locked, e.g. 0.5–3.5 s post-cue)
  → riemann_mdm
  → decision_policy (streaming stability)

A few configuration notes:

  • Epoch length drives covariance rank. For motor imagery, a 2–3 second post-cue window at standard bandpass (8–30 Hz) gives stable, full-rank matrices with typical 32–64 channel setups. Shorter windows or very high channel counts may require Ledoit-Wolf shrinkage — check executor logs for condition number warnings.
  • Tangent space projection is an optional path. If you project each covariance matrix into the tangent space at the Riemannian mean of all training data, you obtain a vector of Euclidean-space features that preserves local manifold geometry. Those vectors can then be fed to a Bayesian classifier — rxlda_sdk (NimbusLDA) or rxpolya_sdk (NimbusSoftmax) — giving you calibrated posterior probabilities alongside the geometric distance-based decision.
  • Evaluate with evaluation_plan and results_output to get subject-wise out-of-fold accuracy. MDM's small-sample advantage is most visible in the 10–40 trial-per-class range; above ~200 trials, CSP+LDA and deep models typically catch up or surpass it.

If you're planning to keep performance stable as the session evolves (drift, headset shifts, day-2 return), the SDK's personalization layer is the natural next rung after you have a working baseline. See: Nimbus SDK 0.6.0: Personalization that keeps up with the session.

A complete Riemannian MDM pipeline in Nimbus Studio: preprocessing → epoching → riemann_mdm → decision_policy, with covariance matrix computation happening inside the model node.

When to Choose Riemannian MDM (and When Not To)

Riemannian MDM is the right starting point when:

  • Calibration is short — fewer than 40–60 trials per class. This includes single-session deployments, rapid-prototyping demos, or paradigms where subject fatigue limits collection time.
  • You need a non-parametric baseline — MDM has no distributional assumptions about feature shape, making it a clean lower bound against which to measure CSP, deep models, and Bayesian classifiers.
  • Cross-session robustness matters — the affine-invariance of the Riemannian metric reduces sensitivity to inter-session amplitude drift and reference changes, without requiring explicit normalisation steps.

But MDM has limits. Its decision boundary is defined by proximity to class means, which implicitly assumes classes are roughly spherically distributed on the manifold. When class distributions are elongated, overlapping, or multi-modal, a Bayesian classifier on tangent-space features — or CSP with NimbusLDA — may generalise better. And when training data exceeds several hundred trials per class, EEGNet and the deep model family have more capacity to learn paradigm-specific spatial-temporal features that covariance matrices cannot capture.

Another common escalation path is to add richer network-level features when per-channel covariance isn't capturing the discriminative structure. A practical companion is: EEG Functional Connectivity as a BCI Feature: Phase Coupling, Coherence, and Bayesian Decoding.

For many real-world sessions, the right answer is to run MDM first. Its low sample-count requirement means you get a working decoder from the very first calibration block, giving early feedback on signal quality and paradigm viability before committing to a longer collection.

Conclusion

Riemannian geometry is not an exotic add-on to EEG decoding — it is a natural fit for covariance-based features, because covariance matrices are genuinely curved-space objects. MDM makes this geometry operational: no feature engineering, no hyperparameter search, and strong performance precisely when calibration data is hardest to collect. In Nimbus Studio, riemann_mdm drops into any epoched pipeline with a single node swap, and its compact model artifact deploys with the same contract as every other model node. Start there, measure your baseline, and escalate to Bayesian or deep-learning heads when you have the data to justify them.

Nimbus BCI

Stop writing boilerplate. Start publishing papers. Built by researchers, for researchers.

LinkedInX
Navigation
ProductPersonalizerStudioTeamDocsPaperResources
Nimbus Studio
Download for WindowsDownload for macOSComparisonFeaturesPricingFAQ
© 2026 Nimbus BCI Inc. All rights reserved.
Get startedSign inPrivacyTermsCookies