Abstract
Motor imagery (MI) signals recorded by electroencephalography provide the most practical basis for conceiving brain-computer interfaces (BCI). These interfaces offer a high degree of freedom. This helps people with motor disabilities communicate with the device by tackling a sequence of motor imagery tasks. However, the extracting user-specific features and increasing the accuracy of the classifier remain as difficult tasks in MI-based BCI. In this work, we propose a new method using artificial neural network (ANN) enhancing the performance of the motor imagery classification. Feature extraction techniques, like time domain parameters, band power features, signal power features, and wavelet packet decomposition (WPD), are studied and compared. Four classification algorithms are implemented which are Quadratic Discriminant Analysis, k-Nearest Neighbors, Linear Discriminant Analysis, and proposed ANN architecture. We added Batch Normalization layers to the proposed ANN architecture to improve the learning time and accuracy of the neural network. These layers also alleviate the effect of weight initialization and the addition of a regularization effect on the network. Our proposed method using ANN architecture achieves 0.5545 of kappa and 58.42% of accuracy on the BCI Competition IV-2a dataset. Our results show that the modified ANN method, with frequency and spatial features extracted by WPD and Common Spatial Pattern, respectively, offers a better classification compared to other current methods.
Keywords
Introduction
Brain-computer interfaces (BCIs)1-3 are systems that provide a mode of communication between the human brain and external devices. 4 However, BCI acquires signals from the brain, analyzes them and translates them into commands that are relayed to actuating devices to perform the desired actions. Noninvasive scalp electroencephalography (EEG) 1 is an easy and inexpensive technique for recording brain activity. The EEG signal is recorded by using several electrodes placed on specific areas of the scalp. EEG signals possess the quality of high temporal resolution of the order of a millisecond, which is not yet possible with the latest imaging techniques such as magnetic resonance imaging and computed tomography. This quality makes the EEG an important tool for research and diagnosis related to brain disorders and function.
MI has recently attracted a lot of research interest because it is a fairly flexible EEG technique that can distinguish between different brain activations.5,6 The motor imagery (MI)-EEG signals present the brain activity, recorded when the patient imagines or intends to perform actions such as hand or leg movement. The MI-EEG signal is produced in the area of the sensory-motor cortex of the brain in response to these imaginative or reflective tasks. 2 These MI signals have been used by researchers to differentiate between different oscillatory activations of the brain for different tasks. The automated classification of MI4,5 was performed using different machine learning and depth learning techniques.
To treat MI-EEG signals, many feature extraction methods and machine learning algorithms have been investigated attempting to overcome the poor signal-to-noise ratios and the limitations of small datasets. The support vector machine (SVM) is still producing promising results when combined with the right features. To name few researches, in Kumar et al, 7 mutual information is computed from the characteristics of the common spatial patterns (CSP) to select the optimal frequency bands, and the dimensionality is further reduced using linear discriminant analysis (LDA) before finally classifying the models with the SVM. In a later study, 8 the authors use the LDA for spatial filtering and a long- and short-term memory array for temporal filtering before classifying them again with the SVM. There are also alternative approaches to classical machine learning, such as classification by Riemannian geometry 9 or by a standards-based residual strategy. 10
Nowadays, deep learning methods has prompted researchers to apply them for EEG classification, and deep learning has proven that automated feature extraction can achieve better performance.11,12 Different types and architectures of deep learning have led to advanced results in different areas such as speech, 13 and image 14 classification. We find in Bashar’s study, 15 a survey on the evolution of deep learning neural network architectures.
Among the existing approaches for the analysis of EEG data (eg, nonlinear dynamics methods and time-frequency analysis), the most promising and efficient tools for the classification of EEG tests are based on artificial neural networks (ANNs). 16 Successful application of ANNs requires careful selection of their parameters, which significantly vary depending on a particular task and different subjects. 17 Therefore, optimization of EEG input data (filtering, dimensionality reduction, etc) with the best channel selection presents one of the key issues for the development of effective ANN-based BCIs. Traditional dimensionality reduction methods include Principal Component Analysis and LDA, where original characteristics are mathematically projected onto a lower dimensional space. However, these methods are not generic and require the optimization of the input data for each subject due to the high variability of subjects 18 as well as the lack of association between the ongoing optimization and physiological processes in the brain. These problems are particularly relevant for untrained subjects 18 and cause difficulties for the development of universal BCI. Currently, one of the most important tasks in neuroscience and neurotechnology is the development of efficient and universal methods to optimize input data, in particular, by reducing signal complexity, for further processing with ANNs.
In Robinson et al’s study, 19 the authors used the wavelet-CSP algorithm to classify fast and slow hand movements. In Yang et al’s study, 20 the authors proposed an extraction of characteristics based on the subject using the Fisher wavelet packet decomposition (WPD)-CSP method.
The most efficient and promising tools for classifying single EEG trials are based on ANNs.16,21,22 The successful application of ANNs requires careful selection of their parameters, which can vary considerably depending on different subjects and a particular task. 23 Therefore, channel selection and optimization of EEG input data (filtering, dimensionality reduction, etc) is one of the key issues for the development of effective ANN-based BCIs.
Building on the existing research work on MI-EEG signal classification, this research work proposes a method of EEG signal recognition by MI based on an ANN. The main contributions are:
Aiming at the difficult problem of feature extraction from EEG signal, WPD is used to extract time-frequency features. And use CSP to extract spatial features. Provide high-quality data support for training and subsequent testing of ANN models. The proposed method is oriented toward high accuracy and high precision requirements of EEG signal classification for motor imagination. It is based on the ANN model, it realizes efficient classification of EEG signals based on the advantages of the own ANN model, after the application of WPD and CSP. Comparison results show that our proposed method could offer the best performance by achieving the highest value of kappa and accuracy compared to recent state-of-art approaches.
The remainder of the article is organized as follows. Our proposed method is then presented in the second section. Then the third section is devoted to results and discussion. Then concluding remarks are given in the final section.
Methodology
BCI Competition Dataset Description
The well-known database “Competition IV 2a” is employed to train and then to test our method. It enables the comparison of our results with those from the state-of-the-art methods.
The dataset includes recordings of EEG signals for 9 subjects when they were comfortably sitting and performing MI tasks. Data are taken from 22 EEG and 3 electrooculography (EOG) channels. The electrodes are arranged as per standard 10 to 20 system across the scalp of the person.
The timing of data acquisition is shown in Figure 1. The subjects accomplish 4 tasks of MI. These tasks represent left hand, tongue, feet, and right hand. Also, data are split up into short runs. It is worth noting that each run carries 48 trials of each activity of the MI.

