Skip to content

About

🧠 EEG-driven BCI Robotic Arm for Motor Rehabilitation | CNN-LSTM | 85.89% Accuracy | IEEE Published

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 BCI-Based Robotic Arm for Medical Rehabilitation

Published in IEEE | Amrita Vishwa Vidyapeetham, Coimbatore

Python MATLAB Arduino IEEE Accuracy


πŸ“„ Abstract

Stroke and other neurological disorders often result in significant motor impairments, limiting the effectiveness of traditional rehabilitation. This project proposes a non-invasive Brain-Computer Interface (BCI) system designed to assist motor rehabilitation by decoding motor imagery (MI) tasks from EEG signals.

Using the publicly available PhysioNet EEG Motor Imagery dataset, EEG signals from only three strategically selected electrodes (C3, Cz, C4) over the sensorimotor cortex are utilized β€” significantly reducing hardware complexity without compromising performance. Signals from 30 subjects are preprocessed, then transformed into 2D spectrograms via Short-Time Fourier Transform (STFT). A hybrid CNN-LSTM deep learning model classifies imagined movements (Left, Right, Rest), and the output is transmitted to an Arduino Uno to actuate a 4-DOF robotic arm using SG90 servo motors.


πŸ—οΈ System Architecture

EEG Dataset (PhysioNet)
        β”‚
        β–Ό
Preprocessing (Notch Filter 60Hz + Bandpass 8–30Hz + Z-score Normalization)
        β”‚
        β–Ό
STFT β†’ Spectrogram (224Γ—224Γ—3 RGB β€” C3, Cz, C4 stacked)
        β”‚
        β–Ό
CNN Feature Extractor (16β†’32β†’64 filters, BatchNorm, ReLU)
        β”‚
        β–Ό
LSTM Temporal Classifier (256 hidden units)
        β”‚
        β–Ό
Classification: Left | Right | Rest
        β”‚
        β–Ό
Serial Communication (MATLAB β†’ Arduino Uno)
        β”‚
        β–Ό
4-DOF Robotic Arm (SG90 Servo Motors, PWM Pins D3,D5,D6,D9)

πŸ“ Repository Structure

BCI-Robotic-Arm/
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ preprocessing.py        # Notch + Bandpass filtering, normalization
β”‚   β”œβ”€β”€ spectrogram.py          # STFT-based spectrogram generation
β”‚   β”œβ”€β”€ cnn_model.py            # CNN spatial feature extractor
β”‚   β”œβ”€β”€ lstm_model.py           # LSTM temporal classifier
β”‚   β”œβ”€β”€ train.py                # Training pipeline (CNN 30 epochs, LSTM 70 epochs)
β”‚   β”œβ”€β”€ predict.py              # Real-time inference
β”‚   └── arduino_control.ino    # Arduino Uno servo control sketch
β”œβ”€β”€ notebooks/
β”‚   └── BCI_EEG_Pipeline.ipynb  # Full end-to-end notebook
β”œβ”€β”€ results/
β”‚   β”œβ”€β”€ confusion_matrix.png
β”‚   β”œβ”€β”€ training_curve.png
β”‚   └── ablation_study.csv
β”œβ”€β”€ images/
β”‚   └── system_overview.png
└── LICENSE

βš™οΈ Methods

Dataset

  • Source: PhysioNet EEG Motor Imagery Dataset
  • Subjects: 30 (first valid subjects)
  • Electrodes: C3, Cz, C4 (sensorimotor cortex β€” ERD/ERS)
  • Classes: T0 (Rest), T1 (Left), T2 (Right)
  • Split: 70% Train | 20% Test | 10% Validation

Preprocessing

Step Parameters
Notch Filter 60 Hz (powerline noise removal)
Bandpass Filter 8–30 Hz (mu & beta rhythms), 4th order Butterworth
Normalization Z-score (zero mean, unit variance)
STFT Hamming window=64, overlap=32, FFT=128
Spectrogram 224Γ—224, RGB-stacked (C3, Cz, C4)

CNN Architecture

Layer Details
Input 224Γ—224Γ—3 RGB spectrogram
Conv Block 1 16 filters, BatchNorm, ReLU, MaxPool
Conv Block 2 32 filters, BatchNorm, ReLU, MaxPool
Conv Block 3 64 filters, BatchNorm, ReLU, AvgPool
FC 128 units (spatial feature vector)

LSTM Architecture

Layer Details
Input 128-dim CNN feature vector (as sequence)
LSTM 256 hidden units
Output Softmax β†’ 3 classes

Training

Stage Epochs Optimizer LR
CNN 30 Adam 1e-4
LSTM 70 Adam 1e-4

πŸ“Š Results

Classification Performance

Class Precision Recall F1-Score
T0 (Rest) 0.88 0.88 0.88
T1 (Left) 0.75 0.76 0.75
T2 (Right) 0.82 0.81 0.82

Model Accuracy

Model Variant Accuracy (%)
CNN-LSTM (Proposed) 85.89
CNN Only 82.20
Shallow CNN 70.55
Shallow LSTM 82.10
No Batch Normalization 77.54

Comparison with Related Work

Model Accuracy Subjects Electrodes
CNN-LSTM (This Work) 85.89% 30 3
CNN-LSTM (Fadel et al.) 70.64% 109 64
CNN+LSTM+DNN (Li et al.) 75.52% 12 64
CNN1D MF (Alnaanah et al.) 58.0% 105 64

Our model outperforms all baselines using only 3 electrodes β€” demonstrating hardware efficiency without sacrificing accuracy.

Training Time

  • CNN Feature Extractor: ~4 minutes 56 seconds
  • LSTM Classifier: ~35 seconds

πŸ”§ Hardware Setup

Component Specification
Microcontroller Arduino Uno
Servo Motors SG90 (4Γ—) β€” Torque: 11 kgΒ·cm at 6V
DOF 4 (lift, rotate, grasp, release)
PWM Pins D3, D5, D6, D9
Communication MATLAB β†’ Arduino via Serial (UART)
Commands LEFT, RIGHT, REST β†’ servo angle PWM

πŸš€ Getting Started

Prerequisites

pip install -r requirements.txt

Run Preprocessing

python src/preprocessing.py --data_path ./data/physionet/

Train the Model

python src/train.py --epochs_cnn 30 --epochs_lstm 70 --lr 1e-4

Real-time Prediction

python src/predict.py --port COM3

πŸ“¦ requirements.txt

See requirements.txt for full dependencies (numpy, scipy, torch, mne, pyserial, matplotlib).



πŸ“œ References

  1. Goldberger et al. PhysioBank, PhysioToolkit, PhysioNet. Circulation, 2000.
  2. Fadel et al. Multi-class classification of motor imagery EEG. IEEE BCI, 2020.
  3. Li et al. Improving EEG-based MI classification using hybrid neural network. IEEE ICICN, 2021.
  4. Pfurtscheller & Da Silva. Event-related EEG/MEG synchronization. Clinical Neurophysiology, 1999.

πŸ“ Amrita Vishwa Vidyapeetham, Coimbatore, Tamil Nadu Β |Β  Published in IEEE

About

🧠 EEG-driven BCI Robotic Arm for Motor Rehabilitation | CNN-LSTM | 85.89% Accuracy | IEEE Published

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages