class_docstr: SPoC spatial filtering with covariance matrices as inputs.
  
  Source Power Comodulation (SPoC) [1]_ allows to extract spatial filters and
  patterns by using a target (continuous) variable in the decomposition
  process in order to give preference to components whose power comodulates
  with the target variable.
  
  SPoC can be seen as an extension of the
  :class:`pyriemann.spatialfilters.CSP` driven by a continuous
  variable rather than a discrete (often binary) variable. Typical
  applications include extraction of motor patterns using EMG power or audio
  paterns using sound envelope.
  
  Parameters
  ----------
  nfilter : int, default=4
      The number of components to decompose M/EEG signals.
  metric : str, default='euclid'
      The metric for the estimation of mean covariance matrices.
  log : bool, default=True
      If true, return the log variance, otherwise return the spatially
      filtered covariance matrices.
  
  Attributes
  ----------
  filters_ : ndarray, shape (min(n_channels, n_filters), n_channels)
      If fit, the SPoC spatial filters.
  patterns_ : ndarray, shape (min(n_channels, n_filters), n_channels)
      If fit, the SPoC spatial patterns.
  
  Notes
  -----
  .. versionadded:: 0.2.4
  
  See Also
  --------
  CSP
  
  References
  ----------
  .. [1] `SPoC: a novel framework for relating the amplitude of neuronal
      oscillations to behaviorally relevant parameters
      <https://www.sciencedirect.com/science/article/pii/S1053811913008483>`_
      S. Dahne, F. C. Meinecke, S. Haufe, J. Hohne, M. Tangermann, K-R.
      Muller, and V. V. Nikulin. NeuroImage, 86, 111-122, 2014.
docstr: Train spatial filters.
  
  Parameters
  ----------
  X : ndarray, shape (n_trials, n_channels, n_channels)
      Set of covariance matrices.
  y : ndarray, shape (n_trials,)
      Target variable for each trial.
  
  Returns
  -------
  self : SPoC instance
      The SPoC instance.
docstr_tok: ["Train","spatial","filters",".","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_trials",",","n_channels",",","n_channels",")","Set","of","covariance","matrices",".","y",":","ndarray",",","shape","(","n_trials",",",")","Target","variable","for","each","trial",".","Returns","--","--","--","-","self",":","SPoC","instance","The","SPoC","instance","."]
code: def fit(self, X, y):
      """Train spatial filters.
  
      Parameters
      ----------
      X : ndarray, shape (n_trials, n_channels, n_channels)
          Set of covariance matrices.
      y : ndarray, shape (n_trials,)
          Target variable for each trial.
  
      Returns
      -------
      self : SPoC instance
          The SPoC instance.
      """
  
      # Normalize target variable
      target = np.float64(y.copy())
      target -= target.mean()
      target /= target.std()
  
      C = mean_covariance(X, self.metric)
      Ce = np.zeros_like(X)
      for i in range(Ce.shape[0]):
          Ce[i] = X[i] * target[i]
      Cz = mean_covariance(Ce, self.metric)
  
      # solve eigenvalue decomposition
      evals, evecs = eigh(Cz, C)
      evals = evals.real
      evecs = evecs.real
      # sort vectors
      ix = np.argsort(np.abs(evals))[::-1]
  
      # sort eigenvectors
      evecs = evecs[:, ix]
  
      # spatial patterns
      A = np.linalg.pinv(evecs.T)
  
      self.filters_ = evecs[:, 0 : self.nfilter].T
      self.patterns_ = A[:, 0 : self.nfilter].T
  
      return self
  
imports: import warnings
  import numpy
  from scipy.linalg import eigh, inv
  from sklearn.base import BaseEstimator, TransformerMixin
  from .utils.covariance import _check_cov_est_function, normalize, get_nondiag_weight
  from .utils.mean import mean_covariance
  from .utils.ajd import ajd_pham
  from .None import estimation
  from .preprocessing import Whitening
label_desc: Use image node_id 1 for calling the SPoC obj's underlying member method code with example usage: obj.fit(X, y) and returns: self