Event Detection of Muscle Activation Using an Electromyogram

: In this study, we proposed a precise onset and offset detection algorithm for muscle activation by using an electromyogram (EMG). The adaptive threshold was determined using the constant false alarm rate algorithm. The EMG signal was reﬁned by morphological hole ﬁlling, which is used to close up and ﬁll out missing information. By exploiting the EMG amplitude ratio in two channels, we signiﬁcantly improved the offset detection performance. The proposed method does not require a training process, unlike conventional methods. The experimental results indicated that the estimated errors for both the onset and offset detection are lower than those obtained using two of the conventional methods.


Introduction
Electromyography (EMG) is a method used to record electrical signals generated by muscular activities. EMG is related to muscle contraction and extension which can easily be recorded from the surface of the skin. Owing to these features, EMG is widely studied in various research fields, such as biomechanics, rehabilitation, and clinical diagnosis [1][2][3][4][5]. These applications require muscle activity information related to contraction or extension, and this information can be obtained by confirming the activation of EMG signals. Therefore, the muscle activity detection through EMG signal is a basic but crucial part of EMG applications [5,6].
The muscle activity detection aims to obtain both the onset and offset timing of EMG activity. The onset is defined as the beginning of a muscle contraction or extension, while the offset represents the end of a muscle contraction or extension. An easy technique to detect muscle activity is through visual inspection [7,8]. However the visual inspection by experts is accurate but complex. Thus, various methods for automatic onset and offset detection have been studied [9][10][11][12][13][14][15][16][17].
Most automatic detection methods are based on a threshold [9][10][11][12]. These methods detect the event timing by comparing the mean of EMG signals in a sliding window with a certain threshold. The onset detection using the generalized likelihood ratio test has been studied [9,10]. A single threshold is used for the onset detection only during a series of rapid upper limb movements [11]. Further, the onset detection based on Teager-Kaiser Energy method has been studied [12]. Bonato introduced a double threshold method where two thresholds were used to detect onsets of muscles from eight different locations under the waist [13]. Unlike the single threshold method, this method reduces the false alarm rate. Furthermore, other double threshold-based methods have been developed to increase the robustness to a noise level using EMG recorded from the upper and lower limbs [14][15][16][17]. In addition, Xu selected threshold based on the likelihood ratio test [10] where the optimal threshold was calculated via a likelihood ratio test. Rashid has attempted to achieve parameter optimization and then proposed an extended double threshold algorithm as a variant of the double threshold method [13]. However, these methods require optimization and an additional training process for parameter selection, thereby increasing the complexity of algorithm. Moreover, these conventional threshold-based algorithms are unable to accurately detect the offset timing.
In this study, we proposed a novel method used to detect the precise onset and offset timing of muscle activity, during hand-close and hand-open movements. The adaptive threshold was determined using the constant false alarm rate (CFAR) algorithm, and the EMG signal is refined by morphological hole filling that closes up and fills out the missing information. To evaluate the performance, we calculated the estimated error of the onset and offset timing. Furthermore, the results were compared with the two conventional methods based on the double thresholds. The experimental results indicate that the estimated errors for both onset and offset detection are lower than those occurring in the two conventional methods. In addition, the proposed method does not require a training process unlike conventional training-based methods. Figure 1a shows the self-made wrist-type wearable device, which is used to measure EMG data. This device is composed of a four-channel EMG sensor and connecter, six axis motion sensor module, battery, Bluetooth module, and micro controller unit. The EMG signals and motion sensor data can be recorded simultaneously with a sampling rate of 256 Hz. Bipolar Ag-AgCl snap electrodes were used, and two channels were located in the inner and outer part of the left forearm. A reference electrode was attached to the backside of the neck. Then, gyroscope sensor data were simultaneously recorded from the middle finger of a subject, for the evaluation of the proposed algorithm. The gyroscope is used to obtain the ground truth of the onset and offset timing. One female and nine male subjects were asked to repeat the finger folding sequence. They had to contract all their fingers and maintain this for a certain second (close state), extend all their fingers very quickly (open state), and subsequently relax all their fingers (resting state). The subjects were also instructed to maintain the close stage during two different time intervals, and each trial was repeated 60 times.

Proposed Algorithm
Let s[n] be the EMG signal and x[n] be the absolute value after the DC removal (i.e., x[n] = |s[n] − µ s |) where µ s is the mean of s[n] during the resting period. Evidently, the activation of the inner channel (x 1 [n]) is greater than that of the outer channel (x 2 [n]) during finger contraction (close state), and vice versa for finger extension (open state). The ideal onset and offset timings are the start and the end points of the close state, respectively. The mean absolute value (MAV) is the most common feature in EMG analysis owing to its computational simplicity and is calculated for every sliding window. The MAV for the channel c,x c [n] is obtained as and is illustrated in Figure 3.

