Adaptive Filtering of Accelerometer and Electromyography Signals Using Extended Kalman Filter for Chewing Muscle Activities

. Today Electromyography (EMG) and accelerometer (MEMS) based signals can be used in the clinical diagnosis of physical states of muscle activities such as fatigue, muscle weakness, pain, and tremors and in external or wearable robotic exoskeletal systems used in rehabilitation areas. During the record-ing of these signals taken from the skin surface through non-invasive processes, analysis of the signal becomes difficult due to the electrodes attached to the skin not fully contacting, involuntary body movements, and noises from peripheral muscles. In addition, parameters such as age and skin structure of the subjects can also affect the signal. Considering these nega-tive factors, a new adaptive method based on Extended Kalman Filtering (EKF) model for more effective filtering of the muscle signals based on both EMG and MEMS is proposed in this study. Moreover, the accuracy of the parametric values determined by the filter automatically according to the most effective time and frequency features that represent noisy and filtered signals was determined by different machine learning and classification algorithms. It was verified that the filter performs adaptive filtering with 100 % effectiveness with Linear Discriminant.


Introduction
Surface Electromyogram (EMG) based measurement systems have been used for years, especially in exoskeletal systems based on lower and upper extremity muscles [1], [2] and [3], determining fatigue and pain in these muscles [4] and [5], detecting tremors due to Parkinson's disease [6], [7] and [8], and diagnosis of conditions such as bruxism based on lower jaw muscle activities [9] and [10]. In addition, as an alternative to EMG measurements especially in detecting muscle activities, Microelectromechanical Systems (MEMS) for detecting micro-vibrations in muscles for the direction and control of movement are also being used recently [11], [12] and [13]. However, all these systems can be easily affected by external factors, noises originating from the measured subjects, and other disadvantages. When EMG systems are considered, the most important factor is the Signalto-Noise Ratio (SNR). In processing of EMG signals, the signal is obtained by amplifying very low voltage signals received from EMG probes, in other words, Motor Unit Action Potential (MUAP) signals; however, this also amplifies the existing noises. Another disadvantage of using EMG signals is the interference caused by electromyographic signals from neighboring muscles. Moreover, change in skin impedance due to factors such as the sensor probes not fully contacting the skin, sweatiness of the skin, and hard skin may cause faulty measurement, leading to faulty classification [13] and [14]. The disadvantage of accelerometerbased MEMS systems, on the other hand, is that since they detect micro-vibrations on the skin surface related to muscle contractions, they are very sensitive to highamplitude noise at low frequencies up to 5 Hz originating from vibrations caused by involuntary body movements of individuals [5].
In this study, an Extended Kalman Filter (EKF) based adaptive filtering model that can deliver meaningful frequency components of both MEMS or EMG signals and eliminate unwanted components by itself without using an external hardware analog filter is proposed. Thus, considering the meaningful frequency ranges of 5-100 Hz for MEMS signals [5] or 10-500 Hz for EMG signals [14], noises outside these frequency ranges, in other words, noises induced by involuntary body movements, noises caused by impedance changes due to skin contact, and electromagnetic-induced highfrequency noises can be eliminated. The major benefit of this study is that Process Noise (PN) and Measurement Noise (MN) parameters used in filtering can be determined automatically depending on the environmental conditions. A special calibration method was developed for this. To do this, the most effective time and frequency characteristics of EMG or MEMS based signals were determined separately by regression analysis and Minimum Square Error (MSE), calculated for each determined feature. In addition, the performance of the proposed method is tested by classification with Linear Discriminant (LD) algorithm. Although the proposed method is suitable for all skeletal muscles, for testing the method, EMG signals are obtained from the masseter and MEMS signals are obtained from the temporal muscles since the lower jaw (mandibula) and the head are in continuous movement and these noisy signals can be filtered effectively. Therefore, this is a useful adaptive method for effective filtering of EMG and MEMS-based signals obtained from lower and upper extremity skeletal muscles. Moreover, since additional hardware is not required for filtering, the system has small dimensions and is economical.

2.
Materials and Methods

Signal Acquisition and Pre-Processing
In this study, EMG and MEMS recordings were taken at different times from the movable lower jaw (masseter and temporalis) muscles of 20 subjects between the ages of 14 and 42 (average age of 25), resulting in a total of 60 different signals to be used in filtering experiments. The EMG sensor's (+) and (−) probes were attached to the skin surface of the masseter muscle to have 1 cm spacing between them. The MEMS sensor was fastened by using a wearable headband to coincide with the surface of the temporalis muscle. All subjects were informed in accordance with the Helsinki Declaration and reminded that they were free to opt out of the experiment at any time. Moreover, the participants filled out a questionnaire about anxiety, sleep habits, stress, fatigue, and jaw pain. This study is carried out at Yıldız Technical University within the scope of doctoral thesis, depending on ethical rules. It is prepared in accordance with ethical rules and an ethics report is available.
In this study, "z" axis of ADXL335 MEMS accelerometer sensor was used. In addition, the EMG sensor probes used in this study are AgCl bipolar electrodes. The signals received from these electrodes were amplified with an adjustable gain AD624 instrumentation amplifier (Gain: 1000, CMMR>80 dB). The amplified EMG and MEMS signals were digitized in order to have 4500 samples per second (fs: 4500 Hz) and data recordings were made for each subject. For digitizing these signals, 32-bit Atmel SAM3X8E ARM Cortex-M3 microcontroller with 12-bit A/D converter was used and they were transferred to the PC environment at Baud Rate: 250 000 bps. Matlab R2019b software was used for analyzing and testing the proposed approach. In addition, in order to compare the performance of the proposed method with the traditional analog filtering method in the literature, second-order Butterworth filters were used considering the meaningful frequency range of 10-500 Hz for EMG signals obtained from the muscles. Likewise, considering that meaningful frequency range of MEMS accelerometer signals is 5-100 Hz because of their being sensitive to involuntary body movements, fourth-order Butterworth bandpass filter was used. The experimental setup for the proposed method is shown in Fig. 1.

System Calibration
Before moving on to the filtering experiments, signals obtained from lower jaw muscles were calibrated for each subject. Each subject was made to wear an oral apparatus and then their Maximum Voluntary Contraction (MVC) value was determined. For this, the subjects were asked to squeeze their jaws for 3 seconds at the maximum level. This way, Root Mean Square (RMS) values of the micro-vibration MEMS signals when the subjects squeeze their jaws and contraction-induced EMG signals were determined. In the next stage, jaw closing movements at 10 % MVC levels were repeated at different times. These repetitions were performed as jaw closing (contraction) and opening (relaxation) with 3 sec intervals and all these signals were recorded in the PC environment. Thus, data recordings can be taken such that the amplitude values will be 10 % MVC during these movements.   RMS values of the signal are used for determining MVC levels [4], [15] and [16].
Another step is the calibration of the system. This is done through the system's adjusting its internal parameters adaptively considering the noises induced by external factors, peripheral muscles, contact of the sensor with the surface depending on the skin texture of the subjects and their involuntary movements before filtering signals obtained at 10 % MVC value by using EMG or MEMS sensors. Therefore, first of all, MSE [17] values of the obtained signals are determined according to Eq. (1).
In Eq. (1), squared sum of differences of signal values at each point k from 1 to N is taken. In this equation, R k stands for the value of the reference signal at point k,X k stands for the value of the signal estimated by EKF at point k. The reference signal represents the sig-nal that we desire to obtain from the subjects using an external analog bandpass filter structure. The system can adjust the PN and MN parameters of the EKF until it reaches the minimum value of the MSE parameter. PN and MN parameters in our study can assume values from 0 to 1. These values vary depending on MSE. Figure 2 shows the changes in these values graphically.

