Analysis and Smoothing of EMG Signal Envelope Using Kalman and UFIR Filtering under Colored Measurement Noise

This article describes some filtering methods to remove artifacts from the EMG signal envelope. Diverse EMG waveforms are studied using the Kalman filter (KF) and unbiased finite impulse response (UFIR) filter. The filters are developed in discrete-time state-space for Gauss-Markov colored measurement noise (CMN) and termed as cKF and cUFIR. It is shown that a choice of a proper CMN factor allows extracting the EMG waveform envelope with a high robustness. Extensive investigation have shown that the cKF and cUFIR filter are most efficient when the density is low of the motor unit action potential (MUAP) of the EMG and the Hilbert transform is required. Otherwise, when the envelope is well-pronounced and well-shaped with sharp edges due to a high MUAP density, the filters can be applied directly without using the Hilbert transform.


Introduction
The electromyography (EMG) signals are records of the motor unit action potential (MUAP) used in clinical/biomedical applications to detect and analyze voltage changes within any organ of interest. Such signals are describable in terms of the amplitude, frequency, and phase [1,2] and can be processed using different kinds of finite impulse response (FIR) estimators [3][4][5][6][7]. The EMG signal is complex, because the MUAPs are acquired from diverse areas of the motor unit (MU). For example, a skeletal muscle contains hundreds of different muscle fiber types, and the resulting signal is composed by several MUAPs [2,[8][9][10][11][12][13].
EMG signals contain useful information, but these signals are typically contaminated by sensor noise and artifacts originating from different sources such as electrocardiography interference, spurious background spikes, motion artifact, power line interference [2,14]. Because errors may have a significant affect on EMG data, special signal processing algorithms are required to extract useful information with sufficient accuracy. Many solutions relying on modern technologies have been proposed to extract the EMG signal features and analysis the MU behavior. In biomedical applications, the EMG signal features can be used to detect diseases [2,15].
The envelope of the EMG signal is used in robotic systems and prothesis control [16] to achieve a perfect collaboration between man and robot. The most representative techniques to extract the EMG signal envelope are the Hilbert transform [17], mean square error (MSE) criterion [18], and waveform produced by the rectified signal [19]. Many algorithms have been developed to extract * e-mail: shmaliy@ugto.mx * * e-mail: ibarrao@ugto.mx the EMG signal envelope. The algorithms primarily exploit the envelope reflecting the moving average activity and provide noise reduction [20], but suffer of unacceptably large bias errors and do not avoid spikes. Better results are achieved employing the Savitsky-Golay smoother combined with a low-pass filter [21]. Smoothing provides better envelope shaping, but introduces time-delay-lags, which may not be tolerated in robotic schemes. In [16,22], the EMG signal envelope has been extracted taking advantage of time-frequency analysis via the EMG signal energy on given finite time windows. Another approach developed in [23] suggests rectifying the surface EMG prior to subsequent coherence analysis. The rectification often enhances the firing rate information, but typically does not avoid problems with high envelope variability [24].
Optimal Kalman filter (KF) and Wiener filter algorithms have been developed for EMG signals by many authors [25][26][27][28][29]. Although the classic KF setting allows achieving a maximum estimation accuracy, noise is required to be white Gaussian with known statistics. Therefore, the KF may not be efficient in EMG data analysis unless certain requirements are satisfied. Because noise in EMG data is strictly not white, no essential advantage of the KF was demonstrated so far against other available methods. Another approach developed by Shmaliy and referred to as unbiased finite impulse response (UFIR) filtering [3] completely ignores the zero mean noise and therefore is considered as a robust alternative to KF [30]. Both the KF and UFIR filter may be more efficient under a supposition of the colored measurement noise (CMN).

Extraction of EMG Signal Envelope under CMN
The EMG signal u(t) voltage typically ranges as ±5 mV prior to amplification [2]. A suggested sampling frequency F = 2 kHz [31] corresponds to a sampling time of τ = 0.5 ms, although F may range as (0.25 . . . 3) Hz [32]. A spectral peak of the EMG signal is typically found at (60 . . . 100) Hz and some parts of a digital version u n of the EMG signal may thus be highly oversampled in the discrete time index n corresponding to time t n and τ = t n − t n−1 . If the fiber-generated MUAP density is low, the Hilbert transformû n of u n can be used to draw the envelope U n = u 2 n +û 2 n . Otherwise, if the MUAP density is high and the envelope edges are sharp, the Hilbert transform is not applied. Accordingly, two specifics of the EMG signal envelope can be recognized: • Oversampled parts of U n can be approximated with Korder polynomials.
• Envelope U n is commonly highly disturbed by multiple excursions and special algorithms are required to extract it for applications in robotics and control systems.

State-Space Model of EMG Signal Envelope
Let us represent the envelope U n in discrete-time index n with the K-state-space polynomial model [33] assuming Gauss-Markov CMN v n as where x n ∈ R K is the U n state vector and y n is the scalar observation of U n . For polynomial approximation, entries of the system matrix F are provided by the Taylor series [33,34], Observation y n of U n corresponds to the first state. Therefore, the observation matrix is Matrix B ∈ R K×P projects U n noise w n ∈ R P to x n . A scalar color factor ψ is supposed to be known and such that noise v n is stationary; by ψ = 0, noise v n is supposed to be white, as required by optimal estimators. Because noise w n is generally unknown, we will suppose that it has zero mean with uncertain statistics. However, to run the KF, we will consider w n as white Gaussian, w n ∼ N(0, Q) ∈ R P , with the covariance E{w n w T k } = Qδ n−k , where δ n is a Kroneker symbol, which has unknown entries. Noise ξ n is zero mean and white Gaussian, ξ n ∼ N(0, σ 2 ξ ), with the variance E{ξ 2 n } = R = σ 2 ξ and the property E{w n ξ k } = 0 for all n and k.
We assume that the estimatex n x n|n of x n under the intensive non white variations in U n will range closer to the desired envelope if to suppose the CMN. Therefore, below we will develop two possible linear approaches to shape U n : the KF, which requires all information about the initial values and supposedly white Gaussian noise, and the UFIR filter, which completely ignores these requirements and is thus more robust [30].

Extraction of EMG Signal Envelope under CMN
The known KF algorithms assuming CMN were designed for the forward Euler model x n = F n x n−1 + B n w n−1 , which differs from (1) by the past noise term w n−1 . On the other hand, the UFIR filter was derived in [33] for the backward Euler model (1). To unify the solutions, we will modify the KF and UFIR algorithms for (1)-(3) and call them accordingly as cKF and cUFIR.

cKF Algorithm
To apply the KF to (1)- (3), one can follow [35], consider a new observation z n as measurement differences, and write By taking x n−1 from (1) and v n−1 from (3), a new observation can be written as where D n = H n − Γ n , Γ n = ψ n H n−1 F −1 n , and v n = Γ n B n w n + ξ n is white Gaussian scalar noise with the properties, where the weighted matrix Q n is The modified state-space model (1) and (6) has now time-correlated and white w n andv n and the KF can be applied, if to derive the optimal bias correction gain taking into account the correlation. For given y n ,x 0 , P 0 , Q n , R n , ψ n , and CMN, the cKF algorithm becomes z n = y n − ψ n y n−1 , S n = D n P − n D T n + R n + H n Φ n + Φ T n D T n , x and, by ψ n = 0 and Φ n = 0, it becomes the standard KF.

UFIR Filtering Algorithm
The UFIR filter [3] can be more suitable for EMS signals, because it does not require any information about noise, except for the zero mean assumption [36,37]. To provide a near optimal estimate, this filter requires an averaging horizon [m, n] of N points, from m = n − N + 1 to n, to be optimal N opt in the MSE sense. Of importance is that w n andv n are both zero mean and their correlation does not produce bias. Therefore, the UFIR filter can be applied directly to (1) and (6), unlike the KF.
The cUFIR algorithm operates as follows. Given N, y n , and ψ n , one must set n = N − 1, N Provided the initial values at s, iteratively updated values appear for l = s + 1, . . . , n using the recursions and the output estimatex n =x n is taken when l = n. It also follows that, by ψ n = 0, the cUFIR algorithm becomes the standard UFIR filter [3].

Applications
In this section, we will apply the cKF and cUFIR algorithms to two types of EMG data. First, we will consider EMG signals with low MUAP density, which require the Hilbert transform to shape the envelope. Next, we will process well-pronounced EMG signals with high MUAP density and sharp edges, in which case only better denoising of the envelope is required. For all EMG data, we specify model (1)-(3) with two states, K = 2, and matrices We suppose that the envelope noise w n acts in the third state and projects to state x n by matrix B.

First experiment
We start with a surface EMG signal database collected for lower limb analysis and available from [38]. The database contains samples from 11 subjects with knee abnormality previously diagnosed by a professional and 11 normal knees. All data are collected using the EMG and goniometry equipment MWX8 Datalog Biometrics. Measurements are provided with the sampling frequency F = 1 kHz that corresponds to τ = 10 −3 s. A part of database "1Amar" observed in a time span of (2.6 . . . Fig.  1a. The envelope for low MUAP density was shaped here using the Hilbert transform and sketched in Fig. 1b and Fig. 1c as "data." No information about noise is provided in [38]. Therefore, we voluntary tune the filters to produce consistent estimates with minimal variations about the desired smooth envelope and insignificant time-delays. For the UFIR filter we have experimentally found N opr = 74, which means that data are highly oversampled. To tune the KF, we suppose that the measurement noise has the standard deviation of σ ξ = 50 µV and set σ w = 0.1 V/s 2 for the KF estimate to be consistent to the UFIR estimate. We then run both filters and arrive at estimates shown in Fig. 1b. As can be seen, both filters shape the envelope much better than the Hilbert transform with no essential time-delays, as required. However, the envelope is still corrupted by multiple excursions.

3.4) s is shown in
To suppress excursions, we next tune the cKF and cU-FIR algorithms for ψ = 0.75 andN opt = 140. The results are shown in Fig. 1c. Even a quick look at this figure reveals that excursions are removed from many parts of the envelope, which definitely looks more smoothed.

Second experiment
we next considered an "aggressive" EMG signal from the database "Elbowing," which is available from [39]. A selected part of the signal shown in Fig. 2a was processed similarly to the first one ( Fig. 1) with the same tuning parameters. As can be concluded, the KF and UFIR filter still produce consistent estimates with no essential timedelays. It can also be seen that the cKF and cUFIR fil-  ter suppress excursions by ψ opt = 0.75. On a broader timescale, envelopes of several EMG "Elbowing" signals provided using all filters are given in Fig. 3. This figure assures that the interpretation of variations in the EMG signal as Gauss-Markov CMN allows getting better envelope shaping and artifacts removal. That means that optimal estimators developed for CMN may be considered as main tools for the EMG signal envelope extraction.
We can now made two important conclusions: • The color factor ψ must be optimized for the best desirable envelope shape, • Factor ψ should not exceed 1.0, because v n does not obey the requirement of stationarity otherwise.

EMG Signals for High MUAP Density with Sharp Edges
Finally, we consider several well-pronounced EMG signals with high MUAP densities and sharp edges, which absolute values sampled with F = 2 kHz and τ = 0.5 ms are available from [40]. From this database, we select two types of EMG signals represented with 1) impulse sequences (Fig. 4a) and 2) continuously generated MUAPs (Fig. 5a). We do not apply the Hilbert transform to these data and tune the filters for σ w = 0.3 V/s 2 , σ ξ = 50 µV, N opt = 70, andN opt = 110. A specific is that, for high MUAP density, the envelope noise becomes more like white rather than colored, although it is still definitely not white. This observation means that the color factor ψ should be smaller than in the above considered cases. Furthermore, because the colored noise is less pronounced, one should expect lesser effects from the cKF and cUFIR filter that will be illustrated below.

