Implementations based on least-square unified framework

We summarized various correlation analysis (CA) based spatial filtering algorithms as a least-square unified framework:

\[\arg\min_{\mathbf{W},\mathbf{M}} \left\|\mathbf{E}\mathbf{W}\mathbf{M}^T-\mathbf{T}\right\|^2_F,\]
\[\text{subject to} \mathbf{M}^T\mathbf{M}=\mathbf{I},\]

where \(\mathbf{W}\) is the spatial filter. The matrix \(\mathbf{E}\) presents the combined EEG features of inter-classes, i.e.,

\[\mathbf{E}=\mathbf{L}_\mathbf{E}\mathbf{P}_\mathbf{E}\mathbf{Z},\]

where \(\mathbf{L}_\mathbf{E}\) denotes the combination matrix of inter-class EEG features, \(\mathbf{P}_\mathbf{E}\) denotes the orthogonal matrix applied for generating inter-class EEG features, and \(\mathbf{Z}\) denotes the EEG data. In addition, the matrix \(\mathbf{T}\) is

\[\mathbf{T}=\mathbf{E}\,\mathcal{S}\!\left(\mathbf{K}\right).\]

Similarly as \(\mathbf{E}\), \(\mathbf{K}\) presents the combined EEG features of intra-classes, i.e.,

\[\mathbf{K}=\mathbf{L}_\mathbf{K}\mathbf{P}_\mathbf{K}\mathbf{Z},\]

where \(\mathbf{L}_\mathbf{K}\) denotes the combination matrix of intra-class EEG features, and \(\mathbf{P}_\mathbf{K}\) denotes the orthogonal matrix applied for generating intra-class EEG features.

The values of \(\mathbf{Z}\), \(\mathbf{L}_\mathbf{E}\), \(\mathbf{P}_\mathbf{E}\), \(\mathbf{L}_\mathbf{K}\), and \(\mathbf{P}_\mathbf{K}\) in the CA-based spatial filtering methods are shown in the following table.

../_images/lsframework_table.png

This reduced rank regression problem can be solved by the alternated least squares:

  1. Initilize \(\mathbf{M}\):

    \[\mathbf{M}=\mathbf{V}^{\left( \mathbf{T} \right)}\text{ where }\mathbf{V}^{\left( \mathbf{T} \right)}\text{ is obtained from the SVD of }\mathbf{T}.\]
  2. Update \(\mathbf{W}\):

    \[\mathbf{W}=\left(\mathbf{E}^T\mathbf{E}\right)^{-1}\mathbf{E}^T\mathbf{T}\mathbf{M}.\]
  3. Update \(\mathbf{M}\):

    \[\mathbf{M}=\mathbf{U}^{\left(\mathbf{P}\right)}\left(\mathbf{V}^{\left(\mathbf{P}\right)}\right)^T.\text{ where }\mathbf{U}^{\left(\mathbf{P}\right)}\text{ and }\mathbf{V}^{\left(\mathbf{P}\right)}\text{ are obtained from the SVD of }\mathbf{P}\]
  4. Repeat the steps 2 and 3 until \(\mathbf{W}\) and \(\mathbf{M}\) are converged.

Standard CCA and filterbank CCA

SSVEPAnalysisToolbox.algorithms.SCCA_ls()

FBCCA implemented based on the least-square unified framework

Parameters
  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • force_output_UV – If True, \(\left\{\mathbf{U}_i,\mathbf{V}_i\right\}_{i=1,2,\cdots,I}\) will be stored. Otherwise, they will not be stored. Default is False.

  • update_UV – If True, \(\left\{\mathbf{U}_i,\mathbf{V}_i\right\}_{i=1,2,\cdots,I}\) will be re-computed in following testing trials. Otherwise, they will not be re-computed if they are already existed. Default is True.

Note

Although the FBCCA is a training-free method, these models still need run “fit” function to store reference signals in the model.

Individual template CCA (itCCA) and extended CCA (eCCA)

SSVEPAnalysisToolbox.algorithms.ITCCA_ls()

itCCA implemented based on the least-square unified framework

Parameters
  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • force_output_UV – If True, \(\left\{\mathbf{U}_i,\mathbf{V}_i\right\}_{i=1,2,\cdots,I}\) will be stored. Otherwise, they will not be stored. Default is False.

  • update_UV – If True, \(\left\{\mathbf{U}_i,\mathbf{V}_i\right\}_{i=1,2,\cdots,I}\) will be re-computed in following testing trials. Otherwise, they will not be re-computed if they are already existed. Default is True.

SSVEPAnalysisToolbox.algorithms.ECCA_ls()

eCCA implemented based on the least-square unified framework

Parameters
  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • update_UV – If True, \(\left\{\mathbf{U}_i,\mathbf{V}_i\right\}_{i=1,2,\cdots,I}\) will be re-computed in following training and testing trials. Otherwise, they will not be re-computed if they are already existed. Default is True.

Multi-stimulus CCA

SSVEPAnalysisToolbox.algorithms.MSCCA_ls()

ms-CCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 12.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

Multi-set CCA (MsetCCA)

SSVEPAnalysisToolbox.algorithms.MsetCCA_ls()

Multi-set CCA implemented based on the least-square unified framework

Parameters
  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

Multi-set CCA with reference signals (MsetCCA-R)

SSVEPAnalysisToolbox.algorithms.MsetCCAwithR_ls()

Multi-set CCA with reference signals implemented based on the least-square unified framework

Parameters
  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

TRCA with reference signals (TRCA-R) and eTRCA with reference signals (eTRCA-R)

SSVEPAnalysisToolbox.algorithms.TRCAwithR_ls()

TRCA-R implemented based on the least-square unified framework

Parameters
  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

SSVEPAnalysisToolbox.algorithms.ETRCAwithR_ls()

eTRCA-R implemented based on the least-square unified framework

Parameters
  • n_component – This parameter will not be considered in the eTRCA-R.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

Multi-stimulus TRCA

SSVEPAnalysisToolbox.algorithms.MSETRCA_ls()

ms-TRCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – This parameter will not be considered in this function.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

Task-discriminant component analysis

SSVEPAnalysisToolbox.algorithms.TDCA_ls()

TDCA implemented based on the least-square unified framework

Parameters
  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.

ms-eTRCA-R-1

SSVEPAnalysisToolbox.algorithms.ms_trca_r_1()

TDCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.

ms-eTRCA-R-2

SSVEPAnalysisToolbox.algorithms.ms_trca_r_2()

TDCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.

ms-MsetCCA-R-1

SSVEPAnalysisToolbox.algorithms.ms_msetcca_r_1()

TDCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.

ms-MsetCCA-R-2

SSVEPAnalysisToolbox.algorithms.ms_msetcca_r_2()

TDCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.

ms-MsetCCA-R-3

SSVEPAnalysisToolbox.algorithms.ms_msetcca_r_3()

TDCA implemented based on the least-square unified framework

Parameters
  • n_neighbor – Number of neighbers considered for computing the spatial filter of one stimulus. Default is 2.

  • n_component – Number of components of eigen vectors that will be applied as the spatial filters. The default number is 1, which means the eigen vector with the highest eigen value is regarded as the spatial filter.

  • n_jobs – Number of threadings. If the given value is larger than 1, the parallel computation will be applied to improve the computational speed. Default is None, which means the parallel computation will not be applied.

  • weights_filterbank – Weights of filterbanks. It is a list of float numbers. Default is None, which means all weights of filterbanks are 1.

  • n_delay – Total number of delays. Default is 0, which means no delay.