## 3 WFBRCSP Methods
### Regularized Common Spatial Patterns  
In EEG studies of motor imagery tasks, spatial analysis methods are helpful for identifying and localizing the activation patterns in specific regions of the cortical brain. Specifically, the spatial patterns of EEG signals typically reflect the differences in signal energy across different electrodes or channels, as exhibited in Figure 2. Spatial filtering techniques, such as CSP, are widely used for spatial feature extraction. By optimizing the spatial filters, these techniques can effectively enhance the spatial feature differences of task-related signals, thereby improving the accuracy of motor imagery decoding. The traditional CSP algorithm relies on the covariance matrix to extract features, but the covariance matrix is highly sensitive to noise and artifacts, especially in low signal-to-noise ratio conditions. The presence of noise may lead to inaccurate estimation of the covariance matrix, which in turn, affects the classification performance of the extracted features. In this study, a regularization term is introduced to address the issues of noise and overfitting. Let \(T\) represent the number of channels in the experiment, \(S\) represent the number of sampling points for each channel, and the matrix \(E_{B}[S\times T]\) represent the EEG data collected during one experiment, filtered by the \(B\) filter and weighted for class \(c\) of a particular task. Due to the weighting applied to the subject's EEG data, rank normalization is not performed on the sample covariance matrix here. The form of the sample covariance matrix is:  
\[R_{B,c}=E_{B,c}E_{B,c^{\prime}}^{T}c=\{1,2\} \tag{4}\]  
\(R_{B,c}\) is the sum of the covariance matrices for all \(M_{c}\) trials of the target subject's class \(c\) task in sub-band \(B\), the covariance matrices of the target subject and source domain subjects are merged and regularized using a regularization parameter:  
\[\theta_{B,c}(\beta)=\frac{(1-\beta)\cdot R_{B,c}+\beta\overline{R_{B,c}}}{(1- \beta)\cdot M_{c}+\beta\overline{M_{c}}}(0\leq\beta\leq 1) \tag{5}\]  
\[\sum_{c}\left(\beta,\gamma\right)_{B}=(1-\gamma)\theta_{B,c}(\beta)+\frac{ \gamma}{T}tr[\theta_{B,c}(\beta)]\cdot I(0\leq\gamma\leq 1) \tag{6}\]  
\((\beta,\ \gamma)\) is the regularization parameter, \(\overline{R_{B,c}}\) is the sum of the covariance matrices for \(\overline{M_{c}}\) trials of all source domain subjects' class \(c\) task in sub-band \(B\). The parameter \(\beta\) shifts the initial covariance matrix estimate towards the general covariance, providing a more stable estimate; the parameter \(\gamma\) shifts the initial covariance matrix estimate towards the identity matrix, compensating for possible condition bias under small sample conditions. When \(\beta=\gamma=0\), RCSP is equivalent to CSP [22]. The total covariance matrix is obtained by summing the regularized covariance matrices of the two classes:  
\[S_{B}=\sum_{c,1}\left(\beta,\gamma\right)_{B}+\sum_{c,2}\left(\beta,\gamma \right)_{B} \tag{7}\]  
Perform a generalized eigenvalue decomposition on the total covariance matrix to solve for the eigenvalues \(\lambda_{B}\) and eigenvectors \(\alpha_{B}\). The eigenvectors are then sorted in descending order based on the eigenvalues, resulting in the reordered eigenvector matrix \(U_{B}\). Whitening processing is then applied to \(U_{B}\). Figure 2: The spatial patterns of ERD/ERS in left- and right-hand motor imagery. \[p_{B}=\frac{1}{\sqrt{\lambda_{B}}}U_{B} \tag{8}\]  
Let \(s^{\prime}_{B,c}=P_{B}S_{B,c}P_{B}^{T}\) and solve for the eigenvalues \(\lambda^{\prime}_{B}\) and eigenvectors \(\alpha^{\prime}_{B}\) of \(S^{\prime}_{B,c}\). Similarly, based on the eigenvalues, sort the corresponding eigenvectors in descending order to obtain the eigenvector matrix \(U^{\prime}_{B}\). At this point, the spatial filter for sub-band \(B\) is:  
\[W_{B}=U^{\prime}_{B}P_{B} \tag{9}\]  
Use the spatial filter \(W_{B}\) to extract the EEG signal features \(Z_{B}=W_{B}E_{B}\) and calculate the variance of each column of \(Z_{B}\).