Time sequence representation of a trial from the brain-computer interface competition IV dataset 2a.
The collection of the data consists of 2 sessions in 2 days where the session comprises 6 runs with a short break between them. Thus, for each MI activity, a total of 288 trials is collected. Furthermore, the data was sampled at a frequency of 250 Hz and was filtered by a band pass filter between 0.5 to 100 Hz. In order to remove line noise, another 50 Hz notch filter was utilized.
Proposed Work
The EEG signal passes through a band pass filter with a bandwidth of 23 Hz, ranging from 7 to 30 Hz. The filtered version of the signal is followed by a step to remove the 3 EOG channels.
After this preprocessing, we investigated 3 feature extraction techniques, namely time domain parameter (TDP), band power (Bp), and signal power (Sp). We tested these 3 feature extraction techniques which are widely used for feature extraction from the Competition IV 2a dataset. They have given good results.24,25 We compared these techniques in order to have the features which allowed us to improve the used classifiers. Then, we applied the multiple CSP method. We used this method because it is the most successful and is widely used in MI due to its high recognition rate and simplicity of calculation. 26
The extracted multiple CSP is followed by a classification step. At this stage, we tested 3 classifiers, namely quadratic discriminant analysis (QDA), LDA and k-nearest neighbors (KNN).
Keeping the same preprocessing, the WPD technique is applied to each channel, followed by the multiple CSP method. The extracted multiple CSPs are the inputs of our ANN model. Figure 2 shows the system flowchart for classification of the MI.

