moabb.pipelines.classification.SSVEP_TDCA#
- class moabb.pipelines.classification.SSVEP_TDCA(n_fbands=5, n_components=1, n_delay=6, is_ensemble=True)[source]#
Task Discriminant Component Analysis (TDCA) for SSVEP detection [1].
TDCA is a spatio-temporal discriminant approach that learns common discriminative spatial filters across all stimulus classes using a Fisher-like criterion. Unlike TRCA which learns per-class filters, TDCA learns a shared projection that maximizes between-class scatter relative to within-class scatter.
The method augments EEG data with delayed versions (temporal embedding) to capture temporal dynamics, then applies Fisher discriminant analysis in the augmented space.
Mathematical Formulation
Temporal Embedding: Each trial is augmented with delayed copies:
\[\tilde{\mathbf{X}} = [\mathbf{X}(t), \mathbf{X}(t-1), ..., \mathbf{X}(t-d+1)]\]where \(d\) is the number of delays (
n_delay).2. Between-class scatter \(\mathbf{S}_b\) and within-class scatter \(\mathbf{S}_w\) are computed across all classes.
Fisher criterion: Solve \(\mathbf{S}_b \mathbf{w} = \lambda \mathbf{S}_w \mathbf{w}\)
Top-k eigenvectors form the shared spatial filters.
- Parameters:
n_fbands (int, default=5) – Number of sub-bands for filter bank decomposition.
n_components (int, default=1) – Number of discriminant components to retain.
n_delay (int, default=6) – Number of temporal delays for data augmentation.
is_ensemble (bool, default=True) – If True, use combined filters from all sub-bands for prediction.
- classes_#
Encoded class labels.
- Type:
ndarray of shape (n_classes,)
- templates_#
Templates in the augmented space.
- Type:
ndarray of shape (n_classes, n_fbands, n_channels * n_delay, n_samples_aug)
- weights_#
Shared spatial filters for each sub-band.
- Type:
ndarray of shape (n_fbands, n_components, n_channels * n_delay)
References
[1]Liu, B., Chen, X., Li, X., Wang, Y., Gao, X., & Gao, S. (2021). Improving the performance of individually calibrated SSVEP-BCI by task-discriminant component analysis. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 29, 1998-2007. https://doi.org/10.1109/TNSRE.2021.3114340
Notes
Added in version 1.2.0.
- fit(X, y)[source]#
Learn discriminant spatial filters and class templates.
- 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:
- 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_TDCA[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.