pyriemann.spatialfilters.Xdawn

class pyriemann.spatialfilters.Xdawn(nfilter=4, classes=None, estimator='scm', baseline_cov=None)

Xdawn algorithm.

Xdawn [1] is a spatial filtering method designed to improve the signal to signal + noise ratio (SSNR) of the ERP responses. Xdawn was originaly designed for P300 evoked potential by enhancing the target response with respect to the non-target response [2]. This implementation is a generalization to any type of ERP.

Parameters:
nfilterint, default=4

The number of components to decompose M/EEG signals.

classeslist of int | None, default=None

List of classes to take into account for Xdawn. If None, all classes will be accounted.

estimatorstring, default=”scm”

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

baseline_covNone | ndarray, shape(n_channels, n_channels), default=None

Covariance matrix to which the average signals are compared. If None, the baseline covariance is computed across all trials and time samples.

Attributes:
classes_ndarray, shape (n_classes,)

Labels for each class.

filters_ndarray, shape (n_classes x min(n_channels, n_filters), n_channels)

If fit, the Xdawn components used to decompose the data for each event type, concatenated.

patterns_ndarray, shape (n_classes x min(n_channels, n_filters), n_channels)

If fit, the Xdawn patterns used to restore M/EEG signals for each event type, concatenated.

evokeds_ndarray, shape (n_classes x min(n_channels, n_filters), n_times)

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

See also

XdawnCovariances

References

[1]

xDAWN algorithm to enhance evoked potentials: application to brain-computer interface B. Rivet, A. Souloumiac, V. Attina, and G. Gibert. IEEE Transactions on Biomedical Engineering, 2009, 56 (8), pp.2035-43.

[2]

Theoretical analysis of xDAWN algorithm: application to an efficient sensor selection in a P300 BCI B. Rivet, H. Cecotti, A. Souloumiac, E. Maby, J. Mattout. EUSIPCO 2011 19th European Signal Processing Conference, Aug 2011, Barcelone, Spain. pp.1382-1386.

__init__(nfilter=4, classes=None, estimator='scm', baseline_cov=None)

Init.

fit(X, y)

Train Xdawn spatial filters.

Parameters:
Xndarray, shape (n_trials, n_channels, n_times)

Set of trials.

yndarray, shape (n_trials,)

Labels for each trial.

Returns:
selfXdawn instance

The Xdawn instance.

fit_transform(X, y=None, sample_weight=None)

Fit and transform in a single function.

Parameters:
Xndarray, shape (n_trials, n_channels, n_times)

Set of trials.

yndarray, shape (n_trials,)

Labels for each trial.

Returns:
X_newndarray, shape (n_trials, n_classes x min(n_channels, n_filters), n_times)

Set of spatially filtered trials.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

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_output(*, transform=None)

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

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)

Apply spatial filters.

Parameters:
Xndarray, shape (n_trials, n_channels, n_times)

Set of trials.

Returns:
X_newndarray, shape (n_trials, n_classes x min(n_channels, n_filters), n_times)

Set of spatially filtered trials.