EMG Impulse Sequences with Sharp Edges
The envelopes shaped by the KF and UFIR filter for an EMG impulse sequence with sharp edges shown in Fig.  4a are sketched in Fig. 4b and one infers that there is not big difference between the estimates. Aimed at providing better shaping, the cKF and cUFIR filter are next applied with the color factor ψ opt = 0.6 to produce the envelopes shown in Fig. 4c. Note that the value of ψ is smaller here than in the above cases, as expected. Although the CMN in Fig. 4a is not as large as in the previous case (Fig. 1), the cKF and cUFIR filter still improve the envelope smoothness and suppress some artifacts. This is especially neatly seen in the last fifth impulse in Fig. 4, where the envelope is shaped better and two small artifacts observed in Fig. 4b are well suppressed in Fig. 4c.

Continuously Generated EMG Signals
In the last experiment, we consider the case of a continuously generated EMG signal with a high MUAP density shown in Fig. 5a. Again we observe that the envelope noise looks here more like white and that the colored noise is less pronounced. Accordingly, there is no big difference between the envelopes shaped by the KF and UFIR filter in Fig. 5b and cKF and cUFIR filter in Fig. 5c. Nevertheless, the envelopes are better smoothed in Fig. 5c that speaks in favor of the cKF and cUFIR filter. This experiment leads to a conclusion that the improved filters can be applied universally to EMG signals by setting small ψ for near white and large ψ < 1 otherwise.

Conclusions
The Kalman and UFIR filtering algorithms developed in this paper as cKF and cUFIR for EMG signals assuming CMN in the envelope have demonstrated better performance than the standard solutions. The effect was achieved by suppressing the color noise-like variations and artifacts in the envelope with no essential time delays. Based upon extensive investigations, we suggest that the cKF should be used when a sufficient information is available about noise. Otherwise, one should apply the cUFIR filter, which ignores zero mean noise and is thus more robust against errors in the noise statistics.
Experimental verification provided based on different EMG signals have shown that the cKF and cUFIR algorithms are efficient when the MUAP density is low, in which case intensive excursions in the envelope are reminiscent of the colored noise. Shaped with a high MUAP density, the envelope typically demonstrates smaller variations and the filters designed become less efficient. In both cases, the color factor must be optimized to approach the desired envelope in the best way.