Skip to content

jesus-333/CSP-Python

Repository files navigation

CSP

Python implementation of the CSP algorithm. A more advance impemntation with the FBCSP can be find at this link.

First implementation based on the dataset IV-1 (100 Hz) of the BCI competition. The dataset is not included in the repository but can be easily downloaded at this link.

Version 1

First implementation based on the MATLAB tutorial inside the folder Matlab Tutorial CSP. The functions are all separated and are inside the file CSP_support_function-py and they are executed in a main file called test_file.py.

This version work with no major bug but it has some logical problem with the classifier and the features selector.

Version 2 (Definitive version)

Improved version based on the function of version 1. Now all the function are inside a class (CSP.py file) so you can create a CSP object. I try to make the class as general as possible. For this reasons the class don't have any methods to read data. The class exepct you to provided the data in a 3D matrix of dimension number of trials x channels x number of samples.

The file inside this version are the following:

  1. CSP.py: implementation of the CSP algorithm inside a class to provided an end-to-end solution
  2. CSP_support_function.py: in this version is relegated to have some minor function to read the database.
  3. test_file.py: testing of the class.

The class can classify the data with an hand-made LDA classifier (trainLDA() function) or can use a sklearn classifier passed to the function trainClassifier(). To evaluate a new trial use the evaluate() method.

The class also provided some methods to plot the trials, the features of the data and the PSD (Power Spectral Density) of the various trials.

Releases

No releases published

Packages

No packages published