Classiﬁcation of Hand Movements Using MYO Armband on an Embedded Platform

: The study proposed the classiﬁcation and recognition of hand gestures using electromyography (EMG) signals for controlling the upper limb prosthesis. In this research, the EMG signals were measured through an embedded system by wearing a band of MYO gesture control. In order to observe the behavior of these change movements, the EMG data was acquired from 10 healthy subjects (ﬁve male and ﬁve females) performing four upper limb movements. After extracting EMG data from MYO, the supervised classiﬁcation approach was applied to recognize the different hand movements. The classiﬁcation was performed with a 5-fold cross-validation technique under the supervision of Quadratic discriminant analysis (QDA), support vector machine (SVM), random forest, gradient boosted, ensemble (bagged tree), and ensemble (subspace K-Nearest Neighbors) classiﬁer. The execution of these classiﬁers shows the overall accuracy of 83.9% in the case of ensemble (bagged tree) which is higher than other classiﬁers. Additionally, in this research an embedded system-based classiﬁcation approach of hand movement was used for designing an upper limb prosthesis. This approach is different than previous techniques as MYO is used with an external Bluetooth module and different libraries that make its movement and performance boundless. The results of this study also inferred the operations which were easy for hand recognition and can be used for developing a powerful, efﬁcient, and ﬂexible prosthetic design in the future.


Introduction
Electromyography (EMG) is a diagnostic approach that use motor neurons to control and evaluate the health of muscles and neuron cells. These motor neurons are responsible for transmitting electrical signals through muscles to contract them. A lot of applications of EMG testing exists in clinical and biomedical fields. It can either be used as a diagnostic tool to locate the neuromuscular diseases or to control the prosthetic hand movement. Medical research denotes that different parts of forearm muscles and EMG signals related to hands and fingers can still be measurable even after the loss of the hand. Detection, analysis, and classification of the EMG signal is a well-known topic these days in the biomedical industry, especially in the case of prosthetic hand movement. For detection of EMG data from muscles, various invasive and noninvasive techniques are available [1].
In [2], the author proposed a unique method that controls the prosthetic hand using EMG signals produced by forearm muscle when hand and finger movement occurs. For measuring the sequence of EMG potential in this technique, EMG sensors were used with the help of a Personal Computer sound card. Eleven miniature electromagnetic sensors were mounted in this novel 3D electromagnetic positioning system along with a dataglove [3]. These 11 electromagnetic sensors had the capacity to capture the corresponding hand poses in a real-time scenario [4][5][6]. To collect the motor unit action potential (MUAP) on the skin area, highly reliable and responsive surface electromyogram (sEMG) electrodes were used in [7]. In [8], the author used SEMG sensors to carry out the EMG data for six healthy subjects. Two types of muscle contraction (isometric and isotonic) and (anisometric and anisotonic) were considered taking EMG data for applied forces. The surface electrodes show the limited ways to assess the muscular activity. In the case of sEMG, a pair of electrodes or a complex array of multiple electrodes would be used to record the muscle data. As EMG recording exhibits the potential difference between the two electrodes, that is why we need more than one electrode to capture data [9]. Intramuscular EMG electrodes also play a vital role in acquiring EMG data through various recording techniques. The monopolar needle electrode is one of the simplest approaches of intramuscular EMG electrodes consisting of fine wire to penetrate a muscle with a surface electrode as a reference outside [10]. Two wire monopolar needle electrodes are also used to inject in muscle for data acquisition concerning each other. These monopolar EMG electrodes are insulated and stiff enough to insert in the skin with the tip exposed to reference using surface electrodes. Most commonly, these intramuscular electrode fine wire recordings are used for research or in studies of kinesiology [11]. The change in the upper limb movement shows the vital change in amplitude and features of the surface electromyographic (sEMG) signals [12].
A three dimensional (3D) printed prosthesis used for below elbow amputees is paired with an MYO armband to provide an affordable, practical, and convenient solution for amputees [13,14]. The study of feature extraction is carried out from the acquired EMG data for normal and amputee subjects in time domain and frequency domain [15,16]. The approach of classification of hand movements for healthy subjects and to predict the same for amputees is under discussion in our study rather to extract time domain and frequency domain features that is a quite different mode of study. In [17], the author used the MYO armband with interfacing a developed app of MYO Analyzer that supports the movement of MYO with its own Bluetooth module. While, we used a different library of MYO Bridge with compatibility of an external BLE (Bluetooth-Low-Energy) HM-10 (Jinan Huamao Technology Co., Ltd., Jinan, China) and different movements than installed gestures of MYO armband as used in previous approach. Moreover, they did not mention the subjects and data segmentation while we used two different gender groups with variety of ages, vast data set and movement classification. In [18], the author basically compares both approaches of acquiring data from MYO and conventional EMG data acquisition system for pattern recognition. For this purpose, he used the classification phenomenon. In comparison with proposed approach, our study is very different in terms of data acquisition technique for MYO, classification of EMG data for various hand movements and the novelty of the embedded system for our mechanical design of the prosthesis.
Although the previous approaches improve the cost of amputation, it is still very expensive, particularly for the patients of underdeveloped countries. Therefore, the novelty in this study is to give a noninvasive, feasible and cost-effective solution for people with amputations. The paper presents an advancement in the embedded based classification approach of hand movements which has application in various control applications, especially upper limb prostheses and robotics. Additionally, this work addresses the issue of latency and accuracy in such applications which are a bottleneck in many of the current biomedical device applications. The approach that is adopted in this study is comparatively feasible and cheaper as compared to previous approaches as it uses the noninvasive simple device of the MYO armband which can be wearable on any size of muscle without shuffling of wires, an embedded controller with low price and an HM-10 Bluetooth module for transmitting data. For further progress in the future, we can design a cost-efficient prosthetic upper limb to perform an action through this embedded system.