The Proposed Adaptive Filter Model Based on EKF
Kalman Filter (KF) was introduced by Rudolf Kalman. This model is being used in position tracking systems of space vehicles, robotic control systems, and biomedical signal processing systems [18]. Kalman filter is applicable to linear systems only. To effectively remove noise in nonlinear systems, extended Kalman filter was developed [19]. Since EMG and MEMSbased accelerometer signals obtained from the human  body are nonlinear signals, EKF was preferred over KF in this study. Therefore, in each time step of the EKF model, the signals to be filtered are linearized. According to this approach, a noisy X k signal predicts theX k signal without noise. X k is the value of signal X at moment k, Z k is the measured value of signal X at moment k. w k and v k values are respectively process noise and measurement noise of the signal at moment k [20], [21] and [22]. However, although these parameters are important for the effective operation of the system, there is no specific standard for their determination. The values of these parameters for different applications are different for effective filtering. Therefore, determining these parameters according to changing environmental conditions is the main principle of this study. For this purpose, the proposed system uses MSE value. These noise parameters are updated by the system for the case when MSE parameter is minimum for EKF to be adaptive [20], [21] and [22].
In this model, provided that the w k is constant, the system can adjust v k parameter of the EKF until it reaches the minimum value of the MSE param-eter. This parameter varies depending on MSE. Figure 2 shows the changes in these values graphically. MSE values are updated by comparing X k signal value obtained through EKF with the reference signal R k and thus v k value of the system is determined again such that the system is adaptive. In the updating of the MSE, the new value ofv k is calculated by adding or subtracting the weight coefficient (ρ) to v k using Eq. (2) until it reaches the minimum. The momentum coefficient (γ) in this equation is used to adjust the sensitivity of the system. If this coefficient is small, the system makes more iterations and obtain the most sensitive MSE value. The flow chart of this proposed system is shown in Fig. 3

Determination of Features for Performance Analysis
In order to investigate the effectiveness of the proposed method, distribution and standard deviation of the features that contain time and frequency information of the raw data obtained from the subjects and the filtered data were analyzed. For this, values for 13 features frequently used in the literature were obtained. Three of these features, which are used most widely in the literature especially for detection of mus-

Statistical Analysis
A total of 13 features are obtained from each of the EMG and accelerometer signals received from the subjects. By performing statistical regression analysis for each of these parameters, their effect on the output was determined in order to be used in performance evaluations. Signals obtained as an output of the contraction of the jaw muscles of the subjects before filtering are labeled as "0" and filtered signals are labeled as "1". In order to distinguish these two cases from each other, the regression and Pearson values (p-values) of the features before and after filtering were determined. These results are shown statistically in Tab. 1. Therefore, 6 features with the highest correlation were identified in order to analyze the performance of the filter. These are MNF, ZC, WL, SSC, AAC and DASD.
Here, N is the number of classes, NCCS is the number of correctly classified samples, TNS is the total number of samples obtained from the confusion matrix in MATLAB software [23].

