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.
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.
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:
- CSP.py: implementation of the CSP algorithm inside a class to provided an end-to-end solution
- CSP_support_function.py: in this version is relegated to have some minor function to read the database.
- 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.