Background and Related Work
The electromyography (EMG) pattern recognition system acquired the EMG data from passive sensors, an innovative analog front-end system, and a power microcontroller to get different hand gestures. The data was acquired with the help of Cerebro AFE (Analog Front End IC for broadband communication) and fed into an MCU (microcontroller unit) [19]. In order to recognize the different hand gestures, the fed data was passed through the SVM classifier.
The author in [20] used the feature extraction methodology from the EMG data acquisition while we do not use the feature extraction methodology here. Our approach is just based on the classification of mentioned hand movements for the better performance of our mechanical design of prostheses. Moreover, this approach deals only with the features of amputees while we test the data of healthy subjects as well as to test for amputees. In [21], the author used a feature extraction-based methodology (time domain and frequency domain) that were extracted from raw EMG data to predict the behavior of hand gestures while we used the real time based raw EMG data classification of four movements without going into feature extraction methodology. Our one study of related feature extraction methodology was also published in ACM series publication with the name of "Comparative Analysis of EMG Signal Features in time domain and Frequencydomain using MYO Gesture Control". Finally, in [22] the author proposed the EMG data acquisition approaches with various set ups performing different gestures. The goal of their study to provide the best way of EMG data acquisition after classification phenomenon while in our case the stream of study is different as we want to develop an embedded system base classifier that predicts the future movement of an amputee with our undertaken mechanical design of prostheses.
For de-noising, classification and feature extraction, multiscale principle component analysis (MSPCA), a decision tree and discrete wavelet transform (DWT) was implemented, respectively, in [23,24]. This framework classified the EMG signal as taken by normal, myopathic and ALS (Amyotrophic lateral sclerosis) automatically with C4.5 algorithm, classification and regression tree (CART), and random forest decision tree classifiers. In [25], the author compared the classification performances of multilayer perception (MLP) and support vector machine (SVM). Surface electrodes obtained the EMG signals from the ulnar nerve of patients with DAQ (Data Acquisition) board and 16-bit A/D (Analog to Digital) converter which was stored in a computer's hard disk. The stored EMG data was then used for feature extraction using FFT (Fast Fourier Transform) and PCA (Principal Component Analysis). The PCA coefficients were applied to both MLP and SVM classifiers which show that SVM has a high rate of anticipation in diagnosing neuromuscular disorders.
To detect the wandering behavior of men/women through human recognition activity an approach of data mining was used in [26]. For this purpose, an MYO armband was used to capture the EMG data from muscles. The data obtained from volunteers then transferred to the computer wirelessly from MYO armband through a Bluetooth device. The MEX file of MATLAB (R2018b, Mathworks, Natick, MA, USA) was used to obtain data as MYO works in C/C++ but does not work in MATLAB. The 10-cross validation was used to recognize their motion activities using the frame of SVM, KNN, and naïve Bayes.
In [27], the author reveals the characteristics of different gestures via MYO armband and a gives a case study of an MYO armband that can use it to recognize gestures in map navigation with the help of Apple Maps Connector. In [28], the author proposed a comprehensive study for supervised classification of multichannel surface EMG signals. This representation shows the discrete wavelet transform (DWT) of EMG signals along with unconstrained parameterization of the mother wavelet [29][30][31][32][33][34]. The approach of support vector machine (SVM) is used to classify in a space of multichannel representation.
The results of this study show the discrimination of six hand gestures by getting a rate of 5% misclassification [35][36][37][38].

