## 3 Methods
### Function Selection Mode
#### 3.3.1 Offline P300 Detector Training and Optimization
P300 Detector - Kernel FDA Training and Testing  
In the training stage, KFDA maps the training data \(\mathbf{z}_{i}\in R^{n},i=1,\ldots,L\) into a higher dimensional feature space \(F\) using a nonlinear mapping \(\varphi:\mathbf{z}\in R^{n}\rightarrow\varphi\left(\mathbf{z}\right)\in F\), where the training data includes P300 and non-P300 ones, and then solves the maximization problem as  
\[\underset{\mathbf{v}}{\max}\frac{\mathbf{v}^{\intercal}\mathbf{Bv}}{\mathbf{ v}^{\intercal}\mathbf{Wv}} \tag{4}\]  
where  
\[\mathbf{B}=\frac{1}{L}\sum_{p=1}^{2}n_{p}\left(\frac{1}{n_{p}}\sum_{q=1}^{n_{ p}}\varphi(\mathbf{z}_{pq})\right)\left(\frac{1}{n_{p}}\sum_{r=1}^{n_{p}} \varphi\left(\mathbf{z}_{pr}\right)\right)^{t}\text{ and }\mathbf{W}=\frac{1}{L}\sum_{p=1}^{2}\sum_{q=1}^{n_{p}} \varphi\left(\mathbf{z}_{pq}\right)\varphi^{t}\left(\mathbf{z}_{pq}\right) \tag{5}\]  
are the inter-class inertia and intra-class inertia, respectively, \(\mathbf{z}_{pq}\) is the \(q\)th training data in the \(p\)th class, and \(n_{p}\) is the number of training data in the \(p\)th class. In this paper, the first and the second classes are defined as the positive (P300) and negative (non-P300) classes, respectively. The matrix \(\mathbf{W}\) in (5) is in fact a covariance matrix in \(F\), and thus the mapped data in the expression of \(\mathbf{W}\) need to be centered in advanced [38]. However, the nonlinear mapping is unknown. [PERSON] _et al._ have applied kernel tricks to provide a mapped data centering method (see Appendix C of [38] for detailed derivation). Moreover, the maximization problem in (4) is equivalent to the following eigenvalue resolution:  
\[\lambda\mathbf{Wv}=\mathbf{Bv} \tag{6}\]  
The vector \(\mathbf{v}=\sum_{i=1}^{L}a_{i}\varphi\left(\mathbf{x}_{i}\right)\) is the eigenvector of \(\mathbf{W}^{-1}\mathbf{B}\), where \(a_{i}\) are the expansion coefficients for \(\mathbf{v}\). Performing the eigenvector decomposition on the \(L\times\ L\) kernel matrix \(\mathbf{K}=\left(K_{ij}\right)\) yields \(L\) normalized expansion coefficient vector \(\mathbf{a}\) for each vector \(\mathbf{v}:\mathbf{a}=\mathbf{a}/\sqrt{\mathbf{a}^{\intercal}\mathbf{Ka}}\), where \(K\left(\mathbf{z}_{i},\ \mathbf{z}_{j}\right)=K_{ij}=\varphi\left(\mathbf{z}_{i} \right)\cdot\varphi\left(\mathbf{z}_{j}\right)\) is the kernel function, and \(\mathbf{a}\) is the eigenvector of \(\mathbf{K}\). The training state of Kernel FDA is over after the  
Figure 5: Illustration of the target rows and columns. If the element surrounded by the yellow box is the target element that a user keeps looking at during the data collection, the first column and the second row are defined as the target column and target row, respectively. coefficient vectors are computed. In the testing stage, the projection of a test data \(\mathbf{z}\) onto the \(i\)th vector \(\mathbf{v}^{i}\) is obtained by  
\[\mathbf{x}^{i}=\mathbf{v}^{i}.\,\varphi\left(\mathbf{z}\right)=\sum\limits_{j=1 }^{L}a_{j}^{i}\varphi\left(\mathbf{z}_{j}\right)\cdot\varphi\left(\mathbf{z} \right)=\sum\limits_{j=1}^{L}a_{j}^{i}K\left(\mathbf{z}_{j},\mathbf{z}\right),i =1,\ldots,L \tag{7}\]  
where \(a_{j}^{i}\) is the \(j\)th expansion coefficient of \(\mathbf{v}^{i}\). By choosing the first \(d\) projection values (\(d<L\)), a \(d\)-dimensional vector \(\mathbf{x}=\left(x^{1},\ldots,x^{d}\right)^{t}\in R^{d}\) is formed, which is an EEG feature that will be sent into the SVM classifier. We choose the radius basis function (RBF)  
\[\mathbf{z_{r}}=\frac{1}{N}\sum\limits_{j=1}^{N}\mathbf{z_{rj}},r=1, \ldots,5 \tag{3}\]0  
as the kernel function in this paper, where \(\sigma\) is the parameter of the RBF kernel. Since the RBF kernel is used, the space \(F\) is of infinite dimension [40]. P300 Detector - SVM Training and Testing  
Formulation of SVM (9)-(10) and the kernel function expressed in (8) are also provided in [32]. A set of training data \(\left\{\mathbf{x}_{i},\ y_{i}\right\}_{i=1}^{L}\) is given, where \(\mathbf{x}_{i}\in R^{d}\), and \(y_{i}\) are class labels being either \(+1\) or \(-1\).