Experimental Results
Reference signals were generated by using second and fourth-order Butterworth external analog bandpass filters considering the meaningful frequency ranges of 10-500 Hz [14] for EMG signals and 5-100 Hz [5] for MEMS signals. The signals were obtained in real time from tooth clenching movements due to contraction of the lower jaw muscles, movements in the relaxation position, as well as parafunctional chewing movements. The filtering performance of the adaptive EKF model proposed in our study was measured. Figure 4 and Fig. 5 show the graphs of time-dependent amplitudes of EMG and MEMS based signals, which are unfiltered, reference filtered signal and signal filtered with our proposed adaptive EKF model.
As can also be seen in Fig. 5, parafunctional teeth grinding movements obtained from the accelerometer signal are created by rhythmic contraction and relaxation of the lower jaw muscles. During contraction, rhythmic amplitude bursts can be seen. This is also important for the diagnosis of sleep bruxism disorders. However, when the figure is examined, this situation is not very apparent in the graph of the unfiltered signal, but the vibration amplitude bursts detected by the accelerometer MEMS sensor at the time of contraction are clearly visible in the filtering of the same signal made by EKF estimation in the 5-100 Hz interval. During relaxation, the vibration amplitude values are very close to zero, since the noises are elimi-nated. Thus, the raw noisy signal has become meaningful. In addition, the frequency spectra of the same signals are shown in Fig. 6 and Fig. 7.
When the frequency spectra in Fig. 6 are examined, the meaningful frequencies of the EMG signals are up to 500 Hz [14]. Outside of these frequencies are noise components. It can be seen that when the signal obtained from the model proposed in this study is compared to the signal passed through an external analog filter as a reference, its noisy components were filtered out. When the spectrum of the unfiltered raw MEMS accelerometer signal in Fig. 7 is examined, low frequency noise up to 5 Hz induced by body movements can be seen. Considering that the meaningful frequency range of these signals in the literature is from 5 Hz to 100 Hz [5], although high frequency components are not encountered after 100 Hz, accelerometer systems are still very sensitive to noises induced by body movements. For this reason, with the proposed approach in this study, micro-vibrations in the muscles can be detected automatically as far as possible, and these motion-induced noises can be eliminated. This is clearly seen from Fig. 7 when the frequency spectrum obtained from the proposed approach is compared with the spectra of the analog filtered reference signal and the unfiltered raw signal.
In this study, values of the noise parameters w k and v k of the filter can be adjusted automatically for filtering of the signals by using the EKF system. In order to evaluate the performance of the filter, LD algorithm is applied to signals obtained from the subjects and noise parameters corresponding to filtered signals and obtained by the system automatically are classified. The input parameters for classification are amplitude and frequency features representing a total of 60 filtered EMG and MEMS signals obtained from the subjects. These features are MNF, ZC, WL, SSC, AAC and DASD which have the highest correlation among 13 features determined through statistical regression analysis. Measurement noise value v k is used as output parameter. In the analyses in this study, 6 different v k values calculated by the system adaptively are used in filtering of 60 signals obtained from 20 subjects. These output v k values are respectively 0.008, 0.01, 0.02, 0.1, 1 and 2. For the analyses, the value of the process noise w k is determined by the system as 0.001 for EMG and 0.0001 for MEMS signals and these values are kept constant. For this reason, v k is set as the output parameter as it assumes different values for each subject during classification. During classification, different cross-validation (k-fold) values are used for LD algorithm. Table 2 shows the accuracy rates of classification with respect to different k-fold values. In addition, Fig. 8 displays the confusion matrices for LD algorithm by keeping cross-validation constant (k-fold:10).
When the confusion matrices in Fig. 8 are examined, it can be seen that the features MNF, ZC, WL, SSC, AAC, and DASD that represent the 60 signals from the subjects are classified by the LD algorithm with 100 % accuracy. Thus, the system can calculate the most suitable parameters for these features corresponding to each signal. In other words, the noise parameters corresponding to each signal are consistent parameters according to the classification results calculated in terms of current system performance.

Conclusion
In our study, the performance of the filtering in our proposed method is investigated by using LD with the features MNF, ZC, WL, SSC, AAC, and DASD that have the highest correlation determined by statistical regression analysis. The performance of the proposed model reaches 100 % accuracy. The signals obtained from the human body are complex nonlinear signals. For this reason, EKF filtering approach is used in this study. In this study, the signals received from skeletal muscles require extensive calibration. Therefore, another difference of the proposed method from the studies in the literature is that it is an adaptive filter. The parameters w k and v k of this EKF-based method are updated iteratively in a loop until the minimum MSE value is reached. This way, the system has an adaptive structure due to its adjusting w k and v k parameters automatically. In other words, the system can be adapted to different subjects and muscle groups under different conditions. Moreover, this method is useful for different sensor systems with biological signals that can be obtained from skeletal muscles. Therefore, the experiments in this study were not performed only for a single sensor system. By using two different sensor systems, both EMG and MEMS signals were obtained from the masseter and temporal muscles due to the continuous movement of the head and the jaw and the parafunctional movement ability of the lower jaw; this way, signals from rhythmic teeth grinding and teeth clenching movements could be filtered effectively. Thus, the proposed system is suitable for use in all kinds of skeletal muscles as well as robotic joint angle control, exoskeletal systems for rehabilitation, effective detection of tremors due to Parkinson's disease, diagnosis of fatigue and pain in muscles and diagnosis of bruxism based on lower jaw muscle activities with EMG and MEMS systems. Moreover, since there is no need for external hardware for analog bandpass, lowpass or highpass filtering, it has low cost and takes up little space.

Author Contributions
T.S. developed the theoretical formalism, performed the analytic calculations, and performed the numerical simulations. T.S. and S.K. authors contributed to the final version of the manuscript. S.K. supervised the project.