class_docstr: M/EEG signal decomposition using the Common Spatial Patterns (CSP).
  
  This class can be used as a supervised decomposition to estimate spatial
  filters for feature extraction. CSP in the context of EEG was first
  described in :footcite:`KolesEtAl1990`; a comprehensive tutorial on CSP can
  be found in :footcite:`BlankertzEtAl2008`. Multi-class solving is
  implemented from :footcite:`Grosse-WentrupBuss2008`.
  
  Parameters
  ----------
  n_components : int (default 4)
      The number of components to decompose M/EEG signals. This number should
      be set by cross-validation.
  reg : float | str | None (default None)
      If not None (same as ``'empirical'``, default), allow regularization
      for covariance estimation. If float (between 0 and 1), shrinkage is
      used. For str values, ``reg`` will be passed as ``method`` to
      :func:`mne.compute_covariance`.
  log : None | bool (default None)
      If ``transform_into`` equals ``'average_power'`` and ``log`` is None or
      True, then apply a log transform to standardize features, else features
      are z-scored. If ``transform_into`` is ``'csp_space'``, ``log`` must be
      None.
  cov_est : 'concat' | 'epoch' (default 'concat')
      If ``'concat'``, covariance matrices are estimated on concatenated
      epochs for each class. If ``'epoch'``, covariance matrices are
      estimated on each epoch separately and then averaged over each class.
  transform_into : 'average_power' | 'csp_space' (default 'average_power')
      If 'average_power' then ``self.transform`` will return the average
      power of each spatial filter. If ``'csp_space'``, ``self.transform``
      will return the data in CSP space.
  norm_trace : bool (default False)
      Normalize class covariance by its trace. Trace normalization is a step
      of the original CSP algorithm :footcite:`KolesEtAl1990` to eliminate
      magnitude variations in the EEG between individuals. It is not applied
      in more recent work :footcite:`BlankertzEtAl2008`,
      :footcite:`Grosse-WentrupBuss2008` and can have a negative impact on
      pattern order.
  cov_method_params : dict | None
      Parameters to pass to :func:`mne.compute_covariance`.
  
      .. versionadded:: 0.16
  %(rank_none)s
  
      .. versionadded:: 0.17
  component_order : 'mutual_info' | 'alternate' (default 'mutual_info')
      If ``'mutual_info'`` order components by decreasing mutual information
      (in the two-class case this uses a simplification which orders
      components by decreasing absolute deviation of the eigenvalues from 0.5
      :footcite:`BarachantEtAl2010`). For the two-class case, ``'alternate'``
      orders components by starting with the largest eigenvalue, followed by
      the smallest, the second-to-largest, the second-to-smallest, and so on
      :footcite:`BlankertzEtAl2008`.
  
      .. versionadded:: 0.21
  
  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.
  
  See Also
  --------
  mne.preprocessing.Xdawn, SPoC
  
  References
  ----------
  .. footbibliography::