Proposed Methodology
The study in this paper involves the MYO armband with an embedded system to evaluate the EMG signals. For this approach, we interface our MYO armband to a controller board through an external HM-10 Bluetooth module. The proposed methodology block diagram is shown in Figure 1. The MYO armband is a manufactured product of Thalamic labs that can be used to detect the EMG signals of the forearm muscle. MYO contains eight EMG sensors to recognize the movement of arms and hand gestures. Besides these EMG sensors, MYO also has a nine-axis inertial measurement unit (IMU) to mark the hand movement. The IMU consists of a three-axis accelerometer, three-axis gyroscope, and three-axis magnetometers to account for the different movements. In our case, we used this device because it can be worn on any forearm due to its elasticity and wireless behavior. There were 13 features of time domain and frequency domain selected in this research. These features were analyzed linearly and nonlinearly with specific parameters. Additionally, these features and attributes were used for classification of four-class hand gestures.
The time domain features consist of Likewise, the frequency domain features carry the attributes of • mean frequency, • median frequency, • power bandwidth, • total harmonic distortion (THD), • signal to noise ratio (SNR), • power spectral density (PSD) of signal.

Interfacing MYO with Arduino
A different embedded system can be utilized to interface the MYO armband, but in proposed approach, the Arduino UNO controller board is used to interface the MYO armband.
To access the raw EMG data, we used an external HM-10/CC2541 BLE Bluetooth module that must be flashed out with MyoBridge firmware before communicating to MYO as shown in Figure 2a. In order to make Arduino enabled for use with MYO, we used the library of MyoBridge that includes the EMG, IMU, and hand pose functions. The EMG data transfer rate is at 200 Hz while for IMU it comes out at 50 Hz. That is why in our dataset we obatined four times more EMG data than IMU data as shown in Figure 2b. In this experiment, we selected five healthy male and five female subjects of different age groups (25-55 yr) to perform four hand movement gestures such as stationary, doubletap, single finger movement, and finger spread. These four gestures were further used to classify the different hand movements for both males and females separately. The EMG graph of the 8-channel MYO armband for different hand movements of males is shown in Figure 3. The muscle tissues are normally inactive at rest as shown in Figure 3a. Whenever the muscle gets contracted voluntarily, the action potentials start to occur. Muscle fiber produces more and more action potential with the relatively increased strength of muscle contraction. That is why in Figure 3b,c the different orders of action potentials with increasing rates and amplitudes can be seen. Peaks with varying amplitude in Figure 3b show the motion of double tap with each double tap movement. Similarly, in the case of single finger movement as mentioned in Figure 3c, the normal contraction of muscle with orderly action potentials and smaller amplitude. When the muscle is fully contracted as in the case of finger spread, a group of action potentials from several motor units appear disorderly with higher rates and amplitudes as shown in Figure 3d. The same muscle activation for various hand movements can be seen in the female test group as well where stretching of tissues and peaks of action potentials shows the saturation in finger spread and single finger movement as shown in Figure 4.

Classification and Recognition of Hand Gesture
In this section, the classification approaches used for EMG signal classification are described. This system aims to classify the various hand movements with high accuracy rate. Figure 5 shows the study of four gesture EMG data plus stationary, double tap, single finger movement, and the finger spread. For this purpose, seven classifiers were used to classify our hand movements based on classification tools of WEKA, rapid minor and classify learners in MATLAB (R2018b).

Quadratic Discriminant Analysis (QDA)
Quadratic Discriminant Analysis (QDA) can be used for classifying or distinguishing the dimensions of two or more classes of objects within a surface quadrature. Quadratic Discriminant Analysis (QDA) is a very closely linked group of linear discriminant analysis (LDA), where it has been noticed that the dimensions from each class are normally dispersed. Though, in contrast to LDA, QDA has no postulation in which covariance of each of the classes is identical. When the normality postulation is true, the best conceivable test for the hypothesis that a given measurement is from a given class is the likelihood ratio test. As we mentioned that QDA is not very dissimilar from LDA except that you assume that the covariance matrix can be diverse for each class, therefore, we will estimate the covariance matrix Σ k separately for each class k as k = 1, 2, . . . , K.   Quadratic discriminant function [12]: In Figure 6 the discriminant function is basically a second order classifier. The pattern of classification is parallel as well. You just bargain the class k which capitalizes on the quadratic discriminant function. The decision boundaries are quadratic equations in x. Classification rule: QDA has significantly more parameters than LDA because it has more litheness for the covariance matrix as it inclines to fit the data better than LDA. Therefore, for QDA assessment, you would have a discrete matrix of covariance for each class. If you have numerous classes and not enough sample points for it, then it will be problematic.

SVM Classifier
The support vector machine is basically a supervised learning model with specific learning algorithms used to compute the data for classification. In contrast with linear classification, SVM can also be used for nonlinear classification using the feature of kernel trick as shown in Figure 7.
A binary classifier is a function f: X → Y which nominates every point as x ∈ X with some y ∈ Y. Both linear SVM and quadratic SVM are based on kernel version classifiers.
where w > x + b = 0 and c (w > x + b) = 0 define the same plane [15]. We can choose the normalization of w for both cases as positive and negative support vectors. Choose normalization such that: Margin is given as: The learning algorithm of SVM can be formulated as:

Ensemble (Bagged Tree)
An ensemble classification method is a supervised learning approach that synthesizes the multiple predictions of various machine learning algorithms together in order to get the better prediction than a single algorithm. Bagging or bootstrap aggregation can be used to train data for prediction and to reduce the variance of high variance algorithms like classification and regression tree (CART). Decision trees are very sympathetic and acute towards trainee data. If any changes occur in training data, then it also affects the resulting decision trees which in turn change the results of prediction. In the case of bagged decision trees, we are less apprehensive toward the single tree overfitting the trainee data. For efficiency and higher accuracy, the single decision trees should grow deep with each leaf-node containing a few trainee samples as shown in Figure 8.
For classification or regression of data we have The function estimator which in turn is the result of the base procedure is given as: g (·) = hn ((X1,Y1), . . . , (Xn,Yn))(·): IRd → IR, The variables for the bagged trees algorithm only include the number of samples and the number of trees to count. Models that have large data take time for training, but it will not follow the overfitting in training data.

