pyntbci.transformers.TRCA

class pyntbci.transformers.TRCA(n_components: int = 1)[source]

Task related component analysis (TRCA). Maximizes the intra-class covariances, i.e., the intra-class consistency [2]. TRCA was applied to (SSVEP) BCI [3]. Alternative implementations, also used as example for this code, see Matlab code in [2] for the original, Matlab code in [4] for the SSVEP BCI introduction, and two Python implementation in MOABB [5], and MEEGKit [6].

Parameters:

n_components (int (default: 1)) – The number of TRCA components to use.

w_

The weight vector to project X of shape (n_features, n_components).

Type:

NDArray

References

fit(X: ndarray[Any, dtype[_ScalarType_co]], y: ndarray[Any, dtype[_ScalarType_co]] | None = None) TransformerMixin[source]

Fit TRCA.

Parameters:
  • X (NDArray) – Data matrix of shape (n_trials, n_features, n_samples).

  • y (NDArray (default: None)) – Not used.

Returns:

self – Returns the instance itself.

Return type:

TransformerMixin

transform(X: ndarray[Any, dtype[_ScalarType_co]], y: ndarray[Any, dtype[_ScalarType_co]] = None) ndarray[Any, dtype[_ScalarType_co]][source]

Transform the data matrix from feature space to component space. Note, can operate on both X and y or just X. If X and y are provided, X is filtered with class-specific filters. If only X is provided and a multi-class filter was learned, all trials are filtered with all filters. If only one filter was learned, then only this filter is applied.

Parameters:
  • X (NDArray) – Data matrix of shape (n_trials, n_features, n_samples).

  • y (NDArray (default: None)) – Not used.

Returns:

X – Projected data matrix of shape (n_trials, n_components, n_samples).

Return type:

NDArray