EMG Analysis Functions for PhysioExperiment Objects
PhysioEMG provides 21 exported functions for electromyography (EMG) analysis, built on top of PhysioCore. It covers the complete EMG analysis pipeline from signal conditioning through clinical interpretation: envelope extraction and amplitude normalization, spectral analysis, muscle activation onset detection, fatigue monitoring, muscle synergy decomposition, and inter-muscular connectivity network analysis -- all operating directly on PhysioExperiment objects.
You can install PhysioEMG from r-universe:
# the containers build on Bioconductor, so its repositories are needed too
install.packages("BiocManager", repos = "https://cloud.r-project.org")
install.packages("PhysioEMG",
repos = c("https://x-biosignal.r-universe.dev", BiocManager::repositories()))
Or install the development version from GitHub:
# install.packages("remotes", repos = "https://cloud.r-project.org")
remotes::install_github("x-biosignal/PhysioEMG")
library(PhysioEMG)
# Generate simulated EMG with muscle bursts
pe <- make_emg(n_time = 5000, n_channels = 4, sr = 1000)
# Detect muscle activation onsets
onsets <- emgOnsetDetect(pe, method = "hodges_bui")
# Extract RMS envelope and normalize
pe_env <- emgEnvelope(pe, method = "rms", window_ms = 50)
pe_norm <- emgAmplitudeNormalize(pe_env, method = "peak")
# Decompose into muscle synergies
syn <- muscleSynergy(pe, n_synergies = 3, method = "nmf")
# Analyze inter-muscular coordination network
net <- emgCoherenceNetwork(pe, freq_band = c(10, 50))
coord <- emgCoordinationStructure(net)
Signal conditioning for amplitude analysis:
emgEnvelope() -- extract signal envelope using RMS (sliding window), Hilbert transform, or lowpass rectificationemgAmplitudeNormalize() -- normalize amplitude to maximum voluntary contraction (MVC) or peak valueFrequency-domain characterization of EMG signals:
emgSpectralMoments() -- compute spectral moments (mean frequency, median frequency, bandwidth) over sliding windowsAutomatic identification of muscle activation timing:
emgOnsetDetect() -- detect muscle activation onsets with two algorithms:
Monitor neuromuscular fatigue during sustained or repeated contractions:
emgFatigue() -- track median frequency shift over time in sliding windows (progressive decrease indicates fatigue)emgFatigueIndex() -- compute fatigue index by comparing spectral properties between initial and final contraction segmentsExtract coordinated muscle activation patterns underlying motor control:
muscleSynergy() -- decompose multi-channel EMG into synergies using:
synergyReconstruct() -- reconstruct EMG signals from a reduced set of synergies (assess reconstruction quality)synergyCompare() -- compare synergy structures between conditions, sessions, or subjects using similarity metricsCharacterize functional connectivity and coordination between muscles:
emgCoherenceNetwork() -- magnitude-squared coherence networks within specified frequency bandsemgWPLINetwork() -- weighted phase lag index networks (robust to volume conduction artifacts)emgPartialCoherenceNetwork() -- partial coherence networks controlling for common input effectsemgDirectedGCNetwork() -- directed Granger causality networks for causal inter-muscular couplingemgDynamicWaveletNetwork() -- time-varying connectivity using wavelet coherence (track coordination changes during movement)emgCoordinationStructure() -- extract network topology metrics (modularity, hub muscles, clustering coefficient)emgInterpretNetworkKG() -- interpret network results using anatomical and functional knowledge graphsReady-to-use data for testing, demonstration, and teaching:
make_emg() -- multi-channel EMG with realistic burst patternsmake_emg_contraction() -- EMG with controlled contraction-relaxation cyclesmake_emg_fatigue() -- EMG with progressive fatigue characteristics (spectral shift)PhysioEMG is the EMG analysis layer of the PhysioExperiment ecosystem, a suite of R packages for multi-modal physiological signal analysis:
| Package | Description |
|---|---|
| PhysioCore | Core data structures and accessors |
| PhysioIO | File I/O (EDF, HDF5, BIDS, CSV, MAT) |
| PhysioPreprocess | Preprocessing (filters, ICA, resampling) |
| PhysioAnalysis | Analysis and visualization |
| PhysioEEG | EEG analysis (ICA, ERP, source, BCI, sleep) |
| PhysioEMG | EMG analysis (synergy, fatigue, onset) |
| PhysioECG | ECG and HRV analysis |
Visit the r-universe page to browse all available packages.
MIT License. See LICENSE for details.
Yusuke Matsui
Part of the Physio ecosystem. Community and policy documents live in the umbrella repository: