Design a 1D-CNN'S to classify surface EMG (SEMG) signals Diseño de un 1D-CNN para clasificar señales EMG de superficie (SEMG)

Amputate forearm, finger, or hand is a biggest problem for the disabled subject. Therefore, Prosthetic does a significant role for the amputees to modify the capability and mobility of their systematic activities. Using the EMG signals of hand and finger motion discrimination are continuously growth for numerous hand and finger gestures. The main problem in designing a prosthetic hand is the classification of EMG signals. Machine learning (ML) algorithms present a solution to this problem by providing a way to classify EMG signals with simply and less costly scheme. This study presents more than one experiment on two datasets in order to classify individual fingers (IF) with wrist and victory based on a normative dataset of EMG signals and Deep Learning DL. These experiments show that the overall performance (average accuracy) of the proposed method is 98.83% and the overall error classification rate (error rate) is 1.17%.


INTRODUCTION
The human disability represented by losing one of the limbs is a biggest problem to the restoration of the disabled subject, especially when the forearm, finger, or hand is amputated (Andrews et al., 2008).Gesture recognition built on electromyographic (EMG) signals is a favorable method for the development of Human-Machine Interfaces (HMIs) with standard control, such as intuitive robot interfaces.The biggest job in designing a prosthetic hand is the classification of EMG signals made by neurons of the arm to distinguish different hand actions.These EMG signals vary in strength from one to one and from movement to movement (Bhatti, 2019).The using of EMG signals of hand and finger motion discrimination are continuously progressing.Though, little studies have interested on the on individual finger (IF) with wrist and victory gestures, which are considered more interesting than whole other gestures (wrist and whole-hand gestures) to classify because of the complexity of the muscles which responsible for IF movements.Most models of finger gesture classification use a large number of channels to measure the EMG signals, which means that the system (model) is complex, and its cost is high.As a result, classifying wrist and hand movements had been interested in the numerous previous studies.As a result of the current advances in computing world, especially, machine learning (ML) algorithms have reduced the number of channels to classify the IF gestures without losing the accuracy of classification and the response time (Lee et al., 2021).In current years, DL methods have been effectively applied to a wide range of IF movements recognition (Tsinganos et al., 2018).As a result, new studies in biomedical engineering are focused on towards the application of these methods to EMG-based IF gesture recognition.

Literature Review
Many studies and researches have been made in the field of sEMG signals classification and processing for individual fingers movements due to its non-invasive nature and availability.P. Tsinganos et al., presented a brief overview of Deep Learning methods along with an analysis of a modified simple model based on CNN's for EMG-based hand gesture recognition.3% improvement yields on the classification accuracy of the basic model of the proposed network, whereas the analysis helps in exploring new ways to improve performance and understanding the limitations of the presented model (Tsinganos et al., 2018).While (Atzori et al., 2016), a simple CNN architecture based on 5 blocks of convolutional and pooling layers is used to classify a large number of gestures.The classification accuracy is comparable to those obtained with classical methods, but the classification accuracy is relatively low than the best performance achieved on the same problem using an RF classifier.Stephenson et al., the Myo armband is used as an image input into a CNN to indicate how neural networks have been useful to sEMG signal classification i.e.Long Short Term Memory (LSTM) and convolutional neural networks (CNN) networks.The achieved classification on five finger flexion actions in addition to seven gestures which included four combinations of flexion movements involving the thumb and one of the other fingers i.e. index (Stephenson et al., 2018).(Xing et al., 2018) a CNN model is proposed with five parallel convolution layers to remove the disadvantage of conventional classification methods, which is losing valuable information during feature extraction, and rise EMG-based hand gesture accuracy.For this, data from the NinaPro database was used which has EMG data relative to 53 hand movements for 78 subjects divided into three datasets.They exposed that the classification accuracy of the CNN-based method was 83.23% with preprocessing.(Chen et al., 2020) presented CNN's structure for reducing the deep learning hyper parameters and increasing classification accuracy.The CNN model had four convolutional layers and one max pooling layer.MYO armband sensor is used to measure seven hand gestures.As a result, the proposed training CNN model improves the classification accuracy of hand gestures recognition.(Guo et al., 2020), presented Lw-CNN and SVM to classify six various upper-limb movements of eight subjects as a controlled robotic arm in online.Lw-CNN classification is better than SVM in online experiments.Both classifiers have better accuracy offline than online.88.75% is the average accuracy of the presented study.(Akmal et al., 2021) Support vector machine (SVM) is applied to classify the finger movements at real-time.The proposed classifier achieved mean classification accuracy equal to 78%.The main contribution of this study can be summarized in three points is designing a 1D-CNN layers to classify individual finger movements.

FEATURE EXTRACTION
Features extraction refers to raw signal data transformation into feature maps by eliminating noise, extracting the important data (Chang et al., 2022), and applying it as inputs to the classification system (Kundu & Naidu, 2021).So, Features extraction is a significant procedure for classifying systems by extracting useful information hidden in the raw signals, which should contain as much information as possible to gesture classification.Features extraction includes taking a short time windows of the EMG signal to obtain a more informative measure.This feature extraction should be completed to recognize the command signal (Choi, 2023).In general, time TD, or frequency FD or time-frequency domain TFD is adopted to extract the features.Because of TD is fast, easy to implement, representing the transient state of gestures (Lee et al., 2021) and short enough response time which is suitable in real-time recognition (Caceres, 2014).Therefore, TD features is adopted for IF recognition.For this study, the following seven features are used:

Max
Max is the maximum amplitude value of the input signal that used in non-stationary signal (Caceres, 2014).

Min
Min is the minimum amplitude (McIntosh et al., 2016).

Standard deviation (SD)
SD represents the difference between each signal sample and its mean value (Too et al., 2017).
(2.1) SD represents noise and other interference.It is used in comparison to the mean (Too et al., 2017).

RMS
RMS is a root mean square of the signal (Venugopal & Ramakrishnan, 2014).It can be expressed as: MAV is the total average of the absolute value of the signal (Venugopal & Ramakrishnan, 2014).It can be expressed mathematically, as: (2.3) 2.6.AAC AAC is the average amplitude change of the waveform (Chang et al., 2022), the mathematical expression is: (2.4)

Amplitude First Burst (AFB)
To calculate AFB, the signal is squared.The first maximum point of the resultant signal is used as the feature (BAKIRCIOĞLU & Özkurt, 2020).

CONVOLUTION NEURAL NETWORKS (CNN)
CNN is a deep learning multi-layers artificial neural network that is often used in large data sets.CNN structure consists of a set of layers that can extract numerous features of input data (e.g.image).Higher level features are extracted in the initial layers.While the lowest level is extracted in the deeper layers.The basic structure of CNN is shown in figure 2.7 (Sadhu, 2019).Basically, in CNN's structure, the standard neural network is used in the classification process, while a set of layers different from the conventional neural networks known as hidden layers are used to extract the signal features (Gadekallu et al., 2021).Feature extraction is done by specifying or choosing the size filter in each convolution layer.Depending upon application, CNN's have multiple hidden layers for convoluting the input with the filter.The nonconvolution is other layers in CNN's (Bhatti, 2019).CNNs convolute the input data with filter(s) to extract features from them.The convolution and non-convolution layers are shown in figure 2.

Pooling layer
Pooling-layer decreases the spatial dimensionality of the input matrix.The pooling is classified into average and max pooling layer.Max pool layer deals with peak value of each submatrix in features map.The average pool layer takes average value of each submatrix in feature map (Kiranyaz et al., 2021).

Fully connected FC-layer
After pooling layer, feed-forward ANN procedures are done using the fully-connected (FC) layer as classifier layer (Amado Laezza, 2018).It is a conventional neural network.
As mentioned above, the last pooling or convolutional layer in the form of flattened vector is the input to FC layer.So, the FC layer output refers to type class for input signal (Ghosh et al., 2020).The smaller datasets lead to CNN overfitting.To solve the overfitting problem, Dropout and Batch normalization layers are added to overcome this problem in CNN's.To modify CNN's, numerous aspects are adopted such as activation, loss and optimization functions (Alzubaidi et al., 2021).

ACTIVATION FUNCTIONS
Activation functions are computational functions that are used to activate NN performance.It executes complex calculations in the hidden layers and sends them to the output layer.The activation functions generate nonlinear features in hidden layers.The activation functions can activate or deactivate each neuron in the hidden layer.Thus, the output of each neuron is within range 1to 0 or -1 to +1.The types of the activation functions, are Sigmoid, Tanh, ReLU, Leaky ReLU, Parametric ReLU, Softmax and Swish activation function (Kiranyaz et al., 2021).

