# 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.1 CSP Algorithm  
A CSP algorithm is a spatial filtering algorithm that is suitable for processing multi-channel (multi-dimensional) signals such as EEG signals because CSP can synchronously exploit the spatial correlation of multiple signal channels to capture the spatial characteristics of the multi-dimensional signals. It aims to find an optimal set of spatial filters, enabling the two kinds of samples to acquire a spatial characteristic component and maximum variance after projection [33; 45]. The process of achieving this optimal spatial filter is described by Formulas (1)-(4) as follows:  
Figure 2: Logic flow diagram of the proposed method.  
For the binary MI-EEG classification task, the training set data can be divided into two types of datasets: \(\mathbf{X}_{1}\) and \(\mathbf{X}_{2}\). The mixed covariance matrix (\(\mathbf{R}\)) is obtained for the two types of data as follows:  
\[\mathbf{R}=\overline{\mathbf{R}}_{1}+\overline{\mathbf{R}}_{2}=\text{mean}(\frac{\mathbf{x}_{1 }\mathbf{x}_{1}^{\text{T}}}{\text{trace}(\mathbf{x}_{1}\mathbf{x}_{1}^{\text{T}})})+\text{ mean}(\frac{\mathbf{x}_{2}\mathbf{x}_{2}^{\text{T}}}{\text{trace}(\mathbf{x}_{2}\mathbf{x}_{2}^{ \text{T}})}) \tag{1}\]  
where \(\mathbf{x}_{1}\) and \(\mathbf{x}_{2}\) represent the samples in the two types of datasets, \(\mathbf{X}_{1}\) and \(\mathbf{X}_{2}\), respectively. \(\overline{\mathbf{R}}_{1}\) and \(\overline{\mathbf{R}}_{2}\) represent the average covariance matrix of the two types of data, respectively. The mean indicates the average of the two covariance matrices, and trace indicates the trace of the matrix.  
The albino matrix is obtained according to the mixed covariance matrix:  
\[\mathbf{P}=\frac{1}{\sqrt{\mathbf{\lambda}_{\tau}}}\mathbf{U}_{\tau}^{\text{T}} \tag{2}\]  
where \(\mathbf{\lambda}_{\tau}\) and \(\mathbf{U}_{\tau}^{\text{T}}\) are the eigenvalue and eigenvector matrix of the mixed covariance matrix (\(\mathbf{R}\)), respectively. By using the albino matrix and the mixed covariance matrix, the common eigenvector matrix \(\mathbf{S}_{1}\) and \(\mathbf{S}_{1}\) can be expressed as:  
\[\mathbf{S}_{1}=\mathbf{P}\mathbf{R}_{1}\mathbf{P}^{\text{T}},\mathbf{S}_{2}=\mathbf{P}\mathbf{R}_{2}\mathbf{P} ^{\text{T}} \tag{3}\]  
The projection matrix is determined by the albino matrix (\(\mathbf{P}\)) and the common eigenvector matrix (\(\mathbf{S}_{1}\) or \(\mathbf{S}_{2}\)). The projection matrix (\(\mathbf{W}\)) is expressed as:  
\[\mathbf{W}=\mathbf{U}_{\mathbf{S}}^{\text{T}}\mathbf{P} \tag{4}\]  
where \(\mathbf{U}_{\mathbf{S}}^{\text{T}}\) refers to the eigenvector matrix obtained by the decomposition of \(\mathbf{S}_{1}\) or \(\mathbf{S}_{2}\) (\(\mathbf{S}_{1}\) is equal to \(\mathbf{S}_{2}\)).  
The final CSP filter \(\mathbf{W}_{\text{CSP}}\) consists of m maximum values and m minimum values selected from the projection matrix (\(\mathbf{W}\)). Finally, a feature vector with a length of 2 m is extracted. That is, the CSP feature vector of the single-frequency band and single-time window signal is \(\mathbf{X}_{\text{CSP}}=[\mathbf{x}_{1},\cdots,\mathbf{x}_{2m}]\).