v2.0.0
Loading...
Searching...
No Matches
decoding_csp.cpp File Reference

Implementation of the Common Spatial Patterns decoder. More...

#include "decoding_csp.h"
#include <Eigen/Eigenvalues>
#include <Eigen/SVD>
#include <algorithm>
#include <cmath>
#include <set>
#include <stdexcept>
Include dependency graph for decoding_csp.cpp:

Go to the source code of this file.

Detailed Description

Implementation of the Common Spatial Patterns decoder.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.2.1
Date
May 2026

Estimates the per-class covariance matrices from a list of labelled, band-passed epochs, solves the generalised eigenproblem \(\Sigma_1 w = \lambda (\Sigma_1 + \Sigma_2) w\) with Eigen's GeneralizedSelfAdjointEigenSolver, and keeps the n_components eigenvectors with the largest and smallest eigenvalues as the bank of spatial filters; the corresponding activation patterns are recovered from the pseudoinverse computed via a thin SVD so that ill-conditioned filter matrices degrade gracefully instead of throwing.

DecodingCsp::transform reduces an epoch tensor either to one log-transformed (or z-scored) band-power value per component or to the time-resolved CSP-space projection, depending on the TransformMode selected at construction. DecodingCsp::inverseTransform maps a power-feature matrix back to sensor space by weighting the patterns with the per-feature scores, which is what the application layer uses to render CSP topographies side-by-side with the classification output.

Definition in file decoding_csp.cpp.