class_docstr: Bilinear spatial filter.
  
  Bilinear spatial filter for SPD matrices allows to define a custom spatial
  filter for bilinear projection of the data:
  
  .. math::
      \mathbf{Cf}_i = \mathbf{V} \mathbf{C}_i \mathbf{V}^T
  
  If log parameter is set to true, will return the log of the diagonal:
  
  .. math::
      \mathbf{cf}_i = \log [ \mathrm{diag} (\mathbf{Cf}_i) ]
  
  Parameters
  ----------
  filters : ndarray, shape (n_filters, n_channels)
      The filters for bilinear transform.
  log : bool, default=False
      If true, return the log variance, otherwise return the spatially
      filtered covariance matrices.
  
  Attributes
  ----------
  filters_ : ndarray, shape (n_filters, n_channels)
      If fit, the filter components used to decompose the data for each event
      type, concatenated.
docstr: Apply spatial filters.
  
  Parameters
  ----------
  X : ndarray, shape (n_trials, n_channels, n_channels)
      Set of covariance matrices.
  
  Returns
  -------
  Xf : ndarray, shape (n_trials, n_filters) or                 ndarray, shape (n_trials, n_filters, n_filters)
      Set of spatialy filtered log-variance or covariance, depending on
      the 'log' input parameter.
docstr_tok: ["Apply","spatial","filters",".","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_trials",",","n_channels",",","n_channels",")","Set","of","covariance","matrices",".","Returns","--","--","--","-","Xf",":","ndarray",",","shape","(","n_trials",",","n_filters",")","or","ndarray",",","shape","(","n_trials",",","n_filters",",","n_filters",")","Set","of","spatialy","filtered","log-variance","or","covariance",",","depending","on","the","'log","'","input","parameter","."]
code: def transform(self, X):
      """Apply spatial filters.
  
          Parameters
          ----------
          X : ndarray, shape (n_trials, n_channels, n_channels)
              Set of covariance matrices.
  
          Returns
          -------
          Xf : ndarray, shape (n_trials, n_filters) or \
                  ndarray, shape (n_trials, n_filters, n_filters)
              Set of spatialy filtered log-variance or covariance, depending on
              the 'log' input parameter.
          """
      if not isinstance(X, (np.ndarray, list)):
          raise TypeError("X must be an array.")
      if X[0].shape[1] != self.filters_.shape[1]:
          raise ValueError(
              "Data and filters dimension must be compatible."
          )
  
      X_filt = self.filters_ @ X @ self.filters_.T
  
      # if logvariance
      if self.log:
          out = np.zeros(X_filt.shape[:2])
          for i, x in enumerate(X_filt):
              out[i] = np.log(np.diag(x))
          return out
      else:
          return X_filt
  
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 3 for calling the BilinearFilter obj's underlying member method code with example usage: obj.transform(X) and returns: out, X_filt