Sigmoid Function (Sigm)
It receives real numbers, their output range between zero and one.Its mathematical expression is: (1) Figure 3, shows sigmoid function.ReLU is favored for CNN's because of unlike sigmoid and tanh activation functions, ReLU always has a constant derivative which is very small in the saturation region while tanh and sigmoid don't (Bhatti, 2019).

EVALUATION METHODS
Several evaluation techniques are used in ML to evaluate the performance of the classification patterns like confusion matrix.

Confusion Matrix
The confusion matrix examines the performance of a classification pattern based ML, see (Figure 7).Also, Figure 8 shows a confusion matrix of multi classes.It is the summary of the performance prediction and also known as the error matrix (Karimi, 2021).It shows many correct and incorrect predictions per class to understand the confused class by the model as other class.The confusion matrix rows denote to the predicted values while the columns denote to the actual values.There are four possiblities:  True Positive TP cell means that the actual and the predicted value are positive.
 True Negative TN cell means that the actual value is positive while the predicted value is negative.
 False Positive FP cell means that the actual value is negative while the predicted value is positive.
 False Negative FN cell means that the predicted and actual value are negative (Kulkarni & Batarseh, 2021).

MATERIALS and METHODS
The main support of this study is an investigation into accurately discriminating among individual finger, wrist and victory movements using EMG signals.
Deep learning is adopted for classifying EMG signals to predict individual finger flexions.This system tries to make machine mimic human movements via EMG signals.

PROPOSED METHOD
The proposed method consists of two stages; feature extraction and classification (CNN) stages.Figure 9 illustrates the proposed method architecture.
The first stage uses MAV, RMS, MIN, MAX, AAC, SD and AFB feature extraction methods that are applied to each window with a length equal to 150 msec of the original signal.The selected features are fed to the CNN model as an input for classifying targeted movements.

THE OFFLINE EXPERIMENTS
In this thesis, a deep learning model was proposed to automate the process of feature extraction, selection, and reduction, in addition to the pattern recognition and classification of selected signals.
As mentioned above, 8-layer convolutional neural networks are used.The figure 11 shows the essential structure of the proposed CNN layers.Numerous experiments are processed offline.In the first experiment, the filter size is fixed at a value of 4, the window size of the max pooling layer is 2*2, the dropout layers1 and 2 at 0.1 and the patch size is 30.
The activation function of the dense1 layer is ReLU and the activation function of the dense2 layer is Softmax.To find the suitable number of nodes, it is changed from 220 to 160 nodes and the experiment results are in table 3. From the results of experiment one the best result is at the number of nodes equal to 180.The second experiment adopted the best result (at 180 nodes) and by fixing all previous parameter and changing the filter size.The experiment results are in table 4. From the results of experiment two the best result is at the filter size equal to 4. The third experiment adopted the best result (at 180 nodes) and filter size equal to 4 and by fixing all other previous parameter and changing the window size of the maxpooling layer.The experiment results are in table 5. From the results of the experiment three, the best result is at the window size equals to 2. The fourth experiment adopted the best result (at 180 nodes, filter size 4 and maxpooling dimensions are 2*2) and by fixing all other previous parameter and changing the rate of dropout2 layer.The experiment results are in table 6.From the results of experiment four, the best rate equals to 0.1.The fifth experiment adopted the best result (at 180 nodes, filter size 4, maxpooling dimensions are 2*2 and rate of dropout is 0.1) and by fixing rest previous parameter and changing the patch size.The experiment results are in table 7. From the results of the experiment five the best patch size equals to 30.The sixth experiment adopted the best result (at 180 nodes, filter size 4 and maxpooling dimensions are 2*2, rate of dropout is 0.1and the patch size is 30) and by changing the activation functions of dense1 and dense2 layers, the experiment results are in table 8.

OFFLINE EXPERIMENT RESULTS
In this section, the setting of CNN parameters will be explained through implementing various experiments.Offline experiment trains the proposed method with parameters (filter size, activation functions, optimizer type, etc.).The performance results are divided into two types: training and testing.

The training performance results
In CNN training, the recognizing of the flexion movements for wrist and each finger except thumb and victory movements is 100%.While, the recognizing of the thumb flexion and victory movements are 75% and 98%, respectively.It is clear that the confusion of each movement except thumb and victory is 0%, while the confusion of the thumb flexion and victory movements are 25% and 2%, respectively, as shown in the table 10.

