Technology Devices Evidence SDK Docs Pricing About Blog
Request SDK Access
Abstract visualization of degraded EEG signal waveform quality
Dr. Rohan Mehta

Euclidean Alignment: A Simple but Effective Session-to-Session Normalization for EEG

By Dr. Rohan Mehta, Founder & CEO · Synaptiq

He and colleagues' 2019 paper on Euclidean alignment is one of those methods that earns respect precisely because of its simplicity. In a field where domain adaptation for EEG tends toward complex solutions — Riemannian optimal transport, deep transfer learning, multi-source domain adaptation with elaborate kernel tricks — Euclidean alignment achieves most of the inter-session accuracy improvement with a whitening transform that can be implemented in ten lines of NumPy. Understanding why it works as well as it does is more illuminating than the algebra itself.

In this post I want to work through Euclidean alignment in the depth it deserves: the mathematical operation, its geometric interpretation, the conditions under which it works and the conditions under which it does not, and how it fits into the broader session alignment stack we use in the Synaptiq pipeline.

The Problem It Solves, Precisely

Before explaining the method, it is worth being precise about which component of the inter-session distribution shift Euclidean alignment actually addresses — because it does not address all components equally.

When a patient returns for a BCI session after a few days, the EEG covariance matrices computed from their data in session 2 will differ from those in session 1 for several reasons. The dominant causes of that difference, roughly in order of contribution, are:

  1. Electrode placement variability: The cap is repositioned, and electrode positions shift by a few millimeters relative to cortical landmarks. This changes the linear mixing of neural sources onto electrode channels, which changes the inter-channel covariance structure globally.
  2. Session-specific neural state: The patient's resting-state brain activity — the "idle" background from which motor imagery is a perturbation — varies with arousal, fatigue, and daily physiological state. This shifts the baseline around which the motor imagery signal sits.
  3. Amplitude scaling changes: Impedance differences between sessions, or simple day-to-day variability in EEG amplitude, scale the overall power in each channel.

Euclidean alignment primarily addresses components 2 and 3 — session-specific baseline differences. It partially addresses component 1. It does not address genuine neural changes due to neuroplastic adaptation or pathology progression (component 4), because those reflect real changes in the underlying source signals, not measurement artifacts.

The Algorithm: Three Steps

The Euclidean alignment procedure for a new session is:

Step 1: Collect a brief calibration recording from the patient (2–5 minutes of resting-state or task data). Compute the covariance matrices from this data. In He et al.'s formulation, compute a single reference matrix R̄ as the Euclidean (arithmetic) mean of the session's covariance matrices:

import numpy as np
from pyriemann.estimation import Covariances

# X_calib: [n_trials, n_channels, n_samples] calibration recording
cov_estimator = Covariances(estimator='lwf')
C_calib = cov_estimator.fit_transform(X_calib)

# Euclidean mean of calibration covariances
R_bar = np.mean(C_calib, axis=0)  # shape: [n_channels, n_channels]

Step 2: Compute the whitening matrix — the inverse square root of R̄:

from scipy.linalg import fractional_matrix_power

# Whitening matrix: R_bar^{-1/2}
W = fractional_matrix_power(R_bar, -0.5)

Step 3: Apply the whitening transform to all covariance matrices in the session:

def euclidean_align(C_session, W):
    """
    Align covariance matrices from a new session.
    C_session: [n_trials, n_channels, n_channels]
    W: whitening matrix [n_channels, n_channels]
    Returns: aligned covariance matrices
    """
    C_aligned = np.array([W @ C @ W.T for C in C_session])
    return C_aligned

After alignment, the Euclidean mean of the aligned matrices equals the identity matrix I (by construction). Every session's covariance matrices are re-centered around I regardless of their original distribution. The effect is that a Riemannian classifier trained on aligned session 1 data sees aligned session 2 data that has the same reference point.

Geometric Interpretation: Why Centering Around Identity Helps

The geometric intuition requires thinking about what the Euclidean mean of a session's covariance matrices represents. This mean encodes the "average covariance structure" during the calibration period — the typical inter-channel relationships in the EEG signal, dominated by the patient's resting state and the electrode configuration.

In Riemannian geometry terms, the Euclidean mean is an approximation to the Riemannian mean that is computationally cheaper and geometrically reasonable when the covariance matrices are not too spread out on the manifold (i.e., when within-session variability is small relative to the inter-session shift). For EEG data, this approximation is typically valid.