System flowchart for the classification of the MI. Abbreviations: ANN, artificial neural network; Bp, band power; EEG, electroencephalography; EOG, electrooculograpy; LDA, linear discriminant analysis; MI, motor imagery; Sp, signal power; TDP, time domain parameters; WPD, wavelet packet decomposition.
According to the BCI competition rules, the 3 EOG channels should not be used for classification, for this reason, these channels were ignored in this step. Then, we reduced artifacts by using band pass filtering (fifth-order Butterworth band pass filter: 7-30 Hz).
After the steps of signal preprocessing, the extraction of features is performed. For a given extraction technique, this step could be divided into 3 processing blocks: additional signal filtering using multiple CSP, features calculation, and compute elements of the final vector (vector generation).
The successful application of ANNs requires careful selection of their parameters, which can vary greatly depending on a particular task and different subjects. Therefore, optimization of EEG input data (filtering, dimensionality reduction, etc) and channel selection is one of the key issues for the development of effective ANN-based BCIs. Therefore, we proposed to improve the ANN model by adding a feature extraction block as shown in Figure 2.
Multiple CSP
In BCI, the main goal for using the common spatial patterns CSP algorithm is to calculate features whose variances are optimal to classify only 2 classes of EEG signals. Multiclass CSP are a combination of a certain number of spatial filters. For more details, the reader is referred to Robinson et al’s study. 19
Time Domain Parameters Features
This technique is used to calculate the time-varying power associated to the first k derivatives of the EEG signal. The values obtained from the derivatives of equation (1) are smoothed by using an exponential moving average. Equation (2) gives the used logarithm.
Band Power Features
Each sample of the resulting signal x[t], which contains only the necessary frequency components, is squared to obtain the temporal evolution of the power:
Signal Power Features
For a signal sampled in the time domain by N samples, we calculate the average of the squared as given in equation (5). This average, referred to as the power, is calculated for each EEG channel. The array of these powers presents the feature vector.
Wavelet Packet Decomposition
WPD is a wavelet transform where the discrete-time signal passes through more filters than discrete wavelet transform (DWT). This is of nature to provide a multilevel time-frequency decomposition of the signals. In DWT, each level is calculated by passing only the approximation coefficients of previous wavelets, which are decomposed to give approximation and detail information at a higher level. However, in the WPD, the detail and approximation coefficients are decomposed to create the complete binary tree. The bandwidth of the EEG signal was chosen from the frequency band of 4 to 32 Hz.
Three classifiers are used in the first part of our methodology. These classifiers include the LDA, QDA, and KNN. The LDA classifier is widely used in MI-BCI since it requires low computation. This classifier uses a projection technique that yields data to be projected in a new space. For each class, the LDA classifier includes the same covariance matrix and the mean varies. However, in the QDA classifier, the covariance and the means vary. On the other hand, the KNN classifier represents the simplest classification method. The classification of the feature vector is done by using the majority vote among its neighbors. In addition, the object class is allocated to the most common class which is observed between k-Nearest neighbors.
The ANN is a multilayer fully connected neural nets. The number of inputs corresponds to the feature vector length where the outputs set to 4. One node is allocated to each of the 4 classes. The proposed ANN1 model consists of 116 564 parameters. The proposed ANN2 model consists of 52 580 parameters. Certain parameters (the number of neurons in each layer, the number of hidden layers, etc) must be defined, when designing and training an ANN. These characteristics change depending on a specific application. Therefore, there is no explicit and general method for choosing these parameters. Usually an error and trial method is used, but it is not an accurate method and requires more computing time. We chose to use a batch size of 32 since this size was used by several researchers who obtained good results with the same dataset that we used. 27 In addition, we did several tests with the ANN1 and ANN2 and got the best values with a batch size of 32 with 1000 training epochs.
Figures 3 to 5 illustrate the proposed ANN1 and ANN2 model used to classify the MI tasks. Our architecture is composed on a first layer, a last layer and between them several intermediate layers. The first layer contains 3 elements: Dense layer, Relu activation function, and Dropout layer. The intermediate layers are composed of 7 blocks. Each block starts with a batch normalization layer followed by the dense layer, activation function, and dropout layer.

