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>
Go to the source code of this file.
Implementation of the Common Spatial Patterns decoder.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors
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.