A MATLAB pipeline for processing raw surface EMG signals. Designed for single-volunteer datasets with multiple gesture channels.
Raw EMG → FFT Analysis → Butterworth Bandpass Filter → Rectification → RMS Envelope → Feature Extraction
- FFT Analysis — visualizes frequency content to validate filter cutoff selection
- 4th Order Butterworth Bandpass Filter — removes motion artifact below 40 Hz and high frequency noise above 450 Hz using zero-phase
filtfilt - Rectification — full-wave rectification via absolute value
- RMS Envelope — 200ms sliding window root mean square for muscle activation tracking
- Feature Extraction — computes RMS, MAV, Zero Crossing Rate, and Waveform Length per channel
Download the raw signal CSVs from Kaggle: https://www.kaggle.com/datasets/alexaescalante/emg-dataset-raw-and-filtered-signals
Place CSV files in a local folder and update the filepath in processEMG() accordingly.
processEMG("path/to/file.csv", "ChannelName")Example:
processEMG("C:\data\volunteer_1.csv", "HandOpen")
processEMG("C:\data\volunteer_1.csv", "WristExtension")Compatible with surface EMG datasets sampled at 1000 Hz with the following channel structure:
| Channel | Description |
|---|---|
| HandOpen | Hand opening gesture |
| HandClose | Hand closing gesture |
| WristFlexion | Wrist flexion gesture |
| WristExtension | Wrist extension gesture |
| Supination | Forearm supination |
| Pronation | Forearm forearm pronation |
| Rest | Baseline resting state |
Each function call generates 3 figures:
- FFT Spectrum — single-sided amplitude spectrum (0–500 Hz)
- Raw vs Rectified — side by side comparison of unprocessed and rectified signal
- Processing Pipeline — filtered, rectified, and RMS envelope stacked vertically
Feature values are printed to the MATLAB console:
================ HandOpen ================
Channel RMS MAV ZC WL
_______ ___ ___ __ __
HandOpen 224.3 187.6 1082 9.4e+05
- MATLAB R2020a or later
- Signal Processing Toolbox (
butter,filtfilt)
emg-signal-processing/
├── README.md
└── processEMG.m
Surface EMG signals represent the electrical activity of muscles during contraction. This pipeline follows standard preprocessing practices used in prosthetics and rehabilitation robotics research:
- Bandpass filtering isolates the physiologically relevant EMG frequency band (20–500 Hz)
- RMS envelope is a common control signal in myoelectric prosthetic systems
- Extracted features (RMS, MAV, ZC, WL) are standard inputs for gesture classification models