Algorithms for classification of a single channel EMG signal for human-computer interaction

One of the most accurate and effective ways to control gestures is to control muscle activity, which occurs with any movement. Electromyography (EMG) is used to record such activity. This article compares SVM classification algorithms, perceptron, random trees and the method of density of probability in relation to the EMG signal. Arduino Leonardo with a single-channel Shield EMG is used to record the signal. The aim of this paper is to prove the possibility of creating a cheap and accessible biointerface based on EMG signal.


Introduction
Since the beginning of the development of computer technology, the main interface of human-computer interaction has been dialog boxes controlled by keyboard and mouse. However, with the development of hardware and software, for example, with the advent of mobile phones, augmented reality helmets, IoT, more intelligent interaction interfaces were required, which can be classified as follows: (1) Voice control [1,2]; (2) Control gestures (with video cameras [3], special gloves [4] or special sensors, such as Kinect); (3) The brain-computer interface [5,6].
The use of these interfaces provides convenience in situations where there is no possibility or need to interact with external physical devices.
One of the most accurate and effective ways to control gestures is to control muscle activity, which occurs with any movement. Therefore, the use of signals of bioelectrical activity of muscles to control a device is an urgent task for today. Electromyography (EMG) is used to record this activity. In addition, the scope of EMG signals is very wide: they can be used in medicine to study muscle activity abnormalities; when evaluating the effectiveness of rehabilitation measures; for monitoring the human condition, etc.
When analyzing the bioelectrical activity of different muscles, one can understand which muscles were involved, and, therefore, with the best classification method, determine the movement that is made with their help.

Signal nature
After the arrival of a nerve impulse from the spinal cord to the terminal plate of the nerve attached to the muscle fiber, the post-synaptic membrane of the muscle fiber depolarizes. The depolarization is caused by the movement of Ca++ ions inside. The depolarization process extends to both sides of the end plate. The electrodes located in this field register the voltage (electrical potential) of the muscle fibers. The range of amplitudes of the electromyographic signal lies in the range of one microvolt to several tens of millivolts. The frequency of the signals varies from 0.5 Hz to several hundred hertz, but the individual components of the EMG spectrum can have a frequency of 10-20 kHz.

Electrodes
Electrodes for removing muscle biopotentials are subdivided into surface and needle. In this paper, the surface electrodes shown in Figure 1 are used. With the help of the surface electrode, only total muscle activity can be recorded, representing the interference of the action potentials of many hundreds and even thousands of fibers.
To record the action potentials of muscle fibers or their groups, needle electrodes inserted into the muscle are used. Such electrodes will make it possible to classify more qualitatively similar movements, but such electrodes cannot be used in everyday life, but only in the laboratory with the participation of medical specialists.

Equipment for EMG signal removal
In the research work for testing, the Arduino Leonardo microcontroller and the EMG shield from OLIMEX were required, the advantage of which is the general availability and cheapness of relatively expensive medical equipment. Figure 2 shows the Arduino microcontroller and the shielded EMG shield.

Classification of signals
In [7], four channels and the maximum likelihood method were used to classify eight gestures based on entropy probability densities. In this regard, it was decided to try to get the same result with only one channel and other hardware, but with the same method.
The location of the electrodes for one channel was chosen the same as the second channel in [7], since in this channel there is the most powerful useful signal. Figure 3 shows the location of the electrodes. There are three gestures shown in Figure 4. The signal recording lasted 5 seconds, of which 2 seconds -inactivity, then compression, and again inactivity. Figure 5 shows the recorded signals of each of the three gestures. The essence of this classification method lies in the search for entropies of signals for each gesture. Based on the entropies obtained, the probability density for each gesture is calculated where f is the probability density;   is dispersion. Consider an example: there are 60 experimental compression signals of the index finger, for each signal is calculated the entropy (1), resulting in a vector of 60 entropies. Further, based on these entropies the probability density (2) is calculated. This algorithm is applied to the rest of the gestures in the same order.
For training 45 measurements were taken for each gesture, and for testing 10 for each gesture and n = 220.
The result is the result of the probability densities shown in Figure 6 and the test result shown in Figure 7.  In total, the probability of an misclassification for this method is 4 misclassifications of 10 for the first movement, 2 for the second movement, and 6 for the third. The total probability of incorrect classification is 12/30 = 40%.

Discussions
This method showed a poor result on one channel, and it was not possible to obtain such a good result as in [5], it is possible for this method that the number of channels for removing the EMG signal is important, as well as the high accuracy of the equipment.
Consider other classification methods: SVM, perceptron, and random tree method. For each of these methods, the signs indicated in [8] are distinguished from the signal:  The algorithm for classifying three classes is the "one against all" method. Three classifiers are under construction.  In training perceptron, 6 errors occurred (perceptron parameters: three hidden layers of 50 neurons in the first, 20 in the second and 5 in the third layer).  Linear SVM was trained with one error (so that there was no retraining, SVM was allowed to err).  The trees were trained without errors (100 random trees were used).
The results on the test data is given in Table 1. You can try to improve the result by selecting only significant features from the signal; this can be done using feature_importances_ method in Python.
In LPC is stored not one feature but a vector of 10. In Figures 8-10 This set of features is tested on three classification methods. As a result, the probability of misclassification is shown in Table 2. The probability of misclassification 3.3% 3.3% 0% Having eliminated unnecessary signs, the probability of classification has improved, but it is necessary to allocate for each method its set of features. In the end, it is better to select the characteristics of the method and apply to other than not to provide the signs at all.

Conclusions
This study, using a single channel and cheap hardware, showed a good result on a test sample for three movements, thereby showing the ability to manufacture affordable, cheap and simple biointerfaces.
This simple and affordable hardware allows the expansion of the definition of the maximum number of well-classified gestures to increase the number of controlled impacts.