## 2 Materials and Methods
### Algorithms  
Canonical correlation analysis (CCA) is a multivariable statistical method [24], which can be used to investigate the underlying correlation for two sets of data. CCA has been utilized for analyzing the SSVEP signal by studying the linear relationship between two sets of multidimensional vectors, so as to find a pair of linear transformations and to  
Figure 1: Experimental configuration of the SSVEP experiment, including (**a**) experimental protocol, and (**b**) channel configuration for data acquisition. maximize the correlation of the linear combination. Specifically, given the two sets of multi-dimensional vectors \(X\) and \(Y\), CCA aims to figure out the weight vectors \(w\) and \(v\), and to maximize the correlation coefficient between \(x=X^{T}w\) and \(y=Y^{T}v\). The correlation coefficient between each reference signal \(Y_{n}\) and the signal \(X\) is calculated using the following equations:  
\[\rho=max_{w,v}\frac{E\big{[}\widetilde{x}\widetilde{y}^{T}\big{]}}{\sqrt{E[ \widetilde{x}\widetilde{x}^{T}]E[\widetilde{y}\widetilde{y}^{T}]}}=max_{w,v} \frac{w^{T}XY^{T}v}{\sqrt{w^{T}XX^{T}w^{T}YY^{T}v}}. \tag{1}\]  
When the CCA was applied to the SSVEP based BCI [24], the signal \(X\) indicates the acquired EEG data, and \(Y\) represents the reference signal at \(n\)-th stimulation frequency \(f_{n}\). \(Y\) which is composed of several sine and cosine signals [39]:  
\[Y=Y_{n}=\left[ \begin{array}{c}sin(2\pi f_{n}t)\\ cos(2\pi f_{n}t)\\ \vdots\\ sin(2\pi Nf_{n}t)\\ cos(2\pi Nf_{n}t)\end{array} \right],t=\frac{1}{F_{S}},\frac{2}{F_{S}},\ldots, \frac{K}{F_{S}}, \tag{2}\]  
where \(f_{n}\) represents the \(n\)th stimulation frequency, \(N\) is the number of the harmonics used for CCA, \(K\) represents the signal length, and \(F_{S}\) represents the sampling rate. The SSVEP target frequency (the stimulus frequency which the subject focused on) is determined by the following formula:  
\[f_{\text{test}}=argmax_{fn}\rho_{n},\;n=1,2,\ldots,S, \tag{3}\]  
where \(S\) represents the total number of the used stimulation frequencies. Since the reference signal in the standard CCA method is only generated by a series of sine and cosine signals, it does not take into account the influence of individual-specific and inter-trail differences. Therefore, the classification accuracy of the CCA may not be good enough. A multiway extension of CCA (MCCA), which introduces the concept of tensor analysis, has been proposed to improve classification accuracy by optimizing the reference signals. An \(N\)-order tensor is expressed as \(x=\left(x\right)_{i_{1}i_{2}\ldots i_{N}}\in R^{I_{1}\times I_{2}\times \ldots\times I_{N}}\), the projection of \(x\) on the vector \(w\) is calculated as follows:  
\[\left(x\times\;_{n}w^{T}\right)_{i_{1}\ldots i_{n-1}i_{n+1}\ldots i_{N}}=\sum _{i_{n}}^{I_{n}}x_{i_{1}i_{2}\ldots i_{N}}w_{i_{n}}. \tag{4}\]  
A three-way tensor \(x\) (channel \(\times\) time \(\times\) trial) is calculated from the multiway EEG data and the original reference signal set of multiple trials with specific stimulation frequencies. By analyzing the multidimensional correlation between the three-way tensor EEG data and the two-dimensional sine-cosine signal to find the optimal correlation reference signal, MCCA aims to find linear transformations \(w_{1}\), \(w_{3}\) and \(v\) to maximize the correlation between \(\widetilde{x}=x\times_{1}w_{1}^{T}\times_{3}w_{3}^{T}\) and \(\widetilde{y}=v^{T}Y\).