moabb.pipelines.classification.SSVEP_eCCA#
- class moabb.pipelines.classification.SSVEP_eCCA(n_harmonics=3, freq_map=None)[source]#
Extended CCA (eCCA) for SSVEP detection [1].
Extended CCA combines standard CCA with individual template CCA through a multi-feature fusion approach. It computes four correlation features that capture complementary information from both sinusoidal references and data-driven templates.
Mathematical Formulation
For each test signal \(\mathbf{X}\) and stimulus class \(n\), four correlation features are computed:
\[\begin{split}r_1 &= \rho(\text{CCA}(\mathbf{X}, \mathbf{Y}_n)) \\ r_2 &= \rho(\text{CCA}(\mathbf{X}, \bar{\mathbf{X}}_n)) \\ r_3 &= \rho(\mathbf{X}^T \hat{\mathbf{w}}_{xn}, \bar{\mathbf{X}}_n^T \hat{\mathbf{w}}_{xn}) \\ r_4 &= \rho(\mathbf{X}^T \tilde{\mathbf{w}}_{xn}, \bar{\mathbf{X}}_n^T \tilde{\mathbf{w}}_{xn})\end{split}\]where:
\(\mathbf{Y}_n\) is the sinusoidal reference for frequency \(f_n\)
\(\bar{\mathbf{X}}_n\) is the averaged individual template
\(\hat{\mathbf{w}}_{xn}\) is the spatial filter from \(\text{CCA}(\mathbf{X}, \mathbf{Y}_n)\)
\(\tilde{\mathbf{w}}_{xn}\) is the spatial filter from \(\text{CCA}(\bar{\mathbf{X}}_n, \mathbf{Y}_n)\)
Classification Rule
Features are fused using signed squared correlation:
\[\rho_n = \sum_{l=1}^{4} \text{sign}(r_l) \cdot r_l^2\]The predicted class is: \(\hat{f} = \arg\max_n \rho_n\)
- Parameters:
- classes_#
Class labels in the same label space as
y.- Type:
ndarray of shape (n_classes,)
- le_#
Fitted label encoder.
- Type:
LabelEncoder
References
[1]Chen, X., Wang, Y., Gao, S., Jung, T.-P., & Gao, X. (2015). Filter bank canonical correlation analysis for implementing a high-speed SSVEP-based brain-computer interface. PLOS ONE, 10(12), e0140703. https://doi.org/10.1371/journal.pone.0140703
Notes
Added in version 1.2.0.
- fit(X, y, sample_weight=None)[source]#
Compute individual templates, sinusoidal references, and spatial filters.
- Parameters:
X (MNE Epochs) – Training data as MNE Epochs object.
y (ndarray of shape (n_trials,)) – Label vector with frequency strings for each trial.
sample_weight (Unused) – Only for compatibility with scikit-learn.
- Returns:
self – Fitted instance.
- Return type:
- predict_proba(X)[source]#
Predict class probabilities from fused correlation features.
- Parameters:
X (MNE Epochs) – Test data as MNE Epochs object.
- Returns:
P – Probability of each class for each trial.
- Return type:
ndarray of shape (n_trials, n_classes)
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SSVEP_eCCA[source]#
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SSVEP_eCCA[source]#
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.