meegkit.trca#

Task-Related Component Analysis.

Functions

trca(X)

Task-related component analysis.

TRCA(sfreq, filterbank[, ensemble, method, ...])

Task-Related Component Analysis (TRCA).

class meegkit.trca.TRCA(sfreq, filterbank, ensemble=False, method='original', estimator='scm')#

Bases: object

Task-Related Component Analysis (TRCA).

Parameters:
  • sfreq (float) – Sampling rate.

  • filterbank (list[[2-tuple, 2-tuple]]) –

    Filterbank frequencies. Each list element is itself a list of passband Wp and stopband Ws edges frequencies [Wp, Ws]. For example, this creates 3 bands, starting at 6, 14, and 22 hz respectively:

    [[(6, 90), (4, 100)],
     [(14, 90), (10, 100)],
     [(22, 90), (16, 100)]]
    

    See scipy.signal.cheb1ord() for more information on how to specify the Wp and Ws.

  • ensemble (bool) – If True, perform the ensemble TRCA analysis (default=False).

  • method (str in {'original'| 'riemann'}) – Use original implementation from [1] or a variation that uses regularization and the geodesic mean [2].

  • regularization (str in {'schaefer' | 'lwf' | 'oas' | 'scm'}) – Regularization estimator used for covariance estimation with the riemann method. Consider ‘schaefer’, ‘lwf’, ‘oas’. ‘scm’ does not add regularization and is almost equivalent to the original implementation.

traindata#

Reference (training) data decomposed into sub-band components by the filter bank analysis.

Type:

array, shape=(n_bands, n_chans, n_trials)

y_train#

Labels associated with the train data.

Type:

array, shape=(n_trials)

coef_#

Weight coefficients for electrodes which can be used as a spatial filter.

Type:

array, shape=(n_chans, n_chans)

classes#

Classes.

Type:

list

n_bands#

Number of sub-bands.

Type:

int

References

[1]

M. Nakanishi, Y. Wang, X. Chen, Y. -T. Wang, X. Gao, and T.-P. Jung, “Enhancing detection of SSVEPs for a high-speed brain speller using task-related component analysis”, IEEE Trans. Biomed. Eng, 65(1):104-112, 2018.

[2]

Barachant, A., Bonnet, S., Congedo, M., & Jutten, C. (2010, October). Common spatial pattern revisited by Riemannian geometry. In 2010 IEEE International Workshop on Multimedia Signal Processing (pp. 472-476). IEEE.

__init__(sfreq, filterbank, ensemble=False, method='original', estimator='scm')#
fit(X, y)#

Training stage of the TRCA-based SSVEP detection.

Parameters:
  • X (array, shape=(n_samples, n_chans[, n_trials])) – Training EEG data.

  • y (array, shape=(trials,)) – True label corresponding to each trial of the data array.

predict(X)#

Test phase of the TRCA-based SSVEP detection.

Parameters:

X (array, shape=(n_samples, n_chans[, n_trials])) – Test data.

Returns:

pred – The target estimated by the method.

Return type:

np.array, shape (trials)

meegkit.trca.trca(X)#

Task-related component analysis.

This function implements the method described in [1].

Parameters:

X (array, shape=(n_samples, n_chans[, n_trials])) – Training data.

Returns:

W – Weight coefficients for electrodes which can be used as a spatial filter.

Return type:

array, shape=(n_chans,)

References

[1]

M. Nakanishi, Y. Wang, X. Chen, Y. -T. Wang, X. Gao, and T.-P. Jung, “Enhancing detection of SSVEPs for a high-speed brain speller using task-related component analysis”, IEEE Trans. Biomed. Eng, 65(1):104-112, 2018.

meegkit.trca.trca_regul(X, method)#

Task-related component analysis.

This function implements a variation of the method described in [1]. It is inspired by a riemannian geometry approach to CSP [2]. It adds regularization to the covariance matrices and uses the riemannian mean for the inter-trial covariance matrix S.

Parameters:

X (array, shape=(n_samples, n_chans[, n_trials])) – Training data.

Returns:

W – Weight coefficients for electrodes which can be used as a spatial filter.

Return type:

array, shape=(n_chans,)

References

[1]

M. Nakanishi, Y. Wang, X. Chen, Y. -T. Wang, X. Gao, and T.-P. Jung, “Enhancing detection of SSVEPs for a high-speed brain speller using task-related component analysis”, IEEE Trans. Biomed. Eng, 65(1):104-112, 2018.

[2]

Barachant, A., Bonnet, S., Congedo, M., & Jutten, C. (2010, October). Common spatial pattern revisited by Riemannian geometry. In 2010 IEEE International Workshop on Multimedia Signal Processing (pp. 472-476). IEEE.