Novel joint algorithm based on EEG in complex scenarios

Abstract At present, in the field of electroencephalogram (EEG) signal recognition, the classification and recognition in complex scenarios with more categories of EEG signals have gained more attention. Based on the joint fast Fourier transform (FFT) and support vector machine (SVM) methods, this study proposed a novel EEG signal-processing joint method for the complex scenarios with 10 classifications of EEG signals. Moreover, a comprehensive efficiency formula was put forward. The formula considered the accuracy and time consumption of the joint method. This new joint method could improve the accuracy and comprehensive efficiency of multiclass EEG signal recognition. The new joint approach used standardization for data preprocessing. Feature extraction was performed by combining FFT and principal component analysis methods. EEG signals were classified using the weighted k-nearest nenighbour method. In this study, experiments were conducted using public datasets of brainwave 0-9 digits classification. The result demonstrated that the accuracy and comprehensive efficiency of the novel joint method were 84% and 87%, respectively, which were better than those of the existing methods. The precision rate, recall rate, and F1 score of the novel joint method were 89%, 85%, and 0.85, respectively. In conclusion, the proposed joint method was effective in a complex scenario for multiclass EEG signal recognition.


Introduction
Electroencephalography (EEG) signal is an electrical signal generated by spontaneous electrical activity of hundreds of millions of neurons in the brain. It contains abundant information about brain activity. EEG is an intuitive reflection of the state and function of the brain and has the characteristics of being complex, time-varying, and volatile [1][2][3][4]. At the same time, the brain is also an important organ of the human body, which has important research value. To facilitate the application of EEG signals in clinical studies and practical use, various studies have proposed the noninvasive brain-computer interface (BCI) technology [5][6][7][8].
The EEG-based noninvasive BCI technology is a novel human-computer interaction method. It is independent of human peripheral nerves and muscle tissues, and can realize the communications and controls between the human brain and computer or other peripheral devices. After the researchers extracted the signal characteristics of the acquired EEG signals, they usually used the machine learning methods for classification and recognition [9][10][11][12][13]. The ultimate goal is to send instructions and control external devices. At present, the time-domain and frequency-domain analysis methods [14][15][16], such as fast Fourier transform (FFT), are commonly used methods of EEG signal processing. Then, machine learning methods, such as support vector machine (SVM) and artificial neural network, are used to classify EEG signals [17][18][19][20].
Several studies have reported on the classification of EEG data. For example, Giannakaki et al. [9] collected EEG signals by inducing different emotions and obtained three different types of EEG signals representing calm, positive, and negative emotions. They used wavelet transform combined with SVM method to classify the signals. The accuracy of the recognition result reached 75.12%. Yildiz et al. [17] studied the classification of EEG signals of epileptic patients and normal people. They extracted features from the time domain and frequency domain, such as power spectrum, and then used machine learning methods, SVM, and multilayer perceptron to classify the EEG signals. The accuracy was more than 90%. Other studies have also achieved good results in terms of classification of EEG signals.
At present, studies on the classification of EEG signals mostly focus on the simple recognition scenario of EEG signals of less than five categories, but relatively less research has been done on the classification of more categories of EEG signals. Although a dataset of 10-class EEG signals exists, very few studies have reported on such data to date. This dataset can be used to study EEG recognition of a complex scenario. More importantly, the classification accuracy and time complexity of existing EEG signal classification methods can still be improved. In the field of EEG recognition, two widely used joint classification methods exist: FFT-based joint method [21] and SVM-based joint method [22]. Therefore, based on the existing methods, this study proposed a novel joint method for classifying EEG signals in a complex scenario.

Methods
In this section, two existing joint methods have been introduced: one is based on FFT, and the other on SVM. Also, the proposed novel joint method has been described in detail.

FFT joint method
FFT is a mathematical method used in frequencydomain analysis of signals. It is also widely used in the feature extraction of EEG signals. Akin [23] proposed a joint method based on FFT, which was applied to analyze EEG signals of watching 3D television by five normal volunteers. First, the method normalized the EEG signals and then used FFT and wavelet packet transform methods to process the signals. This method was a classical joint method for EEG signal processing.
As the most common data preprocessing method, normalization can effectively reduce the difficulty in processing data and lower the time complexity of subsequent methods. The calculation formula is as follows: where x is the data point of samples, x max is the maximum value in the data, and x min is the minimum value in the data. x Ã is the result after the normalization, and it ranges from 0 to 1.
After data preprocessing, discrete Fourier transform was used for feature extraction. The formula is as follows: and where N is the number of signal data points, xðnÞ represents the sequence of discrete digital signals, W N is the twiddle factor, and XðkÞ is the result of the transformation. Then, the obtained spectral distribution was taken as the feature vector. Finally, the k-NN method [24] for classification was used.
This classical joint method was widely used in EEG signal analysis. However, when the data volume was large and the dimension was high, the joint method had a large time complexity. Therefore, the comprehensive performance of the method needs to be improved.

SVM joint method
The SVM method is a commonly used classification method in the field of machine learning. It can transform the linear inseparable samples of low-dimensional input space into linear separable samples of highdimensional feature space. This method was also widely used in classifying EEG signals. Subasi and Gursoy [25] proposed an SVM-based joint method. The method was applied to classify and recognize EEG signals in the brain of patients with epileptic seizures and normal individuals. First, they normalized the EEG signals and then employed the primary component analysis (PCA) method to extract features using the SVM method for classification. This method provided a classical joint classification method for EEG recognition.
The SVM joint method first normalizes the EEG data and then uses the PCA [26] method to extract features. Let the set of training samples be fx 1 ; x 2 ; . . . ; x n g; then the average vector of the sample set is The covariance formula is Thus, a covariance matrix is obtained, and it is used for PCA [27].
The PCA method can effectively reduce the dimension and lower the time complexity at the same time. After PCA processing, the reduced data are regarded as the feature vector, and the SVM method [28][29][30][31] is used for feature classification.
The SVM method can solve the small sample, nonlinear, and high-dimensional data classification problem well. Combined with the PCA method for dimension reduction and feature extraction, the method has a large advantage in time complexity. However, the adaptability of SVM to multiclass data and large dataset is poor, and the accuracy is not ideal, leaving a large space for improvement.

Novel joint method
Based on the aforementioned two joint methods, this study proposed a new joint method. It combined the FFT and PCA methods for feature extraction and used the weighted k-NN method for final classification. The weighted method [32,33] could overcome the influence of data noise and data imbalance and make higher classification accuracy. The PCA method could eliminate the noise in the data and reduce the feature dimension. The process of this method is as follows (Figure 1): Step 1: Normalization method was used to preprocess the original EEG signals Step 2: FFT operation was performed on the data. The sequence was divided into two groups according to parity, and the number of values in each group was N=2À1: Then, there is Using the reducibility of coefficient W N ; the following expression was obtained: where X 1 ðkÞ and X 2 ðkÞ have N/2 points with a period of N/2. In this way, the frequency-domain information of the EEG signals could be obtained. Then, PCA was performed on the frequency-domain features. Putting Equation (8) into Equation (5), where the training sample set is fXð0Þ; Xð1Þ; . . . ; XðNÀ1Þg; the following expression was obtained: This formula is the mean vector of the training dataset fXð0Þ; Xð1Þ; . . . ; XðNÀ1Þg; and CovðXðiÞ; XðjÞÞ is the i-th row and j-th column element of the covariance matrix.
Then, the eigenvalues and corresponding eigenvectors of the covariance matrix were calculated. After that, the eigenvectors were arranged into a matrix from top to bottom according to the corresponding eigenvalues from small to large. Finally, the first few rows of the matrix were taken to form the transformation matrix. Through this transformation matrix, feature vectors could be projected to low-dimensional feature spaces.
Step 3: The data obtained from the FFT and dimension reduction were taken as final feature vectors, and the weighted k-NN method was used for feature classification. The method assumed that all feature samples were in the n-dimensional space, and each sample was represented as the vector <a 1 ðxÞ; a 2 ðxÞ; . . . ; a n ðxÞ>; where a r ðxÞ denotes the value of the r-th attribute of sample x: Then, the similarity between the two samples was measured by the Euclidean distance. Let w k be the characteristic weight value and m be the number of attribute values of each sample. The weighting method can be referred from a previous study [34], and the formula can be simplified as follows: 2. Materials and comprehensive efficiency formula

