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.
- 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
| 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 |
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
- gForce Pro Armband by OYMotion
- Linux device with Bluetooth LE support
- Python 3.7+
- Linux operating system (required for
bluepylibrary)
git clone https://github.com/yourusername/geometric-EMG.git
cd geometric-EMGsudo pip3 install -r requirements.txtDependencies:
bluepy— Bluetooth LE communicationPyQt5— GUI frameworkpyqtgraph— Real-time plottingnumpy/pandas— Data processingscikit-learn— Machine learningmatplotlib— Visualizationjoblib— Model serialization
Launch the main application (requires sudo for Bluetooth access):
sudo python3 GUI.pySteps:
- Power on your gForce Pro armband
- Click Scan to discover nearby devices
- Select your armband from the device list
- The application will connect and begin displaying EMG signals
For quick testing without the GUI:
sudo python3 sample.pyThis provides a menu-driven interface to:
- Get firmware version
- Toggle LED / Motor
- Stream quaternion data
- Configure and stream raw EMG data
- Sampling Rate: Up to 500 Hz
- Channels: 8 EMG channels
- Resolution: 8-bit or 12-bit configurable
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
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%
- Algorithm: Logistic Regression (multi-class)
- Training Data: Labeled gesture recordings
- Output: Real-time gesture classification
from modeltraining import model_training, load_model
# Train a new model
model = model_training()
# Or load the pre-trained model
model = load_model()| 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 |
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
)DNF_QUATERNION— Orientation dataDNF_EMG_RAW— Raw EMG signalsDNF_ACCELERATE— Accelerometer dataDNF_GYROSCOPE— Gyroscope data
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
This project is provided for research and educational purposes.
Contributions are welcome! Please feel free to submit issues and pull requests.
For questions or collaboration inquiries, please open an issue on GitHub.
- OYMotion — gForce Pro armband and SDK
- bluepy — Python Bluetooth LE library