The proposed ANN1 model. Abbreviation: ANN, artificial neural network.

The proposed ANN2 model. Abbreviation: ANN, artificial neural network.

Detail of the intermediate layers.
The dense layer is the only real network layer in the ANN model. It transmits all the outputs of the previous layer to all of its neurons, with each neuron providing an output to the next layer. It represents the most basic layer of neural networks. We used a dense layer with 124 units (ie, neurons). We used dropout layers with 0.5 to ignore 50% of the units and to make the training fast. The last is the dense layer with 4 units and applies the SoftMax activation function. We have used the dense layers in ANN to enhance the performance of the classification model as presented in Helen Josephine et al’s study. 28
Parameters for the definition of the model, such as, the number of layers, their types, and their activation functions in a neural network, a set of hyperparameters also govern the performance of a model by controlling various aspects of the behavior of the model. The hyperparameters include optimizer type, input batch size, learning rate, convolution kernel width, and drop rate.
Results and Discussion
Performance Criteria
In this section, we present the performance criteria adopted to assess the performance of the proposed method.
Kappa: The kappa coefficient of Cohen k as expressed by equation 6
29
:
Analysis of Obtained Results With Kappa Value
The obtained results are summarized in Tables 1 to 3. In the first part of our bloc diagram, the average kappa of the LDA method leads to an acceptable accuracy. We can see that the best results for most subjects were achieved when using the LDA classifier with TDP features. The LDA classifier with TDP features produced a kappa value of 0.5009, making it the best performing model of this work.
Results Obtained by LDA and QDA.
Abbreviations: Bp, band power; LDA, linear discriminant analysis; QDA, quadratic discriminant analysis; Sp, signal power; TDP, time domain parameters.
Results Obtained by KNN and ANN.
Abbreviations: ANN, artificial neural network; Bp, band power; CSP, common spatial patterns; KNN, k-nearest neighbors; Sp, signal power; TDP, time domain parameters; WPD, wavelet packet decomposition.
Summary of the Research on Classification MI Tasks.
Abbreviations: ANN, artificial neural network; CSP, common spatial patterns; LDA, linear discriminant analysis; MI, motor imagery; TDP, time domain parameters; WPD, wavelet packet decomposition.
Average feature performance shows that Sp and TDP features provide the best features when multiple CSP are used, compared to the other feature (Bp features). However, subjects S2, S4, S5, and S6 were given low results with all experiments, and in case of subject S5, we obtained the weak results compared to other subjects.
This fact could possibly be used to further improve the accuracy of the classification of the algorithm if, at the kappa calculation stage, the classifier giving the best accuracy was chosen for each subject.
In this article, we investigate feature extraction techniques, aiming at improving the classification performance of 4 different MI tasks.
We explained in Table 3 a summary of the research results on the classification of MI tasks. These results are compared to machine learning methods. Table 4 shows that the ANN1, we proposed, outperforms the other models in terms of the kappa value. Compared to other methods, 3 subjects (S2, S3, and S7) achieved higher kappa value of the 9 subjects.
Report Classification Obtained by ANN1 (in %).
Abbreviation: ANN, artificial neural network.
In Barachant et al’s study, 30 the authors developed a new method called “Minimum Distance to the Riemannian Mean (MDRM)”. It is simple to implement, efficient and shows results close to those obtained with the reference method (consisting of a multiclass CSP followed by an LDA). They obtained an average performance of 0.52. This is not surprising because this method does not perform any type of denoising.
In the MDRM classification method, the only signal processing steps required are the comparison of Riemannian distances, estimation of mean covariance matrices and time filtering. It does not require the definition of parameters. In addition, the results obtained seem satisfactory. Moreover, tangent space mapping is an unsupervised operation that allows the extraction of spatial information with a quality that is comparable to that of up-to-date CSPs.
In Miao et al’s study, 31 the authors used in their proposed method the frequency and the spatial domain, and the other features are ignored, which can lead to the loss of information related to MI, and the lost information can be very useful for the recognition of MI tasks.
In Tabar et al’s study, 32 the authors proposed a new deep network by combining CNN and sparse autoencoder. The classification performance obtained by the proposed method on dataset 2b of the BCI competition IV with respect to kappa value is 0.54. Their results point out that deep learning methods offer better classification performance when compared to other methods.
We used the same dataset used by Barachant et al, Miao et al, and Tabar et al.30-32 Our approach shows a significant improvement which has exploited a multiple class CSP followed by LDA classifier, in terms of the kappa value of 0.52. It is worth noting for 3 out of 9 subjects that our ANN1 method significantly outperforms the method of Barachant et al 30 as emphasized in the Table 1. While, our method shows a high performance that is slightly superior than that of Barachant et al 30 in terms of the mean kappa criterion, it has the advantage of preprocessing the dataset by a band pass filter and WPD, before going to the step of feature extraction by multiple CSP and classification by ANN1.
The limitation of our approach is the use of a large number of parameters (116 564 parameters). This encourages us to improve our ANN1 method, the goal of which is to have better results with a reduced number of parameters and also a reduced computing effort. It is for this reason that we tested in the following section the ANN2 model with 52 580 parameters.
Analysis of Obtained Results With Accuracy Value
Tables 4 and 5 show the classification report of the ANN1 and ANN2, respectively.
Report Classification Obtained by ANN2 (in %).
Abbreviation: ANN, artificial neural network.
From these tables, we can conclude that ANN1 gives better results compared to ANN2 despite having a large number of parameters. It reaches a value of precision, recall, F1 score, and accuracy of 58.72%, 57.69%, 57.22%, and 58.42%, respectively.
The confusion matrix for the proposed methods is present in Figures 6 and 7. The diagonal elements demonstrate the number of points for which the predicted label is equal to the true label, while off-diagonal elements are those that are mislabeled by the classifier. The higher the diagonal values of the confusion matrix, the better, showing many correct predictions.