Data acquisition
The International 10-20 System was used as the reference standard for electrode placement. The data in the experiment were collected from the public dataset: MindBigData (http://www.mindbigdata.com/opendb/).  A multichannel EEG acquisition equipment Emotiv Insight was used for the purpose. The positions of the signals collected in the 10-20 System were AF3, AF4, T7, T8, and Pz. The equipment recorded the EEG signals of participants when they observed the numbers 0-9 in a period of 2 s. A total of 65,250 pieces of data were collected as the dataset. The EEG signal distribution corresponding to stimulus digits 0-9 is shown in Table 1.
In this experiment, the five-fold cross-validation method [35,36] was used to make full use of all samples and evaluate the joint method model. In this method, the data were divided into five disjoint subsets, one of which was selected as the test set and the other four as training sets for each time. The number of test data was 13,050, and the number of training data was 52,200. Therefore, every experiment was carried out five times to ensure the reliability and stability of the results. Moreover, the time consumption and relevant performance evaluation metrics of each experiment were analyzed.

Comprehensive efficiency
Two important parameters were used to judge the performance of the joint method: one was the time consumption for the method operation, and the other was the final classification accuracy of the method. To assess the joint method better, a comprehensive efficiency formula was designed based on the information of time consumption and accuracy. Suppose N methods are present, and the accuracy of the i-th method is m i ; in the interval [0, 1]. The normalized time information parameter is t i : The formula is where the time consumption before normalization processing is represented by t i0 ; and t min and t max represent the minimum and maximum values of time consumption, respectively, before normalization.
Because t i was normalized, its value was in the range [0, 1]. The comprehensive performance of the method was inversely proportional to the time complexity and proportional to the accuracy approximately. To facilitate the calculation, 1Àt i was used in the formula. For avoiding the zero value, ð1Àt i Þ þ 0:1 was adopted. The final comprehensive efficiency formula was as follows: The variable P i is the synthesis efficiency of the ith method, which was used to evaluate the synthesis performance of the joint method.

Experiments and results
This study used cross-validation to perform five independent experiments using three EEG classification joint methods. Then, time consumption and other performance evaluation metrics were compared, and the average was calculated as the final reference measurement.
For these three joint methods, the parameter tuning was conducted on relative models and classifiers. After tuning, the better parameters for these classifiers were chosen. For the k-NN classifier in the FFT joint method, the number of neighbors was set as 5. For the PCA method in the SVM joint method, the number of components to keep was 20; for the SVM method, the "rbf" kernel function was applied, and the penalty parameter C was 0.4. For the PCA method in the novel joint method, the number of components to keep was 20; and for the k-NN classifier, the number of neighbors was set as 2. Table 2 compares the time consumption of the three joint methods. The computer processor used was Intel Core i7-4790, and the main frequency was 3.60 GHz. Table 2 shows that, in the process of classifying EEG signals, the time consumed by the FFT joint method was obviously longer than that for the SVM joint method and the new joint method proposed in this study. Also, the time for the new joint method was a little longer than that for the SVM joint method  because the SVM method does not undergo complex FFT operation. In addition, the new joint method consumed less time because PCA analysis was used to reduce the data dimension. Under the premise of high classification accuracy, the time consumption of the new joint method was acceptable. Comparing the average time consumption of the three joint methods, it was found that the time consumption for the new joint method and the SVM joint method was close, while that of the FFT joint method was about three times that for the former two methods. Therefore, the new joint method performed well in terms of time consumption.

Classification performance analysis
Accuracy is a classification effectiveness evaluation indicator often used in classification problems. The comparison of the accuracy of three joint methods in the complex case of classifying 10-category EEG is shown in Table 3. It is obvious that the classification accuracy of the FFT joint method was higher than that of the SVM joint method, and the accuracy of the new joint method was better than that of the FFT joint method and the SVM joint method. The average accuracy of the new joint method improved by 6% compared with that of the FFT joint method, and by 20% compared with that of the SVM joint method. This showed that the combination of FFT and PCA could obtain the main features of EEG signals and better characterize EEG signals. At the same time, the application of the weighted k-NN method also improved the classification accuracy. Table 3 shows that the average accuracy of the three methods from high to low was as follows: the novel joint method, FFT joint method, and SVM joint method. Therefore, the new joint method had better performance in terms of accuracy.
In addition, to ensure the performance and credibility of the methods, other evaluation metrics, such as precision, recall, F1 score, and kappa coefficient, were also compared.
As the accuracy metric simply calculates the proportion of the sample with the correct prediction, it does not distinguish between the prediction results of different categories and does not consider the case of sample imbalance. Therefore, other more effective metrics are needed. Precision and recall are two metrics widely used in the field of information retrieval and statistical classification to evaluate the quality of results. Then these two metrics were adopted for performance evaluation of the three joint methods in EEG signal recognition.
Precision calculated the proportion of all "correctly retrieved" for all "actually retrieved." The metric was used for performance evaluation when the number of samples in different categories was not completely equal. The comparison of the precision rate of the three methods is shown in Table 4. It was apparent that the precision rate of the SVM joint method was higher than that of the FFT joint method, and the precision of the new joint method was better than that of the SVM joint method. It could be seen that the average precision of the new joint method improved by 25% compared with that of the FFT joint method, and by 17% compared with that of the SVM joint method. This showed that the application of the weighted k-NN method also improved the classification performance.
Recall stands for the ratio of "correctly retrieved" for all "should be retrieved". It is also an effective performance metric when the sample category is unbalanced. The comparison of the recall rate of the threemethod classifications is shown in Table 5. The table shows that the recall rate of the SVM joint method was higher than that of the FFT joint method, and the recall rate of the new joint method was better than that of the SVM joint method. The average recall rate of the new joint method improved by 25% compared with that of the FFT joint method, and by 20% compared with that of the SVM joint method. This indicated that the new joint method was an effective joint method for EEG signal classification. Precision and recall are mutually influential, although an ideal situation arises when both are high. In general, when precision is high, recall is low, or recall is low, but precision is high. Therefore, in practice, it is often necessary to make trade-offs according to specific situations. For example, in the case of general search, the precision rate is raised under the premise of ensuring recall. Moreover, for disease monitoring, anti-spam, and so on, the recall rate is improved under the premise of ensuring the precision rate. However, sometimes, it is required to balance the two, and then the F1 score indicator can be adopted. It is assumed that the precision and recall rates are as high as possible in classifying EEG signals.
The F1 score is a compromise between precision and recall, and it is the harmonic mean of precision rate and recall rate. The comparison of F1 score of the three methods is shown in Table 6. Table 6 shows that the F1 score of the SVM joint method exceeded that of the FFT   joint method, and the F1 score of the new joint method was higher than that of the SVM joint method. The average F1 score of the new joint method increased by 29% compared with that of the FFT joint method, and by 21% compared with that of the SVM joint method. This suggested that the new joint method could obviously improve the classification quality. For a multiclass classification problem, measures such as the accuracy or precision/recall do not provide the complete description of the performance of the classifier in this study. Moreover, when faced with a problem with imbalanced classes, accuracy can be misleading, and then precision, recall, and F1 scores are the other options. However, the F1 score measure does not have an excellent intuitive explanation, other than it being the harmonic mean of precision and recall. Thus, the kappa coefficient was used, which is a very good measure that can handle both multiclass and imbalanced class problems well.
The kappa coefficient can better represent the performance of the multiclassification model based on the confusion matrix of classification results. It is generally thought to be a more robust measure than the simple percent agreement calculation. Moreover, the definition of kappa coefficient is as follows: where p 0 is the relative observed agreement among raters (identical to accuracy) and p e is the hypothetical probability of chance agreement, using the observed data to calculate the probabilities of each observer randomly seeing each category. Moreover, the formula of p e is as follows: (15) where N is the number of items; and for category k, n Ák denotes the number of samples predicted to be category k; and n kÁ denotes the number of samples of category k: The comparison of kappa coefficient of the three method classifications is shown in Table 7. The table shows that the kappa coefficient of the new joint method was better than that of the FFT joint method and the SVM joint method. The average kappa coefficient of the new joint method increased by 94% compared with that of the FFT joint method, and by 23% compared with that of the SVM joint method. The experimental results showed that the new joint method could effectively improve the results of classifying EEG signals in the complex scenario.

Comprehensive efficiency analysis
Two parts are considered in the calculation formula of the comprehensive efficiency of the method: the time consumption and the final classification accuracy. The synthesis efficiency is approximately inversely proportional to the time consumption and directly proportional to the classification accuracy. It can directly reflect the relationship between the consumption time and the accuracy, and accurately evaluate the comprehensive performance of the method. Table 8 shows that the FFT joint method and the SVM joint method are less efficient than the new joint method. Moreover, the new joint method was more efficient than the SVM joint method and the FFT joint method. This showed that the new joint method was effective for classifying EEG signals in complex scenarios.

Conclusion
This study proposed a novel EEG data processing joint method for a complex scenario. It was compared with the existing joint method from several aspects, including time consumption, accuracy, precision rate, F1 score, comprehensive efficiency, and so on. The method used PCA to reduce the dimension of the spectral information of EEG signals; therefore, the time complexity reduced. In addition, the application of a weighted k-NN method ensured that the method could classify EEG signals effectively and improve classification accuracy. The results showed that the proposed novel joint method had the accuracy of 84%, and it improved by 6% and 20% compared with the traditional FFT joint method and SVM joint method, respectively. The novel joint method had a precision rate of 89%, recall rate of 85%, and F1 score of 0.85. Moreover, the comprehensive efficiency of the new joint method was 87%, which improved by nearly 10 times compared with that of the FFT joint method, and increased by 12% compared with that of the SVM joint method. Therefore, the proposed new joint method could better deal with the classification of EEG signals under complex scenarios. The new method can be applied to other EEG signal-processing scenarios, such as emotional recognition [37][38][39][40][41] based on EEG signals. Other feature extraction or classification methods and contrast experiments with existing methods can also be explored using this method. A more efficient method for complex multiclass EEG classification scenarios needs to be developed in future studies.