mne.preprocessing.Xdawn

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

Implementation of the Xdawn Algorithm.

Xdawn 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.

Parameters:

n_components : int (default 2)

The number of components to decompose M/EEG signals.

signal_cov : None | 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’)

Apply correction for overlaped ERP for the estimation of evokeds responses. if ‘auto’, the overlapp correction is chosen in function of the events in epochs.events.

reg : float | str | None (default None)

if not None, allow regularization for covariance estimation if float, shrinkage covariance is used (0 <= shrinkage <= 1). if str, optimal shrinkage using Ledoit-Wolf Shrinkage (‘ledoit_wolf’) or Oracle Approximating Shrinkage (‘oas’).

Attributes:

filters_ : dict of ndarray

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

patterns_ : dict of ndarray

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

evokeds_ : dict of evoked instance

If fit, the evoked response for each event type.

See also

ICA, CSP

Notes

New in version 0.10.

References

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

[2] Rivet, B., Cecotti, H., Souloumiac, A., Maby, E., & Mattout, J. (2011, August). Theoretical analysis of xDAWN algorithm: application to an efficient sensor selection in a P300 BCI. In Signal Processing Conference, 2011 19th European (pp. 1382-1386). IEEE.

Methods

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
transform(epochs) Apply Xdawn dim reduction.
__init__(n_components=2, signal_cov=None, correct_overlap='auto', reg=None)

init xdawn.

apply(inst, event_id=None, include=None, exclude=None)

Remove selected components from the signal.

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

Parameters:

inst : instance of Raw | Epochs | Evoked

The data to be processed.

event_id : dict | 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.

include : array_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.

exclude : array_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.

Returns:

out : dict of instance

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

fit(epochs, y=None)

Fit Xdawn from epochs.

Parameters:

epochs : Epochs object

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

y : ndarray | None (default None)

Not used, here for compatibility with decoding API.

Returns:

self : Xdawn instance

The Xdawn 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:

X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

Returns:

X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

transform(epochs)

Apply Xdawn dim reduction.

Parameters:

epochs : Epochs | ndarray, shape (n_epochs, n_channels, n_times)

Data on which Xdawn filters will be applied.

Returns:

X : ndarray, shape (n_epochs, n_components * event_types, n_times)

Spatially filtered signals.