# Multi-Time and Multi-Band CSP Motor Imagery EEG Feature Classification Algorithm
## 2 Materials and Methods
### MI-EEG Recognition Based on MTF-CSP
#### 2.2.4. Final Decision over Multiple Time Windows  
Two algorithms, ED and AS, are used to make the final recognition decision on the n recognition results obtained from multi-frequency CSP feature extraction and SVM classification in n time windows. They are described in the following.  
1 Effective duration algorithm (ED)  
The ED algorithm aims to determine the longest sequence with the successive same value in a list of digits as the effective duration of the sequence; this continuous value is determined as the final decision value. The decision output value has two characteristics: continuous and most frequent occurrences. That is, the final decision value should not only be sequential values in time order, and the number of consecutive occurrences is the highest compared to other values. The successive occurrences of multiple same identification results indicate the continuous and effective concentration of the subjects in the MI tasks. As shown in Figure 5, in the CSP-based feature extraction process, n groups of feature vectors (2 m \(\times\) 7) are obtained that correspond to n time windows. These feature vectors are fed into n SVM classifiers with the same parameters, providing n recognition scores. The n results are arranged in order of time. The period with the largest number of same successivedecisions is regarded as containing more MI feature information (effective time period) in a single MI trial, and the same successive predicted value in this period is regarded as the final decision value. For example, in n time windows, if most of the consecutive identification results are for right-hand MI, then the model determines that this trial is a MI task for the right hand.  
2 Average score algorithm (AS)  
In order to weigh the recognition results of each window fairly in terms of details, the AS algorithm, by which the scores of each time window obtained by SVM are added and averaged, is proposed. The core of the AS algorithm takes the SVM scores rather than the binary classification results of each time window as the reference value to make the final decision because these scores can specifically measure the category nature of the samples in detail. After calculating the average SVM scores of n time windows, the threshold is selected according to their precision and recall variation curves. The final decision is 1 (right hand MI) for scores higher than the threshold; otherwise, the final decision is 0 (left hand MI). SVM prediction score should be denoted in the \(j\)th window be \(score_{j}\) and h should be the selected threshold value. Then, the final decision value \(P\) is:  
\[\begin{array}{l}P=1,mean\big{(}score_{j}\big{)}>\text{h},\big{(}j=1,2, \ldots n\big{)}\\ P=0,mean\big{(}score_{j}\big{)}\leq\text{h},\big{(}j=1,2,\ldots n\big{)}\\ \end{array} \tag{7}\]  
The decision process of the AS algorithm is depicted in Figure 6.  
Since the recall rate and precision vary according to the threshold [48; 49], an appropriate threshold should be determined to judge the final score. The true positive (_TP_) denotes the number of positive samples that have been determined correctly, and the true negative (_TN_) denotes the number of negative samples that have been determined correctly. The  
Figure 5: Schematic diagram of the ED decision algorithm.  
Figure 6: Schematic diagram of the AS decision algorithm.  
false positive (_FP_) and the false negative (_FN_) denote the numbers of positive samples and negative samples determined falsely, respectively. The recall \(r\) and precision \(p\) are defined as follows:  
\[\begin{array}{l}r=\frac{TP}{TP+FP},\\ p=\frac{TP}{TP+FP}\end{array} \tag{8}\]  
Figure 7 shows the recall rate and precision curves of nine subjects according to a varied threshold. As shown in Figure 7, the recall rate and precision change with opposite trends. In order to weigh the recall rate and precision, the threshold value at the intersection point of the two curves is taken as the optimal threshold value for classification.