mne.decoding.XdawnTransformer#
- class mne.decoding.XdawnTransformer(n_components=2, reg=None, signal_cov=None, cov_method_params=None, *, restr_type=None, info=None, rank='full')[source]#
Implementation of the Xdawn Algorithm compatible with scikit-learn.
Xdawn is a spatial filtering method designed to improve the signal to signal + noise ratio (SSNR) of the event related 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 event related response.
Note
XdawnTransformer does not correct for epochs overlap. To correct overlaps see
Xdawn
.- Parameters:
- n_components
int
(default 2) The number of components to decompose the signals.
- reg
float
|str
|None
(defaultNone
) 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 tomethod
tomne.compute_covariance()
.- signal_cov
None
|Covariance
|array
, shape (n_channels, n_channels) The signal covariance used for whitening of the data. if None, the covariance is estimated from the epochs signal.
- cov_method_params
dict
|None
Parameters to pass to
mne.compute_covariance()
.New in v0.16.
- restr_type“restricting” | “whitening” |
None
Restricting transformation for covariance matrices before performing generalized eigendecomposition. If “restricting” only restriction to the principal subspace of signal_cov will be performed. If “whitening”, covariance matrices will be additionally rescaled according to the whitening for the signal_cov. If None, no restriction will be applied. Defaults to None.
New in v1.11.
- info
mne.Info
|None
The mne.Info object with information about the sensors and methods of measurement used for covariance estimation and generalized eigendecomposition. If None, one channel type and no projections will be assumed and if rank is dict, it will be sum of ranks per channel type. Defaults to None.
New in v1.11.
- rank
None
| ‘info’ | ‘full’ |dict
This controls the rank computation that can be read from the measurement info or estimated from the data. When a noise covariance is used for whitening, this should reflect the rank of that covariance, otherwise amplification of noise components can occur in whitening (e.g., often during source localization).
None
The rank will be estimated from the data after proper scaling of different channel types.
'info'
The rank is inferred from
info
. If data have been processed with Maxwell filtering, the Maxwell filtering header is used. Otherwise, the channel counts themselves are used. In both cases, the number of projectors is subtracted from the (effective) number of channels in the data. For example, if Maxwell filtering reduces the rank to 68, with two projectors the returned value will be 66.'full'
The rank is assumed to be full, i.e. equal to the number of good channels. If a
Covariance
is passed, this can make sense if it has been (possibly improperly) regularized without taking into account the true data rank.dict
Calculate the rank only for a subset of channel types, and explicitly specify the rank for the remaining channel types. This can be extremely useful if you already know the rank of (part of) your data, for instance in case you have calculated it earlier.
This parameter must be a dictionary whose keys correspond to channel types in the data (e.g.
'meg'
,'mag'
,'grad'
,'eeg'
), and whose values are integers representing the respective ranks. For example,{'mag': 90, 'eeg': 45}
will assume a rank of90
and45
for magnetometer data and EEG data, respectively.The ranks for all channel types present in the data, but not specified in the dictionary will be estimated empirically. That is, if you passed a dataset containing magnetometer, gradiometer, and EEG data together with the dictionary from the previous example, only the gradiometer rank would be determined, while the specified magnetometer and EEG ranks would be taken for granted.
The default is
'full'
.New in v1.11.
- n_components
- Attributes:
Methods
fit
(X[, y])Fit Xdawn spatial filters.
fit_transform
(X[, y])Fit to data, then transform it.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
Remove selected components from the signal.
set_output
(*[, transform])Set output container.
set_params
(**params)Set the parameters of this estimator.
transform
(X)Transform data with spatial filters.
- fit(X, y=None)[source]#
Fit Xdawn spatial filters.
- Parameters:
- Returns:
- self
Xdawn
instance The Xdawn instance.
- self
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.
- 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_params
dict
Additional fit parameters.
- Returns:
- get_metadata_routing()[source]#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routing
MetadataRequest
A
MetadataRequest
encapsulating routing information.
- routing
- inverse_transform(X)[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.
- set_output(*, transform=None)[source]#
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
andfit_transform
.“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
New in v1.4: “polars” option was added.
- Returns:
- self
estimator
instance Estimator instance.
- self