Gradient Boosted (Tree)
Gradient boosted is a method that also exists to perform the different supervised machine learning tasks i.e., classification and regression just like the random forests (RF) method. The implementation of this technique is very easy and recalled as with different names. The most common name is gradient boosting machines (GBM) and XGBoost. It is an ensemble learner the same as RF that creates an end model based on the collection of individual models. It has very weak power as an individual model but when these individual models (weak power) combine as a group, it provides a better-quality result. A commonly used type of weak model in GBM is a decision tree as shown in Figure 9.
In boosting, individual models i.e., weak learners are not just built by random subsets of data and features except that it also puts some more weight in the form of incorrect predictions and highly faulty data for the better training. In this way, these models learn in a better way from previous errors/mistakes. This type of boosting is upgraded with a name called stochastic gradient boosting (SGB) in which each ensemble trains with a subset of data. This provides the most generalized and improved model for results.
Minimization of the loss function is done with gradient, in which neural networks are trained by using gradient descent for optimization of the weights. For the training of this model, the weak learners are built, and their predictions are compared with the correctly obtained results. Error rate of this model is defined as the distance between prediction value and its true (correct) value. Therefore, these errors find the gradient. It is simply a derivative of the given loss function. It also provides a direction in which errors of the model can be reduced by "descending the gradient" for the next step of training.
In this case a gradient descent is implemented in order to calculate the learning rate (descending the step size of the gradient), shrinkage (decreasing the learning rate) and loss function used as hyperparameters in GBM. Algorithm: In many supervised learning problems, there is an output variable y and a vector of input variables x described through a joint probability distribution P (x, y). Using a training set {(x1, y1), . . . , (xn, yn)} of known values of x and corresponding values of y, the goal is to find an approximation of a function F (x) that minimizes the expected value of some specified loss functions L (y, F (x)) [20].

Random Forest
Random forest is the improved version of bagged decision trees. The combined effect of multiple predictions from various models can give a better prediction rate from the uncorrelated sub models or weakly correlated models of prediction. In the decision trees algorithm, a problem arises especially in CART that they are greedy algorithms, so they pick a variable to split through the greedy algorithm to minimize the error. There are a lot of similarities in pattern and design configuration for decision trees in case of a bagged tree and they have a high correlation in their prediction level. While in the case of the random forest shown in Figure 10, they changed the algorithms as sub-trees learned in their training process, so their resulting predictions have less correlation among these sub-tresses. The algorithm used for training in the case of random forest applies the same approach as used by bagging or bootstrap aggregation trees to learn. If the data set is given as: X = x1, . . . , xn with responses Y = y1, . . . , yn, bagging to select a random sample of trainee data and try to fit trees to these samples: For b = 1, . . . , B: Where sample with replacement, B training examples from X, Y represent as Xb, Yb and train a decision or regression tree fb on Xb, Yb. Then, after training, predictions of unseen data can be achieved by computing the prediction average of individual trees on x'.

Ensemble Subspace KNN
The random subspace method works based on stochastic process. It picks various components randomly from the characteristic vector during the construction of each classifier as shown in Figure 11. For the nearest neighbor classifiers (KNN), a sample test is compared with a prototype, that provides the selected characteristics only that have contribution other than zero to the distance. From a geometric point of view, this is equivalent to projecting all points in the selected subspace and the closest neighbors k are calculated by the projected distances. A new set of k closest neighbors is calculated by selecting a random subspace every time. Nearest neighbors k in every selected subspace meet for a majority vote in the membership class test sample. If closest neighbor k is selected more times, this obtained the same training samples that appear more times in the set than once.  k 1), the test point is assigned to the class that has the most frequent incidences in list C.

