EMG preprocessing tools

Functions to denoise High Density EMG signals.

EMG Contamination

This ECG-artifact filter is based on the paper Mak, J. N., Hu, Y., & Luk, K. D. (2010). An automated ECG-artifact removal method for trunk muscle surface EMG recordings. Medical engineering & physics, 32(8), 840-848. DOI: 10.1016/j.medengphy.2010.05.007 and on "Rectification and non-linear pre-processing of EMG signals for cortico-muscular analysis." from Myers et al. DOI: 10.1016/s0165-0270(03)00004-9 for the pre-processing of the HD EMG.

The following function remove ECG contamination from High Density EMG signals. This is the matlab implementation of the work described in "Mak, J. N., Hu, Y., & Luk, K. D. (2010). An automated ECG-artifact removal method for trunk muscle surface EMG recordings. Medical engineering & physics, 32(8), 840-848." With the following changes:

Example

Before:
before CCA filter
After:
before CCA filter

Principle

Movement artifact, PLI, WGI contamination

This filter remove movement artifact, power line interference and white gaussian noise. It is based on the paper "Al Harrach, M., Boudaoud, S., Hassan, M., Ayachi, F. S., Gamet, D., Grosset, J. F., & Marin, F. (2017). Denoising of HD-sEMG signals using canonical correlation analysis. Medical & biological engineering & computing, 55(3), 375-388."

IMPORTANT: The algorithm needs a 0.5 seconds of signal without any muscle activity. So either add it a posteriori or be carefull to have enough room in your signal. The selection and the PNR algorithms depends on it.

/!\ WARNING /!\ If your HD EMG signals are contaminated by ECG artifacts, it is vividly recommended to filter them out first before using this filter. Indeed the chance of successful use dramatically lower if there is ECG contamination of the signals.

Example

Before:
before CCA filter
After:
before CCA filter

Principle

Baseline wander fluctuation

This filter remove baseline wander also called baseline fluctuation. It is based on the paper "Fasano, A., & Villani, V. (2014). Baseline wander removal for bioelectrical signals by quadratic variation reduction. Signal Processing, 99, 48-57." for the filter and is using sparsity measure from "Hurley, N., & Rickard, S. (2009). Comparing measures of sparsity. IEEE Transactions on Information Theory, 55(10), 4723-4741." Two part of the algorithm are personal implementation and have not been peer reviewed:

Example

Before:
before CCA filter
After:
before CCA filter

Principle

The filter works by minimizing the variability of the signal by minimizing it quadratic variation, a measure of the signal variability. Baseline wander is estimated solving a constrained convex optimization problem where quadratic variation enters as a constraint.

Optimization:
This filter uses a matrix inversion of a matrix of the size N\*N, thus being extremely costly memory and computationally wise. Because the matrix is a tridiagonal, symmetric, positive-definite system it is possible to “linearize” the calculus. To do so the equation (16) have been developed, and the linear system solver “\\” has been used to “get rid of” the standard inverse calculation. This is possible due to the aforementioned specific properties of the system. More details and explanation can be found in the books from Golub matrix computation. Nonetheless, clear optimization process not being detailed in Fasano et al, 2014, the optimization process implemented here might not be the one used by the author of the article.
Gradient descent:
The process to find the optimal lambda for the filter is not detailed in Fasano et al., 2014. Therefore, the process implemented here is of my own design. The logic behind it is, we are facing a signal away from the baseline it should be on, which is 0. The filter is trying to get the signal back on this baseline. As the signal get filtered closer and closer to the baseline, the number of 0 value increase. We therefore can formulate the problem as a sparsity problem. The gradient descent work on the following logic: if sparsity of sFilt(n-1) - sparsity of sFilt(n) < 0 then stop --> we found the optimal lambda. The formula used have been chosen from Hurley, N., & Rickard, S. (2009). Comparing measures of sparsity. IEEE Transactions on Information Theory, 55(10), 4723-4741, and selected for their behavior that seemed to get close to the optimal lambda found experimentally.

Technologies

The project has been developped on MATLAB 2018a 9.4.0.813654, on windows 10 64 bits.

Setup

The filters are matlab function, to run them, just download them then add them to your matlab path.

How to cite

Robinault Lucien (2021). EMG preprocessing tools V1.0.0 (https://github.com/TSS-22/EMG-preprocessing-tools), GitHub. DOI: 10.5281/zenodo.4441389

Sources

Disclaimer

The information and tools contained in this repository are provided in good faith and no warranty, representation, statement or undertaking is given regarding any information or tool connected with this repository and any warranty, representation, statement or undertaking whatsoever that may be expressed or implied by statute, custom or otherwise is hereby expressly excluded. The use of the tools in this repository and any information in this repository is entirely at the risk of the user. Under no other circumstances the author should be liable for any costs, losses, expenses or damages (whether direct or indirect, consequential, special, economic or financial including any loss of profits) whatsoever that may be incurred through the use of any information or tools contained in this repository. This repository may contain inaccurate information. Which the author is under no responsibility to update or correct any such information or to even maintain this repository. Which the author reserves its right to change any information or any part of this repository without notice.