moabb.pipelines.classification.SSVEP_TRCA_R#
- class moabb.pipelines.classification.SSVEP_TRCA_R(n_fbands=5, n_harmonics=3, is_ensemble=True, method='original', estimator='scm')[source]#
Regularized TRCA (TRCA-R) for SSVEP detection [1].
TRCA-R extends the standard TRCA method by incorporating reference signal projection as regularization. Training data is projected into the orthogonal complement of the sinusoidal reference signals before computing TRCA spatial filters. This removes the sinusoidal component and forces TRCA to learn filters from the residual, improving performance with limited training data.
Mathematical Formulation
For each stimulus frequency \(f_n\), sinusoidal references \(\mathbf{Y}_n\) are constructed. The projection matrix \(\mathbf{P}_{\perp}\) removes the reference component:
\[\mathbf{P}_{\perp} = \mathbf{I} - \mathbf{Y}_n (\mathbf{Y}_n^T \mathbf{Y}_n)^{-1} \mathbf{Y}_n^T\]Projected training data: \(\tilde{\mathbf{X}} = \mathbf{X} \mathbf{P}_{\perp}\)
TRCA spatial filters are then computed on the projected data as in standard TRCA.
- Parameters:
n_fbands (int) – Number of sub-bands for the filter bank decomposition. Defaults to
5.n_harmonics (int) – Number of harmonics for sinusoidal reference generation. Defaults to
3.is_ensemble (bool) – If True, use ensemble TRCA with combined spatial filters. Defaults to
True.method (str) – Covariance estimation method: ‘original’, ‘riemann’, or ‘logeuclid’. Defaults to
'original'.estimator (str) – Covariance estimator: ‘scm’, ‘lwf’, ‘oas’, or ‘schaefer’. Defaults to
'scm'.
- classes_#
Encoded class labels, of shape
(n_classes,).- Type:
- templates_#
Average templates for each class and sub-band, of shape
(n_classes, n_fbands, n_channels, n_samples).- Type:
- weights_#
Spatial filter weights for each sub-band and class, of shape
(n_fbands, n_classes, n_channels).- Type:
References
[1]Wong, C. M., et al. (2020). Spatial filtering in SSVEP-based BCIs: unified framework and new improvements. IEEE Transactions on Biomedical Engineering, 67(11), 3057-3072. https://doi.org/10.1109/TBME.2020.2975552
Notes
Added in version 1.2.0.
- fit(X, y)[source]#
Extract spatial filters and templates with reference projection.
- Parameters:
X (
mne.Epochs) – Training data as MNE Epochs object.y (numpy.ndarray) – Label vector with frequency strings for each trial, of shape
(n_trials,).
- Returns:
self – Fitted instance.
- Return type:
- predict(X)[source]#
Predict class labels.
- Parameters:
X (
mne.Epochs) – Test data as MNE Epochs object.- Returns:
y_pred – Predicted labels.
- Return type:
- predict_proba(X)[source]#
Predict class probabilities.
- Parameters:
X (
mne.Epochs) – Test data as MNE Epochs object.- Returns:
y_pred – Probabilities per class, of shape
(n_trials, n_classes).- Return type:
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SSVEP_TRCA_R[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.