mne.decoding.
CSP
(n_components=4, reg=None, log=None, cov_est=’concat’, transform_into=’average_power’)[source]¶M/EEG signal decomposition using the Common Spatial Patterns (CSP).
This object can be used as a supervised decomposition to estimate spatial filters for feature extraction in a 2 class decoding problem. CSP in the context of EEG was first described in [1]; a comprehensive tutorial on CSP can be found in [2]. Multiclass solving is implemented from [3].
Parameters:  n_components : int, defaults to 4
reg : float  str  None, defaults to None
log : None  bool, defaults to None
cov_est : ‘concat’  ‘epoch’, defaults to ‘concat’
transform_into : {‘average_power’, ‘csp_space’}


References
Attributes
filters_ 
(ndarray, shape (n_channels, n_channels)) If fit, the CSP components used to decompose the data, else None. 
patterns_ 
(ndarray, shape (n_channels, n_channels)) If fit, the CSP patterns used to restore M/EEG signals, else None. 
mean_ 
(ndarray, shape (n_components,)) If fit, the mean squared power for each component. 
std_ 
(ndarray, shape (n_components,)) If fit, the std squared power for each component. 
Methods
__hash__ () <==> hash(x) 

fit (X, y) 
Estimate the CSP decomposition on epochs. 
fit_transform (X[, y]) 
Fit to data, then transform it. 
get_params ([deep]) 
Get parameters for this estimator. 
plot_filters (info[, components, ch_type, …]) 
Plot topographic filters of CSP components. 
plot_patterns (info[, components, ch_type, …]) 
Plot topographic patterns of CSP components. 
set_params (**params) 
Set the parameters of this estimator. 
transform (X) 
Estimate epochs sources given the CSP filters. 
__hash__
() <==> hash(x)¶fit
(X, y)[source]¶Estimate the CSP decomposition on epochs.
Parameters:  X : ndarray, shape (n_epochs, n_channels, n_times)
y : array, shape (n_epochs,)


Returns:  self : instance of CSP

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:  X : numpy array of shape [n_samples, n_features]
y : numpy array of shape [n_samples]


Returns:  X_new : numpy array of shape [n_samples, n_features_new]

get_params
(deep=True)[source]¶Get parameters for this estimator.
Parameters:  deep : boolean, optional


Returns:  params : mapping of string to any

plot_filters
(info, components=None, ch_type=None, layout=None, vmin=None, vmax=None, cmap=’RdBu_r’, sensors=True, colorbar=True, scale=None, scale_time=1, unit=None, res=64, size=1, cbar_fmt=’%3.1f’, name_format=’CSP%01d’, proj=False, show=True, show_names=False, title=None, mask=None, mask_params=None, outlines=’head’, contours=6, image_interp=’bilinear’, average=None, head_pos=None)[source]¶Plot topographic filters of CSP components.
The CSP filters are used to extract discriminant neural sources from the measured data (a.k.a. the backward model).
Parameters:  info : instance of Info
components : float  array of floats  None.
ch_type : ‘mag’  ‘grad’  ‘planar1’  ‘planar2’  ‘eeg’  None
layout : None  Layout
vmin : float  callable
vmax : float  callable
cmap : matplotlib colormap  (colormap, bool)  ‘interactive’  None
sensors : bool  str
colorbar : bool
scale : dict  float  None
scale_time : float  None
unit : dict  str  None
res : int
size : float
cbar_fmt : str
name_format : str
proj : bool  ‘interactive’
show : bool
show_names : bool  callable
title : str  None
mask : ndarray of bool, shape (n_channels, n_times)  None
mask_params : dict  None
outlines : ‘head’  ‘skirt’  dict  None
contours : int  False  None
image_interp : str
average : float  None
head_pos : dict  None


Returns:  fig : instance of matplotlib.figure.Figure

plot_patterns
(info, components=None, ch_type=None, layout=None, vmin=None, vmax=None, cmap=’RdBu_r’, sensors=True, colorbar=True, scale=None, scale_time=1, unit=None, res=64, size=1, cbar_fmt=’%3.1f’, name_format=’CSP%01d’, proj=False, show=True, show_names=False, title=None, mask=None, mask_params=None, outlines=’head’, contours=6, image_interp=’bilinear’, average=None, head_pos=None)[source]¶Plot topographic patterns of CSP components.
The CSP patterns explain how the measured data was generated from the neural sources (a.k.a. the forward model).
Parameters:  info : instance of Info
components : float  array of floats  None.
ch_type : ‘mag’  ‘grad’  ‘planar1’  ‘planar2’  ‘eeg’  None
layout : None  Layout
vmin : float  callable
vmax : float  callable
cmap : matplotlib colormap  (colormap, bool)  ‘interactive’  None
sensors : bool  str
colorbar : bool
scale : dict  float  None
scale_time : float  None
unit : dict  str  None
res : int
size : float
cbar_fmt : str
name_format : str
proj : bool  ‘interactive’
show : bool
show_names : bool  callable
title : str  None
mask : ndarray of bool, shape (n_channels, n_times)  None
mask_params : dict  None
outlines : ‘head’  ‘skirt’  dict  None
contours : int  False  None
image_interp : str
average : float  None
head_pos : dict  None


Returns:  fig : instance of matplotlib.figure.Figure

set_params
(**params)[source]¶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.
Returns
——
self
transform
(X)[source]¶Estimate epochs sources given the CSP filters.
Parameters:  X : array, shape (n_epochs, n_channels, n_times)


Returns:  X : ndarray
