metabci.brainda.algorithms.decomposition.sscor module

SSCOR.

class metabci.brainda.algorithms.decomposition.sscor.FBSSCOR(n_components: int = 1, ensemble: bool = False, n_jobs: int | None = None, filterbank: List[ndarray] = [], filterweights: ndarray | None = None)[source]

Bases: FilterBank

Filter Bank SSCOR method in paper [1]_., [2]_.

filterbank and weights suggested in the paper.

wp = [

[6, 90], [14, 90], [22, 90], [30, 90], [38, 90], [46, 90], [54, 90], [62, 90], [70, 90], [78, 90]

] ws = [

[4, 100], [10, 100], [16, 100], [24, 100], [32, 100], [40, 100], [48, 100], [56, 100], [64, 100], [72, 100]

]

filterweights:

np.arange(1, 11)**(-1.25) + 0.25

References

transform(X: ndarray)[source]

The parameters stored in self are used to convert X into features, and X is filtered through the filter bank to obtain the eigenvalues of each subband component.

update log:

2023-12-10 by Leyi Jia <18020095036@163.com>, Add code annotation

Parameters:

X (ndarray, shape(n_trials, n_channels, n_samples)) – Test the signal.

Returns:

feat – Feature array.

Return type:

ndarray, shape(n_trials, n_fre)

class metabci.brainda.algorithms.decomposition.sscor.SSCOR(n_components: int = 1, transform_method: str | None = None, ensemble: bool = False, n_jobs: int | None = None)[source]

Bases: BaseEstimator, TransformerMixin

fit(X: ndarray, y: ndarray)[source]
transform(X: ndarray)[source]
metabci.brainda.algorithms.decomposition.sscor.sscor_feature(W: ndarray, X: ndarray, n_components: int = 1) ndarray[source]

Return sscor features.

Modified from https://github.com/mnakanishi/TRCA-SSVEP/blob/master/src/test_sscor.m

Parameters:
  • W (ndarray) – spatial filters from csp_kernel, shape (n_channels, n_filters)

  • X (ndarray) – eeg data, shape (n_trials, n_channels, n_samples)

  • n_components (int, optional) – the first k components to use, usually even number, by default 1

Returns:

features of shape (n_trials, n_components, n_samples)

Return type:

ndarray

Raises:

ValueError – n_components should less than half of the number of channels

metabci.brainda.algorithms.decomposition.sscor.sscor_kernel(X: ndarray, y: ndarray | None = None, n_jobs: int | None = None) Tuple[ndarray, ndarray, ndarray][source]

The kernel part in SSCOR algorithm based on paper[1]_., [2]_.

Modified from https://github.com/mnakanishi/TRCA-SSVEP/blob/master/src/train_sscor.m

Parameters:
  • X (ndarray) – EEG data assuming removing mean, shape (n_trials, n_channels, n_samples)

  • y (ndarray) – labels, shape (n_trials, ), not used here

  • n_jobs (int, optional) – the number of jobs to use, default None

Returns:

  • W (ndarray) – filters, shape (n_channels, n_filters)

  • D (ndarray) – eigenvalues in descending order

  • A (ndarray) – spatial patterns, shape (n_channels, n_filters)

References