class mne.preprocessing.Xdawn(n_components=2, signal_cov=None, correct_overlap='auto', reg=None)[source]

Implementation of the Xdawn Algorithm.

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

n_componentsint, (default 2)

The number of components to decompose the signals.

signal_covNone | Covariance | ndarray, shape (n_channels, n_channels)

(default None). The signal covariance used for whitening of the data. if None, the covariance is estimated from the epochs signal.

correct_overlap‘auto’ or bool (default ‘auto’)

Compute the independent evoked responses per condition, while correcting for event overlaps if any. If ‘auto’, then overlapp_correction = True if the events do overlap.

regfloat | str | None (default None)

If not None (same as 'empirical', default), allow regularization for covariance estimation. If float, shrinkage is used (0 <= shrinkage <= 1). For str options, reg will be passed as method to mne.compute_covariance().


New in version 0.10.



Bertrand Rivet, Antoine Souloumiac, Virginie Attina, and Guillaume Gibert. xDAWN algorithm to enhance evoked potentials: application to brain–computer interface. IEEE Transactions on Biomedical Engineering, 56(8):2035–2043, 2009. doi:10.1109/TBME.2009.2012869.


Bertrand Rivet, Hubert Cecotti, Antoine Souloumiac, Emmanuel Maby, and Jérémie Mattout. Theoretical analysis of xDAWN algorithm: application to an efficient sensor selection in a P300 BCI. In Proceedings of EUSIPCO-2011, 1382–1386. Barcelona, 2011. IEEE. URL:

filters_dict of ndarray

If fit, the Xdawn components used to decompose the data for each event type, else empty. For each event type, the filters are in the rows of the corresponding array.

patterns_dict of ndarray

If fit, the Xdawn patterns used to restore the signals for each event type, else empty.

evokeds_dict of Evoked

If fit, the evoked response for each event type.


The event id.


Whether overlap correction was applied.



Return hash(self).

apply(inst[, event_id, include, exclude])

Remove selected components from the signal.

fit(epochs[, y])

Fit Xdawn from epochs.

fit_transform(X[, y])

Fit to data, then transform it.


Get parameters for this estimator.


Not implemented, see Xdawn.apply() instead.


Set the parameters of this estimator.


Apply Xdawn dim reduction.

apply(inst, event_id=None, include=None, exclude=None)[source]

Remove selected components from the signal.

Given the unmixing matrix, transform data, zero out components, and inverse transform the data. This procedure will reconstruct the signals from which the dynamics described by the excluded components is subtracted.

instinstance of Raw | Epochs | Evoked

The data to be processed.

event_iddict | list of str | None (default None)

The kind of event to apply. if None, a dict of inst will be return one for each type of event xdawn has been fitted.

includearray_like of int | None (default None)

The indices referring to columns in the ummixing matrix. The components to be kept. If None, the first n_components (as defined in the Xdawn constructor) will be kept.

excludearray_like of int | None (default None)

The indices referring to columns in the ummixing matrix. The components to be zeroed out. If None, all the components except the first n_components will be exclude.


A dict of instance (from the same type as inst input) for each event type in event_id.

Examples using apply:

fit(epochs, y=None)[source]

Fit Xdawn from epochs.

epochsinstance of Epochs

An instance of Epoch on which Xdawn filters will be fitted.

yndarray | None (default None)

If None, used[:, 2].

selfinstance of Xdawn

The Xdawn instance.

Examples using fit:

fit_transform(X, y=None, **fit_params)[source]

Fit to data, then transform it.

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

Xarray, shape (n_samples, n_features)

Training set.

yarray, shape (n_samples,)

Target values.


Additional fitting parameters passed to

X_newarray, shape (n_samples, n_features_new)

Transformed array.


Get parameters for this estimator.

deepbool, optional

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


Parameter names mapped to their values.


Not implemented, see Xdawn.apply() instead.


Set the parameters of this estimator.

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




The object.


Apply Xdawn dim reduction.

instEpochs | Evoked | ndarray, shape ([n_epochs, ]n_channels, n_times)

Data on which Xdawn filters will be applied.

Xndarray, shape ([n_epochs, ]n_components * n_event_types, n_times)

Spatially filtered signals.