The common spatial pattern (CSP) allows one to maximize the variance of signals from one condition and at the same time minimize the variance of signals from another condition [1]. For example, consider two three-dimensional tensors (
trials×channels×time
) of electroencephalogram (EEG) from separate classes
X1,X2∈Rp×q×r
. For each trial let us assume zero mean and compute between channel across time sample covariance matrices (SCMs)
Σi(k)=r−11Xi(k)Xi(k)⊤∈Rq×q
for
i=1,2
and
k=1,…,p
. Furthermore, let us take
Σˉi∈Rq×q
as the arithmetic mean SCM for each class across all trials
k
.
Our example is a standard data and preprocessing pipeline for CSP used by software libraries like PyRiemann [2]. We assume the SCMs are conditioned so that they are symmetric positive definite (SPD). By definition, for a matrix
A∈Rn×n
and any non-zero vector
x∈Rn
, if
A=A⊤
and
x⊤Ax>0
, then
A
is SPD. As a result, all eigenvalues are positive
λi>0
from the eigendecomposition
A=QDQ⊤
where
D=diag(λ1,…,λn)
[3]. Furthermore, the sum of two SPD matrices
A,B∈Rn×n
is also SPD since
x⊤(A+B)x=x⊤Ax+x⊤Bx>0
. Let us diagonalize the mean SCMs from our example.
Σˉ1+Σˉ2=VΛV⊤.
The whitening transformation of an SCM results in zero mean, unit variance, and zero covariance [1]. In other words, the whitening transformation maps an SCM to the identity matrix
Σ↦I
. We define the whitening matrix as
W=VΛ−1/2V⊤∈Rn×n
. The result is no longer an ellipse when plotted but rather the unit circle.
W(Σˉ1+Σˉ2)W⊤=VΛ−1/2V⊤(VΛV⊤)VΛ−1/2V⊤=I.
We can rewrite our whitening transformation to show that the variance of the signals in our first class
Σˉ1
is maximized, while the variance of the signals in our second class
Σˉ2
is also minimized. We do this by distributing the whitening matrix throughout the sum of our SCMs. The result is two transformed SCMs we denote by
Σˉ1′,Σˉ2′∈Rn×n
whose sum is the identity matrix.
W(Σˉ1+Σˉ2)W⊤=WΣˉ1W⊤+WΣˉ2W⊤=Σˉ1′+Σˉ2′=I.
Let us use
Vi′Λi′Vi′⊤
where
i=1,2
to denote the diagonalization of our transformed SCMs. Since
Σˉ1′+Σˉ2′=I
the sum of the diagonals
dij=diag(Λi′)j
is
d1j+d2j=1
. Furthermore,
dij>0
since
Σˉi′
is SPD. Therefore, the diagonals are bounded between 0 and 1. When the variance
daj≫dbj
for
a=b
, the classification problem is more or less solved for unseen EEG trials. However, when
daj
is close to
dbj
the discrimination between classes is more ambiguous [1].
References
Benjamin Blankertz (2018) Gentle Introduction to Signal Processing and Classification for Single-Trial EEG Analysis. CRC Press.
Alexandre Barachant, Quentin Barthélemy, Jean-Rémi King, Alexandre Gramfort, Sylvain Chevallier, Pedro L. C. Rodrigues, Emanuele Olivetti, Vladislav Goncharenko, Gabriel Wagner vom Berg, Ghiles Reguig, Arthur Lebeurrier, Erik Bjäreholt, Maria Sayu Yamamoto, Pierre Clisson, Marie-Constance Corsi, Igor Carrara, Apolline Mellot, Bruna Junqueira Lopes, Brent Gaisford, Ammar Mian, Anton Andreev, Gregoire Cattan, Arthur Lebeurrier (2025) pyRiemann. Zenodo.
Kevin P. Murphy (2022) Probabilistic Machine Learning: An Introduction. MIT Press.
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)