Confusion matrices for the 9 subjects (from (a) to (i)) obtained by ANN1. Abbreviation: ANN, artificial neural network.

Confusion matrices for the 9 subjects (from (a) to (i)) obtained by ANN2. Abbreviation: ANN, artificial neural network.
A comparison of the classification accuracies of the ANN1 method with other state-of-the-art methods is presented in Table 6.
Comparison of the Classification Accuracy (%).
Abbreviation: ANN, artificial neural network.
As shown in Table 6, our ANN1 method outperforms all other machine learning (ML) methods with an average classification accuracy of 58.42%, while the Ensemble method is weaker with an average classification accuracy of 58.20%.
In the study by Thanh et al, 33 the authors compared their proposed particle swarm optimization-based Fuzzy Logic System with many competing approaches, including AdaBoostM2 ensemble (Ensemble), and KNN. They applied these machine learning methods using the functions of Matlab, namely fitensemble and fitcknn, respectively.
Our ANN1 method gave the best accuracy value. We believe that this is thanks to the preprocessing we applied to the dataset. In addition, the extraction of frequency characteristics using WPD and spatial characteristics using CSP, improved the rate of classification accuracy of MI.
In a future work, we will try to apply adaptive transfer learning for an adaptive transfer learning for the classification of MI-EEG with a deep convolutional neural network like 34 or we apply new approaches based on machine learning like. 35
Conclusion
In this work, the experimental analyzes performed show the effectiveness of our proposed method using ANN architecture which achieves 0.5545 of kappa and 58.42% of accuracy on the BCI competition IV 2a dataset. Our results show that this method, with frequency and spatial features extracted by WPD and CSP, respectively, offers a better classification compared to other current methods. We leave it to readers to improve the classification of MI tasks in EEG signals using ML/deep learning techniques. In future work, we intend to refine deep learning models and fusion methods to improve the accuracy of MI-EEG task classification. We also plan to study and compare the execution time of the different blocks as well as a complexity analysis for hardware implementation.
Footnotes
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article
