File Exchange

image thumbnail

Common Spatial Patterns (CSP)

A vectorized, quick and simple implementation of the CSP algorithm.


Updated 19 Jul 2019

View License

The function 'csp' performs a bearable implementation of the Common Spatial Patterns (CSP) algorithm, which consists of a binary data-driven supervised data projection of a signal by maximizing the variance of the positive class while minimizing the variance of the negative one.

Input parameters:
- X1 and X2: Signals for the positive and negative class, respectively, whose dimensions must be [classes x samples].

Output parameters:
- W: Filter matrix (mixing matrix), whose columns are spatial filters.
- lambda: Eigenvalues of each filter.
- A: Demixing matrix.

Once the W is trained, the projection of new data X must be computed as:
X_csp = W'*X;

An example of use is included in the 'csp_example.m' file.

Cite As

Víctor Martínez-Cagigal (2020). Common Spatial Patterns (CSP) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux