pyriemann.estimation.XdawnCovariances

class pyriemann.estimation.XdawnCovariances(nfilter=4, applyfilters=True, classes=None, estimator='scm', xdawn_estimator='scm', baseline_cov=None, **kwds)

Estimate special form covariance matrix for ERP combined with Xdawn.

Estimation of special form covariance matrix dedicated to ERP processing combined with Xdawn spatial filtering. This is similar to pyriemann.estimation.ERPCovariances but data are spatially filtered with pyriemann.spatialfilters.Xdawn. A complete description of the method is available in [1].

The advantage of this estimation is to reduce dimensionality of the covariance matrices supervisely.

Parameters
nfilterint, default=4

Number of Xdawn filters per class.

applyfiltersbool, default=True

If set to true, spatial filter are applied to the prototypes and the signals. When set to False, filters are applied only to the ERP prototypes allowing for a better generalization across subject and session at the expense of dimensionality increase. In that case, the estimation is similar to pyriemann.estimation.ERPCovariances with svd=nfilter but with more compact prototype reduction.

classeslist of int | None, default=None

list of classes to take into account for prototype estimation. If None, all classes will be accounted.

estimatorstring, default=’scm’

Covariance matrix estimator, see pyriemann.utils.covariance.covariances().

xdawn_estimatorstring, default=’scm’

Covariance matrix estimator for Xdawn spatial filtering. Should be regularized using ‘lwf’ or ‘oas’, see pyriemann.utils.covariance.covariances().

baseline_covarray, shape (n_channels, n_channels) | None, default=None

Baseline covariance for Xdawn spatial filtering, see pyriemann.spatialfilters.Xdawn.

**kwdsoptional keyword parameters

Any further parameters are passed directly to the covariance estimator.

See also

ERPCovariances
Xdawn

References

1

MEG decoding using Riemannian Geometry and Unsupervised classification A. Barachant. Technical report with the solution of the DecMeg 2014 challenge.

Attributes
P_ndarray, shape (n_classes x min(n_channels, n_filters), n_times)

If fit, the evoked response for each event type, concatenated.

__init__(nfilter=4, applyfilters=True, classes=None, estimator='scm', xdawn_estimator='scm', baseline_cov=None, **kwds)

Init.

fit(X, y)

Fit.

Estimate spatial filters and prototyped response for each classes.

Parameters
Xndarray, shape (n_matrices, n_channels, n_times)

Multi-channel time-series.

yndarray, shape (n_matrices,)

Labels for each matrix.

Returns
selfXdawnCovariances instance

The XdawnCovariances instance.

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
Xarray-like of shape (n_samples, n_features)

Input samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_paramsdict

Additional fit parameters.

Returns
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

get_params(deep=True)

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsdict

Parameter names mapped to their values.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters
**paramsdict

Estimator parameters.

Returns
selfestimator instance

Estimator instance.

transform(X)

Estimate Xdawn covariance matrices.

Parameters
Xndarray, shape (n_matrices, n_channels, n_times)

Multi-channel time-series.

Returns
covmatsndarray, shape (n_matrices, n_components, n_components)

Covariance matrices filtered by Xdawn, where n_components is equal to 2 x n_classes x min(n_channels, nfilter) if applyfilters is True, and to n_channels + n_classes x min(n_channels, nfilter) otherwise.