Skip to content

ahansoty/emg-processing-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

EMG Signal Processing Pipeline

A MATLAB pipeline for processing raw surface EMG signals. Designed for single-volunteer datasets with multiple gesture channels.

Pipeline Overview

Raw EMG → FFT Analysis → Butterworth Bandpass Filter → Rectification → RMS Envelope → Feature Extraction

Features

  • 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

Usage

Dataset

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

Output

Each function call generates 3 figures:

  1. FFT Spectrum — single-sided amplitude spectrum (0–500 Hz)
  2. Raw vs Rectified — side by side comparison of unprocessed and rectified signal
  3. 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

Dependencies

  • MATLAB R2020a or later
  • Signal Processing Toolbox (butter, filtfilt)

File Structure

emg-signal-processing/
├── README.md
└── processEMG.m

Background

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

About

MATLAB pipeline for multi-channel surface EMG analysis — bandpass filtering, RMS envelope extraction, and frequency-domain characterization of hand and wrist gestures

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages