The source code of the OACCA introduced in our IEEE TBME paper (10.1109/TBME.2021.3133594) is shared here. After comparing the CCA and OACCA performance, it can be found that the OACCA performs better than the CCA.
v1.0: (6 Jan 2022)
Test OACCA in two SSVEP datasets
Compare CCA and OACCA under different time-window lengths
v1.1: (31 May 2022)
Add the file itr_bci.m
v1.2: (19 Jun 2025)
Add the introduction part
If you find any mistakes, please let me know via chiman465@gmail.com.
In this study, we used two public SSVEP datasets (Dataset I and II) as provided by Tsinghua BCI group (http://bci.med.tsinghua.edu.cn/).
Dataset I:
The details can be found in the following article:
Wang, Y., et al. (2016). A benchmark dataset for SSVEP-based brain–computer interfaces. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 25(10), 1746-1752.
Dataset II:
The details can be found in the following article:
Liu, B., et al. (2020). BETA: A large benchmark database toward SSVEP-BCI application. Frontiers in neuroscience, 14, 627.
The following table lists the important information of these two datasets, including the subject number (N_{sub}), the target number (N_f), the block number (N_{block}), and the layout.
First, the OACCA aims to learn a subject-specified spatial filters from the subject’s multi-trial unlabeled data during online stage, which is substantially different from the traditional CCA method using a single-trial unlabeled data (or the current trial's data). The OACCA can compute the spatial filters that can adapt to a specified subject because it updates the parameters of the spatial filtering algorithm trial by trial.
Here the following block diagrams are used to illustrate the difference between the traditional CCA method and the OACCA method for frequency detection in SSVEP-based BCIs.
In the traditional CCA, each trial's frequency detection is only relied on the current trial's data (or the single-trial data). It does not take the knowledge from previous trials into consideration.
But, in the OACCA, each trial's frequency detection is relied on not only the current trial's data, but also the knowledge from previous trials. The OACCA could compute the adaptive spatial filters by considering the historical information, such as the multi-trial data (
where
In the OACCA, there are two types of adaptive spatial filters: prototype spatial filter and multi-stimulus CCA spatial filter.
- Prototype Spatial Filter
The OACCA computes a prototype spatial filter (PSF) from a series of CCA-SFs corresponding to the previous trials (($u_{{k_1}^{[t]}}^{[1]}$ ,$u_{{k_1}^{[t]}}^{[2]}$ , ...,$u_{{k_1}^{[t]}}^{[t]}$ )), such that the PSF has maximal similarity to them:
where
- Multi-Stimulus CCA Spatial Filter
The OACCA computes a pair of multi-stimulus CCA spatial filter based on the multi-trial data ($X^{[1]}$ ,$X^{[2]}$ , ...,$X^{[t]}$ ) and the corresponding sine-cosine reference signals (${Y_{{k_2}^{[1]}}}$ ,${Y_{{k_2}^{[2]}}}$ , ...,${Y_{{k_2}^{[t]}}}$ ), such that they have the maximal canonical correlation coefficient:
where
Based on three types of spatial filters, we can compute three groups of template-matching results (
Therefore, there are three types of detection results (
where CCA + PSF + MSCCA detection result is the final detection result.
- Dataset I
At first, we run the codeOACCA_acc_tsinghua_2021.m
to calculate the recognition accuracy using different methods (i.e., CCA, OMSCCA, PSF, CCA+OMSCCA, CCA+PSF, OACCA (or CCA+OMSCCA+PSF)), different trial orders (10 random orders) and different data lengths (10 different lengths: 0.6, 0.7, 0.8, ..., 1.5 s). All of the methods are under the same preprocessing procedure (e.g., the same bandpass filtering, the same filter-bank analysis, etc). Finally, all the calculated results will be stored in the OACCA_accuracy_tsinghua_2021.mat.
Second, we run the codeplot_oacca_acc_itr_2021.m
to plot the comparison results based on 'OACCA_accuracy_tsinghua_2021.mat'.
The following figure shows the accuracy comparsion between CCA, OMSCCA, PSF, CCA+OMSCCA, CCA+PSF, OACCA (or CCA+OMSCCA+PSF). Note that x-axis indicates the data length (or time-window length) and y-axis indicates the average accuracy across different subjects and trial orders. The OACCA performs much better than the CCA.
The following figure shows the ITR comparsion between CCA, OMSCCA, PSF, CCA+OMSCCA, CCA+PSF, OACCA (or CCA+OMSCCA+PSF). Note that x-axis indicates the data length (or time-window length) and y-axis indicates the average ITR across different subjects and trial orders. The OACCA performs much better than the CCA.
It should be noticed that only the CCA performance can be kept constant every time (i.e., we can repeat the same results as shown in the IEEE TBME paper). For the others (OMSCCA, PSF, CCA+OMSCCA, CCA+PSF and OACCA), their performance may have very little difference because of different trial orders.
- Dataset II
Similarly, we follow the procedure as introduced in Dataset II in this study. At first, we run the codeOACCA_acc_beta_2021.m
and all the calculated results will be stored in the OACCA_accuracy_beta_2021.mat. Second, we run the codeplot_oacca_acc_itr_2021.m
to plot the comparison results based on 'OACCA_accuracy_beta_2021.mat'.
The following figure shows the accuracy comparsion between CCA, OMSCCA, PSF, CCA+OMSCCA, CCA+PSF, OACCA (or CCA+OMSCCA+PSF). Note that x-axis indicates the data length (or time-window length) and y-axis indicates the average accuracy across different subjects and trial orders. The OACCA performs much better than the CCA.
It should be noticed that only the CCA performance can be kept constant every time (i.e., we can repeat the same results as shown in the IEEE TBME paper). For the others (OMSCCA, PSF, CCA+OMSCCA, CCA+PSF and OACCA), their performance may have very little difference because of different trial orders.
If you use this code for a publication, please cite the following papers
@article{wong2020learning,
title={Learning across multi-stimulus enhances target recognition methods in SSVEP-based BCIs},
author={Wong, Chi Man and Wan, Feng and Wang, Boyu and Wang, Ze and Nan, Wenya and Lao, Ka Fai and Mak, Peng Un and Vai, Mang I and Rosa, Agostinho},
journal={Journal of Neural Engineering},
volume={17},
number={1},
pages={016026},
year={2020},
publisher={IOP Publishing}
}
@article{wong2020spatial,
title={Spatial filtering in SSVEP-based BCIs: unified framework and new improvements},
author={Wong, Chi Man and Wang, Boyu and Wang, Ze and Lao, Ka Fai and Rosa, Agostinho and Wan, Feng},
journal={IEEE Transactions on Biomedical Engineering},
volume={67},
number={11},
pages={3057--3072},
year={2020},
publisher={IEEE}
}
@article{wong2021online,
title={Online Adaptation Boosts SSVEP-Based BCI Performance},
author={Wong, Chi Man and Wang, Ze and Nakanishi, Masaki and Wang, Boyu and Rosa, Agostinho and Chen, Philip and Jung, Tzyy-Ping and Wan, Feng},
journal={IEEE Transactions on Biomedical Engineering},
year={2021 (Early Access)},
publisher={IEEE}
}