Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🦾 Geometric-EMG

Real-time Electromyography (EMG) Signal Processing & Gesture Recognition System

A Python-based application for capturing, visualizing, and classifying EMG signals from the gForce Pro armband. This system enables real-time hand gesture recognition using machine learning.


✨ Features

  • Real-time EMG Data Acquisition — Connect to gForce Pro armband via Bluetooth LE
  • Live Signal Visualization — 8-channel EMG signal display with PyQt5/PyQtGraph
  • Gesture Recognition — Machine learning-based classification of 9 hand gestures
  • Data Collection Interface — Guided protocol for recording training data
  • Pre-trained Model — Ready-to-use Logistic Regression classifier

Supported Gestures

Gesture Description
🤜 Flexion Wrist bending (palm toward forearm)
🤛 Extension Wrist extending (back of hand toward forearm)
👈 Ulnar Deviation Wrist tilting toward pinky
👉 Radial Deviation Wrist tilting toward thumb
🔄 Pronation Forearm rotation (palm facing down)
🔃 Supination Forearm rotation (palm facing up)
✋ Open Palm Hand fully open
✊ Close Palm Hand in fist position
🖐️ Rest Relaxed hand position

🏗️ Architecture

geometric-EMG/
├── GUI.py                 # Main application entry point
├── gforce.py              # gForce SDK - Bluetooth communication layer
├── searchwindow.py        # Main UI window with data visualization
├── customcanvas.py        # Real-time plotting canvas
├── modeltraining.py       # Feature extraction & model training
├── sample.py              # Standalone example for testing connection
├── img/                   # Gesture reference images
├── Subject_*/             # EMG recording data directories
└── LogisticRegression.joblib  # Pre-trained classifier model

🔧 Requirements

Hardware

  • gForce Pro Armband by OYMotion
  • Linux device with Bluetooth LE support

Software

  • Python 3.7+
  • Linux operating system (required for bluepy library)

📦 Installation

1. Clone the Repository

git clone https://github.com/yourusername/geometric-EMG.git
cd geometric-EMG

2. Install Dependencies

sudo pip3 install -r requirements.txt

Dependencies:

  • bluepy — Bluetooth LE communication
  • PyQt5 — GUI framework
  • pyqtgraph — Real-time plotting
  • numpy / pandas — Data processing
  • scikit-learn — Machine learning
  • matplotlib — Visualization
  • joblib — Model serialization

🚀 Usage

Running the GUI Application

Launch the main application (requires sudo for Bluetooth access):

sudo python3 GUI.py

Steps:

  1. Power on your gForce Pro armband
  2. Click Scan to discover nearby devices
  3. Select your armband from the device list
  4. The application will connect and begin displaying EMG signals

Command Line Interface (Testing)

For quick testing without the GUI:

sudo python3 sample.py

This provides a menu-driven interface to:

  • Get firmware version
  • Toggle LED / Motor
  • Stream quaternion data
  • Configure and stream raw EMG data

📊 Data Format

Raw EMG Data

  • Sampling Rate: Up to 500 Hz
  • Channels: 8 EMG channels
  • Resolution: 8-bit or 12-bit configurable

Data Files

EMG recordings are saved in Subject_*/ directories with the naming convention:

Motion_{gesture_id}_Rep_{repetition}.txt

Each file contains:

  • 128 data points per packet
  • 8 channels of EMG data
  • Space-separated values

🧠 Machine Learning Pipeline

Feature Extraction

The system uses Root Mean Square (RMS) as the primary feature:

rms = sqrt(mean(signal²))

Parameters:

  • Window Length: 100ms (50 samples at 500Hz)
  • Window Overlap: 50%

Model

  • Algorithm: Logistic Regression (multi-class)
  • Training Data: Labeled gesture recordings
  • Output: Real-time gesture classification

Training Your Own Model

from modeltraining import model_training, load_model

# Train a new model
model = model_training()

# Or load the pre-trained model
model = load_model()

📁 Project Structure

File Description
GUI.py Application entry point
gforce.py gForce SDK for Bluetooth communication
searchwindow.py Main window with device scanning and data display
customcanvas.py PyQtGraph-based real-time plotting widget
modeltraining.py ML training and feature extraction functions
sample.py Standalone testing script with CLI menu
pagewindow.py Base page window class
menuwindow.py Menu navigation component
datawindow.py Data display window
helpers.py Utility functions

⚙️ gForce SDK Configuration

EMG Raw Data Settings

GF.setEmgRawDataConfig(
    sampRate=500,      # Sampling rate (max 500 Hz)
    channelMask=0xFF,  # All 8 channels enabled
    dataLen=128,       # Samples per packet
    resolution=8       # 8-bit resolution
)

Available Data Notifications

  • DNF_QUATERNION — Orientation data
  • DNF_EMG_RAW — Raw EMG signals
  • DNF_ACCELERATE — Accelerometer data
  • DNF_GYROSCOPE — Gyroscope data

🔬 Research Applications

This system is suitable for:

  • Prosthetic Control — EMG-based prosthesis interfaces
  • Human-Computer Interaction — Gesture-based input devices
  • Rehabilitation — Motor function assessment and training
  • Biomechanics Research — Muscle activity analysis

📝 License

This project is provided for research and educational purposes.


🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.


📧 Contact

For questions or collaboration inquiries, please open an issue on GitHub.


🙏 Acknowledgments

  • OYMotion — gForce Pro armband and SDK
  • bluepy — Python Bluetooth LE library

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages