/BCI-Based-FES-for-Hand-Rehabilitation

Brain Computer Interface (BCI) Motor Imagery AI Model For IOT Real Time Embedded Application

Primary LanguageJupyter Notebook

Hand Rehabilitation System Using Functional Electrical Stimulation (FES) Based on Brain-Computer Interface (BCI)

Table of Contents


Project Overview

Hand function impairment, including paralysis or muscle weakness (paresis), often results from neurological disorders such as stroke, spinal cord injury, and traumatic brain injury. This project presents an innovative rehabilitation system that integrates Brain-Computer Interface (BCI) technology with Functional Electrical Stimulation (FES) to address these challenges. The system captures brain electroencephalography (EEG) signals using Motor Imagery techniques, classifies these signals with an AI model, and activates FES to stimulate the relevant muscles, enabling the intended hand movements.


Project Features

🔴 BCI Module: Captures and processes EEG signals using Motor Imagery techniques.

🔴 AI Integration: Classifies EEG signals to interpret user intentions.

🔴 FES Module: Stimulates muscle contraction through electrical impulses.

🔴 Feedback Glove: Provides real-time feedback on hand movements to ensure correct execution.

🔴 GUI: Monitors system parameters, allows EEG recording, and maintains a patient database with electronic reports.

🔴 IoT Network: Integrates all system components for seamless communication and control.


System Components

  1. Brain-Computer Interface (BCI)
    • EEG Data Acquisition: Captures brain signals using a Neuron Spectrum EEG device.
    • Pre-processing: Applies baseline correction, band-pass filtering, and trial trimming.
    • Feature Extraction: Utilizes Common Spatial Patterns (CSP) and Filter Bank Common Spatial Patterns (FBCSP).
    • Classification: Employs AI models such as SVM, MLP, LDA, Logistic Regression, and Extra Trees, with hard voting applied for ensemble predictions

  1. Functional Electrical Stimulation (FES)
    • Stimulation Parameters: Adjustable frequency, intensity, and pulse duration.
    • Therapy Protocols: Supports various hand function training patterns.
    • Safety Features: Includes isolation transformers, diodes, digital potentiometers, and software protection.

  1. Feedback Glove
    • Design: Comfortable and flexible, equipped with sensors to measure finger angles.
    • Functionality: Uses hall effect sensors to detect magnetic field changes during finger movements.

  1. Graphical User Interface (GUI)
    • Control and Monitoring: Provides an intuitive interface for system control and parameter monitoring.
    • Reporting: Gathers and presents performance data and system logs for analysis.
image image
  1. IoT Network

    • Integration and Communication Flow: Ensures coordinated interaction between the Master CPU (Decision Module), FES MC (Action Module), and Glove MC (Feedback Module).
    • Message Protocol: Utilizes seven messages for communication, with continuous data exchange for real-time operation.
    • Communication Technologies: Employs User Datagram Protocol (UDP) and ESP-NOW for low-latency and reliable data transmission.

    Messages Transmitted Through Modules

Message Description Sender Receiver
Message 1 FES Initial Parameters GUI FES
Message 2 Glove Calibration FES Glove
Message 3 Angles Acquisition Glove GUI
Message 4 State Reporting Glove GUI
Message 5 Decision (Grasp/Release) GUI Glove
Message 6 Channel ON (Grasp/Release) Glove FES
Message 7 Realtime FES parameters FES GUI

Master CPU (Decision Module)

  • EEG Signal Processing and AI Model: Uses Lab Streaming Layer (LSL) protocol to receive EEG signals and AI models to analyze motor imagery patterns.
  • Glove State Handling: Manages the operational state of the glove, ensuring proper feedback.
  • GUI: Provides an intuitive interface for monitoring and controlling the system.
  • Reporting: Gathers and presents performance data and system logs.

FES MC (Action Module)

  • FES Parameters: Manages intensity required for efficient function performance.
  • Pulse Generation: Produces electrical pulses for muscle stimulation.
  • Grasp-Release Functions: Executes commands for grasp and release actions.

Glove MC (Feedback Module)

  • Angles Acquisition: Continuously measures and reports the angles of the user's fingers.
  • State Reporting: Indicates the current state of the glove (grasp or release mode).


Project Structure

BCI-FES-Rehabilitation-System
├─ src
│  ├─ AI
│  │  ├─ Deep Learning
│  │  │  ├─ Cross_Subject_Classification_EEGInceptionMI.ipynb
│  │  │  ├─ Within_Subject_Classification_EEGInceptionMI.ipynb
│  │  ├─ Machine Learning
│  │  │  ├─ CSP
│  │  │  │  ├─ CSP_Models_Train.ipynb
│  │  │  ├─ FBCSP
│  │  │  │  ├─ FBCSP_V5.py
│  │  │  │  ├─ FBCSP_2_sec_train.ipynb
│  │  │  │  ├─ FBCSP_4_sec_train.ipynb
│  │  ├─ GUI
│  │  │  ├─ Backend
│  │  │  │  ├─ main.py
│  │  │  │  ├─ login.py
│  │  │  │  ├─ calibration_screen.py
│  │  │  │  ├─ LSLViewer.py
│  │  │  │  ├─ patients.py
│  │  │  │  ├─ newpatient.py
│  │  │  │  ├─ record_automation.py
│  │  │  │  ├─ report.py
│  │  │  │  ├─ session.py
│  │  │  ├─ QT_Design
│  │  │  │  ├─ main_window.ui
│  │  │  ├─ Assets
│  │  │  │  ├─ Imgs
│  │  ├─ Glove
│  │  │  ├─ boot.py
│  │  │  ├─ ESPnow.py
│  │  │  ├─ hall.py
│  │  │  ├─ mac.py
│  │  │  ├─ message_formating.py
│  │  │  ├─ NetworkSetup.py
│  │  ├─ FES
│  │  │  ├─ boot.py
│  │  │  ├─ ESPnow.py
│  │  │  ├─ message_formating.py
│  │  │  ├─ NetworkSetup.py
├─ Paper.pdf
├─ README.md

Installation

To set up the project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/Omar-Saad-ELGharbawy/BCI-Graduation-Project
    
  2. Install the required dependencies:

    pip install -r requirements.txt
  3. Set up the EEG device and FES system according to the provided documentation.

  4. Run the GUI application:

    python main.py

Usage

Calibrate the System:

  • Set initial FES parameters.
  • Perform glove calibration.

Begin a Session:

  • Start the EEG recording.
  • Follow the on-screen instructions for Motor Imagery tasks.

Monitor Progress:

  • Use the GUI to monitor real-time feedback and adjust parameters as needed.
  • Review session reports to track patient progress.

Dataset

  • The project utilizes both a public online dataset and collected data for training and validation.
  • Public Dataset: Clinical Brain-Computer Interfaces Challenge WCCI 2020 Glasgow dataset. Dataset
  • To request our collected data, please contact any of the project contributors via their emails for more information.

Results

The system achieved an average prediction accuracy of 79% for real-time predictions using a 2-second window of EEG data. The use of real-time feedback and adjustable FES parameters significantly improved rehabilitation outcomes compared to fixed parameters.


Future Work

  1. Collect more data to improve model accuracy.
  2. Enhance the FES circuit for better control.
  3. Improve glove sensor sensitivity to reduce delay.

Technical Skills


Team

Team Members' Names CV
Dina Hussam Dina_Hussam_CV.pdf
Neveen Mohamed
Omar Ahmed
Omar Saad Omar_Saad_CV.pdf
Sherif Ahmed Sherif_Ahmed_CV.pdf

Acknowledgements

Supervised by Dr. Aliaa Rehan Youssef, Department of Systems and Biomedical Engineering, Cairo University.


References