ReSurfEMG: A Python Package for Comprehensive Analysis of Respiratory Surface EMG
Abstract
Highlights
- What are the main findings?
- ReSurfEMG is a comprehensive Python package for advanced respiratory sEMG analysis.
- Signal processing methodology and settings profoundly affect sEMG signal quality.
- What is the implication of the main finding?
- ReSurfEMG facilitates comprehensive reporting as a citable methodological reference.
- ReSurfEMG lays the open-source groundwork for methodological standardization.
Abstract
1. Introduction
2. Software Description
2.1. The ReSurfEMG Python Package
2.1.1. Data Connector: Reading sEMG Data
2.1.2. Pre-Processing: Filtering
2.1.3. Pre-Processing: ECG Removal
2.1.4. Pre-Processing: Envelope
2.1.5. Postprocessing: Event Detection
2.1.6. Postprocessing: Features
2.1.7. Postprocessing: Quality Assessment
2.2. The ReSurfEMG Repository
3. Materials and Methods
3.1. Experimental Setup
3.2. Data Analysis
4. Results
4.1. Filtering
4.2. ECG Removal
4.3. Envelope
4.4. Moving Baseline and Event Detection
4.5. Features and Quality Assessment
5. Discussion
5.1. Respiratory sEMG: From Research to the Bedside
5.2. Limitations
5.3. Future Directions
6. Conclusions
Supplementary Materials
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
| EMG | Electromyography |
| sEMG | Surface EMG |
| ETP | Electrical time product |
| SNR | Signal-to-noise ratio |
| AUB | Area under the baseline |
| ICU | Intensive care unit |
| ECG | Electrocardiogram |
| CLI | Command line interface |
| PyPI | Python Package Index |
| RMS | Root-mean-square |
| SWT | Stationary wavelet transform |
| n | Decomposition level |
| fc | Cutoff frequency |
| fs | Sampling frequency |
| MAD | Median absolute deviation |
| sEAdi | Surface electrical activity of the diaphragm |
| ARV | Average rectified value |
| cfhp | High-pass cutoff frequency |
| cflp | Low-pass cutoff frequency |
| CCMO | Central Committee on Research Involving Human Subjects |
References
- Fogarty, M.J.; Mantilla, C.B.; Sieck, G.C. Breathing: Motor control of diaphragm muscle. Physiology 2018, 33, 113–126. [Google Scholar] [CrossRef]
- Roesthuis, L.H.; van der Hoeven, J.G.; van Hees, H.W.H.; Schellekens, W.-J.M.; Doorduin, J.; Heunks, L.M.A. Recruitment pattern of the diaphragm and extradiaphragmatic inspiratory muscles in response to different levels of pressure support. Ann. Intensive Care 2020, 10, 67. [Google Scholar] [CrossRef]
- de Vries, H.J.; Jonkman, A.H.; de Grooth, H.J.; Duitman, J.W.; Girbes, A.R.J.; Ottenheijm, C.A.C.; Schultz, M.J.; van de Ven, P.M.; Zhang, Y.; de Man, A.M.E.; et al. Lung- and Diaphragm-Protective Ventilation by Titrating Inspiratory Support to Diaphragm Effort: A Randomized Clinical Trial. Crit. Care Med. 2022, 50, 192–203. [Google Scholar] [CrossRef]
- Ramsay, M.; Mandal, S.; Suh, E.-S.; Steier, J.; Douiri, A.; Murphy, P.B.; Polkey, M.; Simonds, A.; Hart, N. Parasternal electromyography to determine the relationship between patient-ventilator asynchrony and nocturnal gas exchange during home mechanical ventilation set-up. Thorax 2015, 70, 946–952. [Google Scholar] [CrossRef]
- Adler, D.; Perrig, S.; Takahashi, H.; Espa, F.; Rodenstein, D.; Pépin, J.L.; Janssens, J.-P. Polysomnography in stable COPD under non-invasive ventilation to reduce patient–ventilator asynchrony and morning breathlessness. Sleep Breath. 2012, 16, 1081–1090. [Google Scholar] [CrossRef]
- Sinderby, C.; Navalesi, P.; Beck, J.; Skrobik, Y.; Comtois, N.; Friberg, S.; Gottfried, S.B.; Lindström, L. Neural control of mechanical ventilation in respiratory failure. Nat. Med. 1999, 5, 1433–1436. [Google Scholar] [CrossRef] [PubMed]
- Bellani, G.; Bronco, A.; Marocco, S.A.; Pozzi, M.; Sala, V.; Eronia, N.; Villa, G.; Foti, G.; Tagliabue, G.; Eger, M.; et al. Measurement of diaphragmatic electrical activity by surface electromyography in intubated subjects and its relationship with inspiratory effort. Respir. Care 2018, 63, 1341–1349. [Google Scholar] [CrossRef]
- Kacmarek, R.M.; Berra, L.; Villar, J. On the Road to Surface Monitoring of Diaphragmatic Activity in Mechanically Ventilated Patients. Respir. Care 2018, 63, 1457–1458. [Google Scholar] [CrossRef]
- van Leuteren, R.W.; Hutten, G.J.; de Waal, C.G.; Dixon, P.; van Kaam, A.H.; de Jongh, F.H. Processing transcutaneous electromyography measurements of respiratory muscles, a review of analysis techniques. J. Electromyogr. Kinesiol. 2019, 48, 176–186. [Google Scholar] [CrossRef] [PubMed]
- Jonkman, A.H.; Warnaar, R.S.P.; Baccinelli, W.; Carbon, N.M.; D’cruz, R.F.; Doorduin, J.; van Doorn, J.L.M.; Elshof, J.; Estrada-Petrocelli, L.; Graßhoff, J.; et al. Analysis and applications of respiratory surface EMG: Report of a round table meeting. Crit. Care 2024, 28, 2. [Google Scholar] [CrossRef] [PubMed]
- Bota, P.; Silva, R.; Carreiras, C.; Fred, A.; da Silva, H.P. BioSPPy: A Python toolbox for physiological signal processing. SoftwareX 2024, 26, 101712. [Google Scholar] [CrossRef]
- Makowski, D.; Pham, T.; Lau, Z.J.; Brammer, J.C.; Lespinasse, F.; Pham, H.; Schölzel, C.; Chen, S.H.A. NeuroKit2: A Python toolbox for neurophysiological signal processing. Behav. Res. Methods 2021, 53, 1689–1696. [Google Scholar] [CrossRef] [PubMed]
- Wu, T.-L.; Alhossary, A.A.; Pataky, T.C.; Ang, W.T.; Donnelly, C.J. pyemgpipeline: A Python package for electromyography processing. J. Open Source Softw. 2022, 7, 4156. [Google Scholar] [CrossRef]
- Dos Reis, I.M.M.; Ohara, D.G.; Januário, L.B.; Basso-Vanelli, R.P.; Oliveira, A.B.; Jamami, M. Surface electromyography in inspiratory muscles in adults and elderly individuals: A systematic review. J. Electromyogr. Kinesiol. 2019, 44, 139–155. [Google Scholar] [CrossRef]
- Cabral, E.E.; Fregonezi, G.A.; Melo, L.; Basoudan, N.; Mathur, S.; Reid, W.D. Surface electromyography (sEMG) of extradiaphragm respiratory muscles in healthy subjects: A systematic review. J. Electromyogr. Kinesiol. 2018, 42, 123–135. [Google Scholar] [CrossRef]
- Silva Junior, E.F.F.d.; Campos, S.L.; Leite, W.S.; Melo, P.V.d.S.; Lins, R.A.C.; Araújo, M.d.G.R.d.; Guerino, M.R. Surface electromyography signal processing and evaluation on respiratory muscles of critically ill patients: A systematic review. PLoS ONE 2023, 18, e0284911. [Google Scholar] [CrossRef]
- Moore, C.M.; Baccinelli, W.; Sivokon, O.; Warnaar, R.S.P.; Soleimani, F.; Mos-Oppersma, E. ReSurfEMG, version: Latest; Zenodo. [CrossRef]
- Hermens, H.J.; Freriks, B.; Merletti, R.; Stegeman, D.; Blok, J.; Rau, G.; Disselhorst-Klug, C.; Hägg, G. European Recommendations for Surface ElectroMyoGraphy: Results of the SENIAM Project; Roessingh Research and Development: Enschede, The Netherlands, 1999; ISBN 9789075452150. [Google Scholar]
- Schweitzer, T.W.; Fitzgerald, J.W.; Bowden, J.A.; Lynne-Davies, P. Spectral analysis of human inspiratory diaphragmatic electromyograms. J. Appl. Physiol. 1979, 46, 152–165. [Google Scholar] [CrossRef] [PubMed]
- Lenis, G.; Pilia, N.; Loewe, A.; Schulze, W.H.W.; Dössel, O. Comparison of Baseline Wander Removal Techniques considering the Preservation of ST Changes in the Ischemic ECG: A Simulation Study. Comput. Math. Methods Med. 2017, 2017, 9295029. [Google Scholar] [CrossRef]
- Kligfield, P.; Gettes, L.S.; Bailey, J.J.; Childers, R.; Deal, B.J.; Hancock, E.W.; van Herpen, G.; Kors, J.A.; Macfarlane, P.; Mirvis, D.M.; et al. Recommendations for the Standardization and Interpretation of the Electrocardiogram. Circulation 2007, 115, 1306–1324. [Google Scholar] [CrossRef]
- Petersen, E.; Sauer, J.; Graßhoff, J.; Rostalski, P. Removing Cardiac Artifacts From Single-Channel Respiratory Electromyograms. IEEE Access 2020, 8, 30905–30917. [Google Scholar] [CrossRef]
- Clancy, E.A.; Morin, E.L.; Merletti, R. Sampling, noise-reduction and amplitude estimation issues in surface electromyography. J. Electromyogr. Kinesiol. 2002, 12, 1–16. [Google Scholar] [CrossRef] [PubMed]
- Graßhoff, J.; Petersen, E.; Farquharson, F.; Kustermann, M.; Kabitz, H.-J.; Rostalski, P.; Walterspacher, S. Surface EMG-based quantification of inspiratory effort: A quantitative comparison with Pes. Crit. Care 2021, 25, 441. [Google Scholar] [CrossRef]
- Warnaar, R.S.P.; Cornet, A.D.; Beishuizen, A.; Moore, C.M.; Donker, D.W.; Oppersma, E. Advanced waveform analysis of diaphragm surface EMG allows for continuous non-invasive assessment of respiratory effort in critically ill patients at different PEEP levels. Crit. Care 2024, 28, 195. [Google Scholar] [CrossRef]
- Warnaar, R.S.P.; Cornet, A.D.; Beishuizen, A.; Donker, D.W.; Oppersma, E. Advanced serial analysis of the diaphragm surface EMG: Insights into the effect of pressure support on the neuro-ventilatory response during the ICU stay. Crit. Care 2025, 29, 258. [Google Scholar] [CrossRef]
- Saboisky, J.P.; Gorman, R.B.; De Troyer, A.; Gandevia, S.C.; Butler, J.E. Differential activation among five human inspiratory motoneuron pools during tidal breathing. J. Appl. Physiol. 2007, 102, 772–780. [Google Scholar] [CrossRef]
- Warnaar, R.S.P.; Moore, C.M.; Baccinelli, W.; Sivokon, O.; Soleimani, F.; Oppersma, E. ReSurfEMG, version: V1.0.2; Zenodo. 2024. [CrossRef]
- Surawicz, B.; Childers, R.; Deal, B.J.; Gettes, L.S. AHA/ACCF/HRS Recommendations for the Standardization and Interpretation of the Electrocardiogram. Circulation 2009, 119, e235–e240. [Google Scholar] [CrossRef]
- Bertini, M.; Ferrari, R.; Guardigli, G.; Malagù, M.; Vitali, F.; Zucchetti, O.; D’Aniello, E.; Volta, C.A.; Cimaglia, P.; Piovaccari, G.; et al. Electrocardiographic features of 431 consecutive, critically ill COVID-19 patients: An insight into the mechanisms of cardiac involvement. EP Eur. 2020, 22, 1848–1854. [Google Scholar] [CrossRef] [PubMed]
- Hogan, N.; Mann, R.W. Myoelectric Signal Processing: Optimal Estimation Applied to Electromyography—Part I: Derivation of the Optimal Myoprocessor. IEEE Trans. Biomed. Eng. 1980, BME-27, 382–395. [Google Scholar] [CrossRef]
- Ninane, V.; Rypens, F.; Yernault, J.-C.; de Troyer, A. Abdominal Muscle Use during Breathing in Patients with Chronic Airflow Obstruction. Am. Rev. Respir. Dis. 1992, 146, 16–21. [Google Scholar] [CrossRef] [PubMed]
- Moore, C.M.; Baccinelli, W.; Sivokon, O.; Warnaar, R.S.P.; Mos-Oppersma, E. ReSurfEMG, version: V0.2.1; Zenodo. 2024. [CrossRef]
- Moore, C.M.; Baccinelli, W.; Sivokon, O.; Warnaar, R.S.P.; Oppersma, E. ReSurfEMG: A Python library for preprocessing and analysis of respiratory EMG. J. Open Source Softw. 2023, 8, 5251. [Google Scholar] [CrossRef]
- De Luca, C.J. The Use of Surface Electromyography in Biomechanics. J. Appl. Biomech. 1997, 13, 135–163. [Google Scholar] [CrossRef]
- Estrada, L.; Torres, A.; Sarlabous, L.; Jané, R. Improvement in Neural Respiratory Drive Estimation From Diaphragm Electromyographic Signals Using Fixed Sample Entropy. IEEE J. Biomed. Health Inform. 2016, 20, 476–485. [Google Scholar] [CrossRef]
- Sarlabous, L.; Aquino-Esperanza, J.; Magrans, R.; de Haro, C.; López-Aguilar, J.; Subirà, C.; Batlle, M.; Rué, M.; Gomà, G.; Ochagavia, A.; et al. Development and validation of a sample entropy-based method to identify complex patient-ventilator interactions during mechanical ventilation. Sci. Rep. 2020, 10, 13911. [Google Scholar] [CrossRef]
- Lozano-García, M.; Sarlabous, L.; Moxham, J.; Rafferty, G.F.; Torres, A.; Jané, R.; Jolley, C.J. Surface mechanomyography and electromyography provide non-invasive indices of inspiratory muscle force and activation in healthy subjects. Sci. Rep. 2018, 8, 16921. [Google Scholar] [CrossRef] [PubMed]