The testing performance results
In the CNN testing, at 40 epoch the recognizing of the flexion movements for wrist and each finger except thumb and victory movements is 100%.While, the recognizing of the thumb flexion and victory movements are 73.5% and 98%, respectively.It is clear that the confusion of each movement except thumb and victory is 0%, while the confusion of the thumb flexion and victory movements are 26.5% and 2%, respectively, as shown at table 12.It is clear that the thumb training and testing give the worst result.

CONCLUSIONS
A CNN-based classification algorithm is proposed for five finger, wrist and victory gestures.The proposed method needs several experiments to tune the CNN layers parameter.This study presents more than one experiment on the selected Kaggle datasets in order to implement a human-computer interface based on EMG signal and DL.One of these datasets is a benchmark dataset.These experiments show that the overall performance (average accuracy) of the proposed method according to Table 9 is 98.83% and the overall average misclassification (error rate) is 1.17%.The overall sensitivity is 95.918%.the overall precision is 98.92% and overall F1-score is 97.105%.
Based on the obtained results and a number of experiments that were achieved in this study, the parameters of the CNN affects the performance of the proposed method so several experiments have been performed to find the proper parameter (such as filter size, pooling method, etc) that provide the best classification of the EMG signal.The model is able to learn the features and pattern of sEMG signals with relatively high accuracy when applied in both offline and online modes.The parameters found in the offline experiments based on the benchmark dataset have good performance.Likewise, the system can be used by any person, whether disabled or healthy, and it can also be used in the Internet of Things to control a specific system It is concluded that the model is able to learn the features and patterns of sEMG signals with relatively high accuracy when tested.So, according to this study, the CNN is suitable to increase the success of the classification of the daily used finger/hand movements.

Figure 7 .
Figure 7. Confusion matrix for two classes.

Figure 8 .F1
Figure 8. Confusion matrix for multi class.

Figure 9 .
Figure 9. Block diagram of the proposed method.This model is trained in Python and ran it in a windows-based fourth generation, core i7 PC with 1.8 GHz CPU and 8 GB memory.Offline Dataset This dataset is downloaded from Kaggle site which is one of the datasets provided by Google.It contains signals of seven movements (the victory, beside wrist and five individual finger flexions) of eight subjects as in figure 10.

Figure 10 .
Figure 10.Studied movements for classification.The information about this dataset illustrated in table 4.1.The 448 dataset divided into two subsets, i.e. training and testing data.The training subset contains 399 sample of each movement and the rest (49) data are used in the testing subsets for eight subjects.

Figure 11 .
Figure 11.The proposed model block diagram.

Figure 14 .
Figure 14., shows that the loss and accuracy curves during training and validation on exercise Dataset.The Loss becomes very low, while the accuracy becomes high at 40 epochs.

Figure 14 .
Figure 14.The loss and accuracy curves in offline.

Table 1 .
The offline dataset.

Table 2
The binary class code.

Table 3 .
First experiment results.

Table 4
Second experiment results.

Table 6
Fourth experiment results.

Table 7
Fifth experiment results.

Table 8 .
The sixth experiment results.From the results of the experiment six the best choice for the activation functions are in the third row of the table 8..According to the previous experiments (experiment1 to experiment 6), the best structure of CNN's is specified in table 9.

Table 9 .
The best proposed model.

Table 10 .
Confusion matrix of classifying the studied movements during offline training.The results of the performance evaluation of the classification offline training shown in table 11, besides, figures 11 and 13 respectively.It is noticed, that the minimum accuracy and precision of classification at wrist flexion.While, the thumb flexion gives minimum sensitivity of classification.The minimum F1-score is done at the victory gesture.The maximum misclassification results at wrist and thumb movements, while the rest of the studied movements the classification is 100%.

Table 11 .
Performance evaluation of offline training.

Table 12 .
Confusion matrix of classifying the studied movements during offline testing.The results of the performance evaluation of the classification offline testing shown in table 13 besides, figures 15 and 16 respectively.It is noticed, that the minimum accuracy of classification at wrist and thumb flexion.Wrist flexion gives minimum precision.While, the thumb flexion gives minimum sensitivity of classification.The minimum F1-score is done at thumb flexion movement.The maximum misclassification results at wrist and thumb movements, while the classification of the rest of the studied movements is 100%.

Table 13 .
Performance evaluation of the classification offline testing.