GithubHelp home page GithubHelp logo

nabilalibou / online_bci_mi Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 11.95 MB

Real-Time BCI for Rock-Paper-Scissors: Decoding Motor Imagery with Minimal Training

License: MIT License

Python 100.00%
brain-computer-interface eeg eeg-analysis eeg-classification motor-imagery-classification preprocessing-pipeline machine-learning artifact-rejection deep-learning ica

online_bci_mi's Introduction

Real-Time Brain-Computer Interface for Rock-Paper-Scissors

This repository explores the development of a real-time Brain-Computer Interface (BCI) capable of classifying motor execution and motor imagery tasks using EEG signals. The ultimate goal is to create a rock-paper-scissors game controlled by BCI using minimal training data.

The project arose from a desire to compete with a colleague in various games using BCI technology. We aimed to develop a system that accurately classifies different limb movements using only 50 training samples per condition.

Approach:

This study is divided into two parts:

Offline Analysis: This phase involves preprocessing and classification of recorded EEG signals to identify optimal algorithms for real-time processing.

Online Analysis: This phase implements the chosen algorithms in a real-time BCI system using MNE-lsl for online classification and control.

Experimental Setup:

  • Subjects: Two right-handed participants (me and my colleague).
  • Tasks: Three motor execution (ME) and three motor imagery (MI) tasks, each focused on a different limb (left arm, right arm, right leg).
  • Data Acquisition: 32-channel EEG system (TMSI) with 2064 Hz sampling rate using a standard 10/20 electrode montage.
  • Protocol: Each session consisted of an initial resting state followed by 50 repetitions of a sequence combining ME and MI tasks as illustrated in the diagram below:

Offline Analysis

Preprocessing

The raw EEG data undergoes various steps to remove artifacts and noise, including:

  • Band-pass filtering (0.1 Hz - 50 Hz) with zero-phase response.
  • Automatically detect bad channels based on peak-to-peak amplitude, deviation from the mean amplitude, correlation with others channels and power spectral density distribution.
  • Epoching (-0.15s to 5s around each event-task).
  • Re-referencing to the 'Cz' electrode.
  • Reconstruction of bad channels by spherical spline interpolation [1].
  • ICA for artifact rejection with automatic component labeling using MNE-ICALabel.
  • Baseline correction.
  • Automatic bad epoch rejection based on the power spectral density and the Riemannian covariance (using the Potato algorithm [2]).

Feature extraction

(Details to be added)

Classifiers

(Details on chosen algorithms to be added).

Classification Scores

(Results of offline classification - intra-subject & inter-subject - to be added).

Online Analysis:

Preprocessing

(Details to be added)

Feature extraction

(Details to be added)

Classifiers

(Details on chosen algorithms to be added).

Classification Scores

(Results of offline classification - intra-subject & inter-subject - to be added).

Getting Started:

Clone the repository and install the dependencies:

git clone https://github.com/nabilalibou/online_bci_mi.git
pip install -r requirements.txt

Video/Gif:

(To be added - demonstrate online preprocessing and classification)

References

[1] F. Perrin, J. Pernier, O. Bertrand, and J. F. Echallier, “Erratum: Spherical splines for scalp potential and current density mapping (Electroenceph. Clin. Neurophysiol. 1989, 72: 184 187),” vol. 76, Jan. 1990.

[2] The Riemannian Potato: an automatic and adaptive artifact detection method for online experiments using Riemannian geometry A. Barachant, A Andreev, and M. Congedo. TOBI Workshop lV, Jan 2013, Sion, Switzerland. pp.19-20.

online_bci_mi's People

Contributors

nabilalibou avatar

Stargazers

 avatar  avatar

Watchers

 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.