| BioSPPy | NeuroKit2 | Pyemgpipeline | ReSurfEMG | |
|---|---|---|---|---|
| Filtering | + | +/− | + | ++ |
| ECG removal | − | − | − | ++ |
| Envelope extraction | + | + | + | + |
| Event detection | + | + | − | ++ |
| Waveformfeatures | − | − | − | ++ |
| Quality assessment | − | + | − | ++ |
| Synthetic data | + | + | − | ++ |
| Auxiliary physiological signals | ABP, ACC, BVP, ECG, EDA, EEG, PCG, PPG, resp. | ECG, EDA, EEG. EOG, PPG, resp. | − | Respiratory pressures, flows, volumes |
| ReSurfEMG Subpackage | Modules | Description |
|---|---|---|
| data_connector | config | Configure default paths for data analysis |
| file_discovery | Detect folders and files | |
| converter_functions | Load data in ReSurfEMG standard format | |
| tmsisdk_lite | ReSurfEMG adaptation of TMSi SDK library | |
| adicht_reader | ReSurfEMG adaptation for importing .adicht data | |
| synthetic_data | Generate synthetic sEMG and auxiliary data | |
| data_classes | Object-oriented data processing for TimeSeries data | |
| peakset_class | Object-oriented handling of waveform features and quality | |
| preprocessing | filtering | Remove baseline drift and powerline noise |
| ecg_removal | Remove ECG components | |
| envelope | Calculate sEMG envelope | |
| postprocessing | baseline | Calculate dynamic sEMG baseline |
| event_detection | Detect breathing events | |
| features | Calculate sEMG and auxiliary data features | |
| quality_assessment | Assess sEMG and auxiliary data quality | |
| helper_functions | math_operations | Data agnostic math operations |
| visualization | Visualize basic signal characteristics | |
| data_classes_quality_assessment | The quality assessment functions for the data class TimeSeries objects | |
| pipelines | ipy_widgets | Standardized Jupyter Widgets |
| processing | Standardized signal processing pipelines | |
| synthetic_data | Standardized synthetic data generation | |
| cli | cli | Command line interface: Run the library from the command line outside a Python environment or shell |
| Processing Step | Range | Default | Under-Filtering | Over-Filtering |
|---|---|---|---|---|
| Filtering [18,19,23] | ||||
| High-pass cutoff | 10–100 Hz | 20 Hz | 15 Hz | 30 Hz |
| Low-pass cutoff | 30–1000 Hz | 500 Hz | 1000 Hz | 500 Hz |
| Filter order | 1–8 | 3 | 1 | 3 |
| ECG removal: Gating [29,30] | ||||
| Gate width | 0.05–0.40 s | 0.20 s | 0.15 s | 0.30 s |
| Filling method | Zeros/Prior average/Raw interpolation/RMS interpolation | RMS interpolation | RMS interpolation | RMS interpolation |
| ECG removal: Wavelet denoising [22] | ||||
| Decomposition level | 2–6 | floor(log2(fs/20)) | N/A | N/A |
| Fixed threshold | 4.0–12.0 | 4.5 | N/A | N/A |
| Envelope: RMS and ARV [25] | ||||
| Window length | 0.10–1.00 s | 0.25 ms | 0.10 ms | 0.50 ms |
| Moving baseline [24,25] | ||||
| Window length | 1–10 s | 7.5 s | 7.5 s | 7.5 s |
| Percentile | 10th–50th | 33rd | 20th | 33rd |
| Filtering | Under (n = 158) | Default (n = 158) | Over (n = 158) |
|---|---|---|---|
| Features | |||
| Duration (s) | 1.0 (0.2) −12% | 1.2 (0.2) | 1.4 (0.1) +18% |
| Tmax (s) | 0.5 (0.1) −18% | 0.6 (0.1) | 0.6 (0.1) +13% |
| Amplitude (µV) | 4.0 (0.8) +21% | 3.3 (0.7) | 1.4 (0.4) −58% |
| ETP (µV.s) | 2.1 (0.3) +10% | 1.9 (0.4) | 1.2 (0.3) −39% |
| Pseudo-slope (µV/s) | 12.9 (5.8) +61% | 8.0 (1.9) | 4.1 (0.9) −49% |
| Quality aspects | |||
| Pseudo-SNR (.) | 3.1 (0.4) −4% | 3.2 (0.5) | 1.9 (0.3) −40% |
| AUB (%) | 15.6 (3.3) +9% | 14.3 (3.7) | 20.8 (6.3) +46% |
| Bell error (%) | 21.2 (5.0) +73% | 12.3 (3.8) | 7.1 (2.7) −42% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Warnaar, R.S.P.; Moore, C.M.; Baccinelli, W.; Soleimani, F.; Donker, D.W.; Oppersma, E. ReSurfEMG: A Python Package for Comprehensive Analysis of Respiratory Surface EMG. Sensors 2025, 25, 6465. https://doi.org/10.3390/s25206465
Warnaar RSP, Moore CM, Baccinelli W, Soleimani F, Donker DW, Oppersma E. ReSurfEMG: A Python Package for Comprehensive Analysis of Respiratory Surface EMG. Sensors. 2025; 25(20):6465. https://doi.org/10.3390/s25206465
Chicago/Turabian StyleWarnaar, Robertus Simon Petrus, Candace Makeda Moore, Walter Baccinelli, Farnaz Soleimani, Dirk Wilhelm Donker, and Eline Oppersma. 2025. "ReSurfEMG: A Python Package for Comprehensive Analysis of Respiratory Surface EMG" Sensors 25, no. 20: 6465. https://doi.org/10.3390/s25206465
APA StyleWarnaar, R. S. P., Moore, C. M., Baccinelli, W., Soleimani, F., Donker, D. W., & Oppersma, E. (2025). ReSurfEMG: A Python Package for Comprehensive Analysis of Respiratory Surface EMG. Sensors, 25(20), 6465. https://doi.org/10.3390/s25206465