By whitening with W = R̄-1/2, we are applying a coordinate transformation that maps the session-specific reference point (R̄) to the identity matrix I. This is a rotation and scaling in covariance matrix space. After alignment, all sessions share the same reference point — the identity. Differences between aligned covariance matrices now reflect only the relative variation within each session (the motor imagery signal content, the within-session noise) rather than the absolute position of each session's distribution on the manifold.

The Riemannian metric is invariant under congruence transformations (maps of the form C → ACAT), which is exactly the form of the Euclidean alignment operation. This means that the geodesic distances between covariance matrices — the quantities the Riemannian classifier uses to make decisions — are preserved by the alignment transformation. The alignment re-centers the data without distorting the geometric relationships within the session, which is why it does not degrade within-session classification accuracy while improving cross-session performance.

What the Empirical Results Show

On publicly available multi-session EEG datasets (BCIC IV 2a, PhysioNet Motor Imagery), Euclidean alignment consistently closes 60–80% of the accuracy gap between within-session and cross-session performance for Riemannian classifiers. To put numbers on it: if within-session accuracy is 82% and unaligned cross-session accuracy is 68%, Euclidean alignment typically brings cross-session accuracy to 77–80% — recovering most but not all of the within-session performance level.

The residual accuracy gap after alignment reflects the components of inter-session shift that Euclidean alignment does not address: genuine changes in the neural motor imagery signal structure, and large electrode placement changes that alter the spatial covariance structure rather than just the amplitude scaling. These cannot be removed by a data-free (no labeled training data from the new session) alignment method — they require either labeled calibration data and classifier updating, or domain adaptation methods that go beyond simple re-centering.

Limitations: When Euclidean Alignment Fails or Underperforms

Euclidean alignment is not a universal solution to inter-session non-stationarity. Its limitations matter for clinical deployment:

It requires calibration data from the new session. Typically 2–5 minutes of resting-state data is sufficient — the calibration recording does not need to be labeled. But it does require a session-start calibration step that takes time and clinician attention. "Zero-calibration" cross-session transfer, where no new session data is needed, requires more complex transfer learning methods.

It is less effective for large electrode placement changes. When cap repositioning is substantial (e.g., a full cap removal and refit after a patient transfer), the electrode placement change can be large enough that the dominant variance in the new session's covariance matrices reflects the new electrode geometry rather than the motor imagery signal. In this case, Euclidean alignment re-centers the new geometry around the identity but cannot recover the old spatial filter estimates without labeled data.

It does not transfer classifier decision boundaries. Euclidean alignment normalizes the covariance distribution, but if the Riemannian class means ML and MR estimated in session 1 are significantly displaced after large neural or placement changes, the classifier will still show accuracy degradation even after alignment. The alignment improves things by standardizing the reference point; it does not update the class models themselves.

It uses the Euclidean mean, not the Riemannian mean. For sessions with high within-session variability — patients with particularly noisy EEG — the Euclidean mean is a worse approximation to the true session reference point than the Riemannian mean would be. Riemannian re-centering (aligning to the Riemannian mean of the session rather than the Euclidean mean) is theoretically more appropriate but computationally more expensive and shows only modest improvements on most EEG datasets. The simplicity of the Euclidean version is a genuine practical advantage rather than just computational laziness.

Euclidean Alignment in the Synaptiq Pipeline

In the Synaptiq SDK, Euclidean alignment is applied automatically at session boundaries as the first stage of session initialization. The implementation computes R̄ from a configurable calibration window (default: 2 minutes of pre-session resting state, minimum: 60 seconds). The whitening matrix W is stored and applied to all subsequently acquired covariance matrices for the duration of the session.

This session-boundary alignment is combined with online Riemannian covariance updating within the session — the two methods address different timescales of non-stationarity and are complementary rather than redundant. Euclidean alignment handles the step-change at session start; online updating handles the slow drift through the session.

The choice to use Euclidean alignment (rather than Riemannian re-centering or more complex domain adaptation) is pragmatic: it achieves most of the accuracy benefit of the more complex methods, adds approximately 2–5ms to session initialization processing time, and its behavior is easy to characterize and document for regulatory purposes. For a clinical SDK where the behavior of every algorithm must be understood and explained, simplicity that achieves most of the benefit of a more complex approach is the right engineering decision.