class_docstr_tok: ["M\/EEG","signal","decomposition","using","the","Common","Spatial","Patterns","(","CSP",")",".","This","class","can","be","used","as","a","supervised","decomposition","to","estimate","spatial","filters","for","feature","extraction",".","CSP","in","the","context","of","EEG","was","first","described","in",":","footcite",":","`","KolesEtAl1990","`",";","a","comprehensive","tutorial","on","CSP","can","be","found","in",":","footcite",":","`","BlankertzEtAl2008","`",".","Multi-class","solving","is","implemented","from",":","footcite",":","`","Grosse-WentrupBuss2008","`",".","Parameters","--","--","--","--","--","n_components",":","int","(","default","4",")","The","number","of","components","to","decompose","M\/EEG","signals",".","This","number","should","be","set","by","cross-validation",".","reg",":","float","|","str","|","None","(","default","None",")","If","not","None","(","same","as","``","'empirical","'","``",",","default",")",",","allow","regularization","for","covariance","estimation",".","If","float","(","between","0","and","1",")",",","shrinkage","is","used",".","For","str","values",",","``","reg","``","will","be","passed","as","``","method","``","to",":","func",":","`","mne.compute_covariance","`",".","log",":","None","|","bool","(","default","None",")","If","``","transform_into","``","equals","``","'average_power","'","``","and","``","log","``","is","None","or","True",",","then","apply","a","log","transform","to","standardize","features",",","else","features","are","z-scored",".","If","``","transform_into","``","is","``","'csp_space","'","``",",","``","log","``","must","be","None",".","cov_est",":","'concat","'","|","'epoch","'","(","default","'concat","'",")","If","``","'concat","'","``",",","covariance","matrices","are","estimated","on","concatenated","epochs","for","each","class",".","If","``","'epoch","'","``",",","covariance","matrices","are","estimated","on","each","epoch","separately","and","then","averaged","over","each","class",".","transform_into",":","'average_power","'","|","'csp_space","'","(","default","'average_power","'",")","If","'average_power","'","then","``","self.transform","``","will","return","the","average","power","of","each","spatial","filter",".","If","``","'csp_space","'","``",",","``","self.transform","``","will","return","the","data","in","CSP","space",".","norm_trace",":","bool","(","default","False",")","Normalize","class","covariance","by","its","trace",".","Trace","normalization","is","a","step","of","the","original","CSP","algorithm",":","footcite",":","`","KolesEtAl1990","`","to","eliminate","magnitude","variations","in","the","EEG","between","individuals",".","It","is","not","applied","in","more","recent","work",":","footcite",":","`","BlankertzEtAl2008","`",",",":","footcite",":","`","Grosse-WentrupBuss2008","`","and","can","have","a","negative","impact","on","pattern","order",".","cov_method_params",":","dict","|","None","Parameters","to","pass","to",":","func",":","`","mne.compute_covariance","`",".","..","versionadded",":",":","0.16","%","(","rank_none",")","s","..","versionadded",":",":","0.17","component_order",":","'mutual_info","'","|","'alternate","'","(","default","'mutual_info","'",")","If","``","'mutual_info","'","``","order","components","by","decreasing","mutual","information","(","in","the","two-class","case","this","uses","a","simplification","which","orders","components","by","decreasing","absolute","deviation","of","the","eigenvalues","from","0.5",":","footcite",":","`","BarachantEtAl2010","`",")",".","For","the","two-class","case",",","``","'alternate","'","``","orders","components","by","starting","with","the","largest","eigenvalue",",","followed","by","the","smallest",",","the","second-to-largest",",","the","second-to-smallest",",","and","so","on",":","footcite",":","`","BlankertzEtAl2008","`",".","..","versionadded",":",":","0.21","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",".","See","Also","--","--","--","--","mne.preprocessing.Xdawn",",","SPoC","References","--","--","--","--","--","..","footbibliography",":",":"]
docstr: Estimate epochs sources given the CSP filters.
  
  Parameters
  ----------
  X : array, shape (n_epochs, n_channels, n_times)
      The data.
  
  Returns
  -------
  X : ndarray
      If self.transform_into == 'average_power' then returns the power of
      CSP features averaged over time and shape (n_epochs, n_sources)
      If self.transform_into == 'csp_space' then returns the data in CSP
      space and shape is (n_epochs, n_sources, n_times).
docstr_tok: ["Estimate","epochs","sources","given","the","CSP","filters",".","Parameters","--","--","--","--","--","X",":","array",",","shape","(","n_epochs",",","n_channels",",","n_times",")","The","data",".","Returns","--","--","--","-","X",":","ndarray","If","self.transform_into","==","'average_power","'","then","returns","the","power","of","CSP","features","averaged","over","time","and","shape","(","n_epochs",",","n_sources",")","If","self.transform_into","==","'csp_space","'","then","returns","the","data","in","CSP","space","and","shape","is","(","n_epochs",",","n_sources",",","n_times",")","."]
code: def transform(self, X):
      """Estimate epochs sources given the CSP filters.
  
      Parameters
      ----------
      X : array, shape (n_epochs, n_channels, n_times)
          The data.
  
      Returns
      -------
      X : ndarray
          If self.transform_into == 'average_power' then returns the power of
          CSP features averaged over time and shape (n_epochs, n_sources)
          If self.transform_into == 'csp_space' then returns the data in CSP
          space and shape is (n_epochs, n_sources, n_times).
      """
      if not isinstance(X, np.ndarray):
          raise ValueError(
              "X should be of type ndarray (got %s)." % type(X)
          )
      if self.filters_ is None:
          raise RuntimeError(
              "No filters available. Please first fit CSP "
              "decomposition."
          )
  
      pick_filters = self.filters_[: self.n_components]
      X = np.asarray([np.dot(pick_filters, epoch) for epoch in X])
  
      # compute features (mean band power)
      if self.transform_into == "average_power":
          X = (X**2).mean(axis=2)
          log = True if self.log is None else self.log
          if log:
              X = np.log(X)
          else:
              X -= self.mean_
              X /= self.std_
      return X
  
imports: import copy
  import numpy
  from scipy.linalg import eigh
  from ..cov import _regularized_covariance
  from ..defaults import _BORDER_DEFAULT, _EXTRAPOLATE_DEFAULT, _INTERPOLATION_DEFAULT
  from ..evoked import EvokedArray
  from ..fixes import pinv
  from ..utils import _check_option, _validate_type, copy_doc, fill_doc
  from .base import BaseEstimator
  from .mixin import TransformerMixin
label_desc: Use image node_id 4 for calling the CSP obj's underlying member method code with example usage: obj.transform(X) and returns: X