Results and Discussion
In this research, the behavior of four hand gestures including the stationary, double tap, single finger movement and finger spread were observed to understand attributes and features of hand movements for male and female subjects using a number of classifiers. Different classification approaches named as LDA, QDA, SVM, NN, ensemble (bagged tree), random forest, gradient boosted, and subspace KNN were adopted in our case to utilize and classify the hand movements.
In the experimental procedure, a total of four gestures were performed per trial of different subjects of different age groups (25-55 yr). The two groups were classified as male and female. For the male group, each subject performed all four gestures in a sequence of stationary, double tap, single finger movement and finger spread. Performing window of each gesture was selected of 1 min duration. Therefore, the proposed MYO based embedded system took data of 4 min for completion of each set of movements for a single subject. The same procedure was followed for extracting data in the case of the female group.
To employ the classification approach, we used the 5-fold cross-validation technique in our model of classify learner with four classes of EMG data. In the case of WEKA, 10-fold cross-validation approaches are used to classify our EMG data as shown in Figure 12. The scatter plot of four classes of EMG signals in classify learner is shown in Figures 13 and 14 where we can see the scatter plot of EMG data among each channel of MYO (as column 1 = channel 1, column 2 = channel 2, and so on) for both cases of male and female (As VarName 3 = channel 1, VarName 4 = channel 2, and so on). In our model of classify learner, we defined a response variable to classify the predictive behavior of four classes of EMG signal. For this reason, we marked our four-class hand gestures as 0 for stationary, 1 for double tap, 2 for movement of single finger and 3 for finger spread as response variable as shown in Table 1.    Single finger movement 2 4 Finger spread 3 The results of this experiment show a high rate of accuracy with F-measure, MCC, and ROC. As from the results, we concluded that the ensemble bagged tree shows a higher rate of accuracy for both male and female subjects among the listed classifiers with 83.9% and 78.4%, respectively, as given in Tables 2 and 3.  The dominance of different colors shows the action potential of muscles during each movement. For example, Figure 13 shows the maximum dominance of purple color which means that muscle concentration maximizes with finger spread as compared to other gesture movements.
The confusion matrix and ROC curve for both cases (male and female) are shown in Figure 15. The recognition rate of various hand movements after classification gives 92% for stationary, 68% for double tap, 83% for single finger movement and 82% for finger spread gesture in male movement as shown in Figure 15a. While in the case of random forest for males, it gives the recognition accuracy for each gesture as 91% for stationary, 67% for double tap, 83% for movement of single finger and 82% for finger spread as given in Table 4.  The recognition rate of hand movements in the female test case after classification gives up to 83% for stationary, 69% for double tap, 73% for single finger movement and 61% for finger spread gesture as shown in Figure 15b.
The region of convergence (ROC) curve was used to find the quality and accuracy of the running classifier. The marker on the plot exhibits the performance of the classifier as it shows the true positive rate (TPR) and false positive rate (FPR) of the running classifier as shown in the Figures 16 and 17. For example, if it states the behavior of false positive rate (FPR) as 0.25 then it means that the classifier picks the 25% incorrect observations for the positive class. In turn, if the true positive rate (TPR) signifies the behavior of classifier as 0.75 then actually it shows that the classifier picks 75% correct observations for the positive class.

Comparative Analysis
In the field of biomedical engineering, various design techniques and approaches have been used to develop efficient and cost-effective solutions for handicaps. For this purpose, some developers use invasive electrodes on muscles to acquire EMG data and some give preference to noninvasive design techniques through a controller or DAQ board. MYO armband is the latest approach and has become very widely used in a number of studies. As it is mentioned above in the literature that although previous design techniques improve the results of accuracy and reduce the cost of prosthetic design, it still requires some improvement in the cost of design.
The detailed comparison of different approaches with our proposed approach is given below in Table 5. As compared to previous approaches, we gave an idea of the MYO armband as a motion device for various upper limb movements through an embedded system and an external Bluetooth module with a good performance classifier. The overall system developed in the proposed case is relatively cheaper, noninvasive and gives good performance too compared to other costly systems with a high rate of accuracies. Moreover, the previous approaches used the surface EMG electrodes and sensors to capture data for upper limbs which comprises many obstructions such as motion artifacts, electromagnetic resonance of wires, signal to noise ratio and the most prominent of them is an invasive approach that quite painful for subjects. We classified the four basic and general hand movements to study the liability of our system. The results of this study show comparatively good performance in detecting four hand movements with an accuracy of more than 80-92%. Moreover, this study can be used in the future to develop a cheap prosthetic design for an amputee.

Conclusions and Future Work
The aim of this research paper was to classify and recognize the hand movements for various upper limb movements. For this purpose, a novel method was proposed to acquire the EMG signals from forearm muscle with the MYO gesture control system on an embedded platform through a Bluetooth module. For getting different hand gestures, a total of 10 healthy subjects (five males and five females) participated in this research work. After acquiring EMG data from these participants, five-fold cross-validation approaches were used to classify these hand movements. The results based on classification using ensemble (bagged tree) gave a high rate of accuracy among other classifiers with a better recognition rate for various hand movements.
The results of this study can also be used in the future to develop an efficient, costeffective and flexible assistive device or prosthesis. This work will also be extended to more or other gesture classification, as per need, based on same framework.