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, default=5) – Number of sub-bands for the filter bank decomposition.

  • n_harmonics (int, default=3) – Number of harmonics for sinusoidal reference generation.

  • is_ensemble (bool, default=True) – If True, use ensemble TRCA with combined spatial filters.

  • method (str, default='original') – Covariance estimation method: ‘original’, ‘riemann’, or ‘logeuclid’.

  • estimator (str, default='scm') – Covariance estimator: ‘scm’, ‘lwf’, ‘oas’, or ‘schaefer’.

classes_#

Encoded class labels.

Type:

ndarray of shape (n_classes,)

templates_#

Average templates for each class and sub-band.

Type:

ndarray of shape (n_classes, n_fbands, n_channels, n_samples)

weights_#

Spatial filter weights for each sub-band and class.

Type:

ndarray of shape (n_fbands, n_classes, n_channels)

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 (ndarray of shape (n_trials,)) – Label vector with frequency strings for each trial.

Returns:

self – Fitted instance.

Return type:

SSVEP_TRCA_R

predict(X)[source]#

Predict class labels.

Parameters:

X (MNE Epochs) – Test data as MNE Epochs object.

Returns:

y_pred – Predicted labels.

Return type:

list of int

predict_proba(X)[source]#

Predict class probabilities.

Parameters:

X (MNE Epochs) – Test data as MNE Epochs object.

Returns:

y_pred – Probabilities per class.

Return type:

ndarray of shape (n_trials, n_classes)

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SSVEP_TRCA_R[source]#

Configure whether metadata should be requested to be passed to the score method.

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 (see sklearn.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 to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object