Code Monkey home page Code Monkey logo

fbcsp-python's Introduction

FBCSP Python

Python implemementation of the FBCSP algorithm. Based on my previous work on the CSP algorithm available at this link.

This repository contain an extension of the CSP (Common Spatial Pattern) known as FBCSP (Filter-Bank CSP). This algorithm is used to extract features and classify EEG trials. The algorithm is used for binary classification.

Version 4 (V4) is based on the work of Kai Keng Ang et al. easily available following the link. Also the multiclass variant is based on a strategy described in that article. Version 1 (V1) and version 2 (V2) are the first implementation and contain error. They are not supposed to be used and lack the method for complete training and evaluation. Version 3 (V3) work's without big problem but I improved some function in the 4.

How the class work

The class must receive in input with the initialization a training set inside a dictionary. The keys of the dictionary must be the label of the two class and each element must be a numpy matrix of dimension "n. trials x n. channels x n.samples". The class must also receive the frequency sampling of the signal.

Once initialized the class automaticaly found the various spatial filter and the best features to train the classifier. The classifier used is an LDA classifier implemented through sklearn. You could also provided another sklean classifier during the initialization of the class if you prefer. The class split the data in a train and test set and then trains and evaluates the classifiers.

An evalaution method to classify new trials is implemented with the name evaluateTrial(). The input of method must have the dimensions "n. trials x n. channels x n.samples". The method return a vector where each element is the label of the respective trial. The label are "1" for class 1 and "2" for class 2.

Multiclass Classification

In case you have data with multiple label I also create a second class for multiclassification. The class is inside the file "FBCSP_Multiclass.py". The input of the class must be also in this case a dictionary with key the label of the varios trial and element the trials matrix with dimensions "n. trials x n. channels x n.samples". Results for the dataset 2a of the BCI competition dataset is reported in the table below:

Subject Accuracy
1 0.698
2 0.555
3 0.805
4 0.5381
5 0.444
6 0.4027
7 0.7743
8 0.684
9 0.725
AVG 0.6251

fbcsp-python's People

Contributors

jesus-333 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.