CFAR-Based EMG Binarization
First, we detect the activation of the EMG signal by using the modified CFAR threshold. The CFAR is an algorithm, which sets a threshold to maintain a false alarm rate constantly. We use the median CFAR detector to calculate the decision threshold. Let } be the training cell, and letx c [n] be the test cell for the channel c, where L G and N represent the guard and the training cell length, respectively.
Subsequently, the CFAR threshold is calculated as Here, P f a denotes the false alarm rate and is set to 0.05. The CFAR threshold CFAR th c is modified by setting the upper limit to where M c represents the upper limit. The EMG signal is binarized using this threshold. When the EMG signal is activated, the state is mapped to 1, and when the EMG signal is inactivated, the state is mapped to 0, that is, Figure 4 illustrates the binarized EMG using the modified CFAR threshold. There is a notable existence of abnormal peaks and holes that disturb the detection of activation. Morphological hole filling is adopted to refine the binarized EMG, thereby removing these abnormal peaks and holes.

Refinement of the Binarized EMG
Morphological hole filling is a signal processing algorithm using for closing up and filling out the missing information. The algorithm consists of two steps: erosion and dilation.
The erosion step is calculated as Although the erosion step may remove abnormal peaks, it also enlarges holes. Therefore, dilation is applied to fill holes. The dilation is calculated as The start and end of the activation are detected from the channel dilation results, x Dc [n], and they are denoted by T c s and T c f , respectively. Figure 5 displays the EMG refinement results and shows that the peaks and holes disappear after the morphological hole filling. From T c s and T c f , we obtain T s1 and T f 1 by selecting the minimum and maximum values for each channel, that is, and

Onset and Offset Detection
Since they are both activated during the hand-close movement, the onset detection can be easily achieved using either x 1 [n] or x 2 [n]. However, the offset, which is the end time of the hand-close movement or the start time of the hand-open movement, is more difficult to detect than the onset. This is because EMG signals are sustained even after the completion of hand-close movements. Thus the offset detection becomes inaccurate [14,17]. This phenomenon can be observed in Figure 5. In the hand-close movement,x 1 [n] is clearly higher thanx 2 Then x p [n] is defined as where µ r [n] is the mean of rx[n]; that is, Further, is a standard deviation of rx[n] during resting period. Using x p [n], we calculate T s2 and T f 2 as T s2 = arg min n (x p [n] = 1) (12) and Figure 6 shows T s2 and T f 2 . Finally, by compensating for the delay occurred by sliding windows from T s2 , and T f 2 , the onset, T s , and the offset time,T f , are estimated asT andT Time (s) Amplitude Figure 6. Estimated onset and offset results.
Here, τ means the compensation value calculated as τ = N−1 2 f s . Figure 7 presents the onset and offset detection results of the two subjects. These results are compared with those obtained through conventional methods.

Experimental Results
We compared the results of the proposed algorithm with the novel double threshold method (nDTM) [14] and the extended double threshold algorithm (eDTA) [17] to evaluate the performance of the proposed algorithm. Both conventional algorithms are based on the original double threshold method [13], which is a simple but widely used method for muscle activity detection. In the experiments, we set β = 0.75, and τ = 78ms. Figure 7 verifies that the proposed algorithm is more accurate than the eDTA or nDTM. Figure 8 shows the effect of the P f a selection on the estimate error by varying from 0 to 0.5 for 10 subjects. Althouogh P f a higher than 0.3 results in the increased estimated error, P f a smaller than 0.2 results in the steady performace. To quantify the accuracy, we have computed the estimation error as where T k represents the ground truth of the onset or the offset andT k is estimated. The performance of the onset and the offset detection are separately evaluated. Figure 9 shows the results of subjects who show the best and the worst detection performance. For the onset detection, the proposed algorithm and eDTA reveal a similar estimate error, whereas nDTM exhibits a higher estimate error both in the best and the worst cases. It is noticeable that the offset detection result of the proposed algorithm is better than both of conventional methods.  The means and the standard deviations of the estimated error for the 10 subjects are listed in Table 1. For the onset detection, the proposed algorithm exhibits better or similar estimated errors compared to conventional methods for all the subjects. Regarding the offset detection, the proposed algorithm demonstrates the better performance than conventional methods. This indicates that the proposed algorithm can detect the onset and the offset of muscle activation more accurately than eDTA and nDTM.

Conclusions
In this study, we investigated a precise onset and offset detection algorithm for muscle activation by using two channel EMG signals. In controlling prosthetic devices or smart user interface, user's intended gestures or motions are usually predicted by EMG signals. The onset and offset timing as well as types of gestures are very important to control prosthetic devices or smart user interface accurately. Since inaccurate onset or offset detection may result in non-causal or delayed response, the accurate onset and offset detection are required.
We significantly enhanced the offset detection performance by exploiting the EMG amplitude ratio in two channels. The estimated onset and offset errors have been calculated separately for the performance evaluation. The results have been compared with those of two conventional methods, which are based on the double threshold method. For onset detection, the proposed algorithm is comparable to eDTA and nDTM, whereas for offset detection, the proposed algorithm exhibits a performance that surpasses that of conventional ones.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: