class_docstr: Fit a receptive field model.
  
  This allows you to fit an encoding model (stimulus to brain) or a decoding
  model (brain to stimulus) using time-lagged input features (for example, a
  spectro- or spatio-temporal receptive field, or STRF)
  :footcite:`TheunissenEtAl2001,WillmoreSmyth2003,CrosseEtAl2016,HoldgrafEtAl2016`.
  
  Parameters
  ----------
  tmin : float
      The starting lag, in seconds (or samples if ``sfreq`` == 1).
  tmax : float
      The ending lag, in seconds (or samples if ``sfreq`` == 1).
      Must be >= tmin.
  sfreq : float
      The sampling frequency used to convert times into samples.
  feature_names : array, shape (n_features,) | None
      Names for input features to the model. If None, feature names will
      be auto-generated from the shape of input data after running `fit`.
  estimator : instance of sklearn.base.BaseEstimator | float | None
      The model used in fitting inputs and outputs. This can be any
      scikit-learn-style model that contains a fit and predict method. If a
      float is passed, it will be interpreted as the ``alpha`` parameter
      to be passed to a Ridge regression model. If `None`, then a Ridge
      regression model with an alpha of 0 will be used.
  fit_intercept : bool | None
      If True (default), the sample mean is removed before fitting.
      If ``estimator`` is a :class:`sklearn.base.BaseEstimator`,
      this must be None or match ``estimator.fit_intercept``.
  scoring : ['r2', 'corrcoef']
      Defines how predictions will be scored. Currently must be one of
      'r2' (coefficient of determination) or 'corrcoef' (the correlation
      coefficient).
  patterns : bool
      If True, inverse coefficients will be computed upon fitting using the
      covariance matrix of the inputs, and the cross-covariance of the
      inputs/outputs, according to :footcite:`HaufeEtAl2014`. Defaults to
      False.
  n_jobs : int | str
      Number of jobs to run in parallel. Can be 'cuda' if CuPy
      is installed properly and ``estimator is None``.
  
      .. versionadded:: 0.18
  edge_correction : bool
      If True (default), correct the autocorrelation coefficients for
      non-zero delays for the fact that fewer samples are available.
      Disabling this speeds up performance at the cost of accuracy
      depending on the relationship between epoch length and model
      duration. Only used if ``estimator`` is float or None.
  
      .. versionadded:: 0.18
  %(verbose)s
  
  Attributes
  ----------
  coef_ : array, shape ([n_outputs, ]n_features, n_delays)
      The coefficients from the model fit, reshaped for easy visualization.
      During :meth:`mne.decoding.ReceptiveField.fit`, if ``y`` has one
      dimension (time), the ``n_outputs`` dimension here is omitted.
  patterns_ : array, shape ([n_outputs, ]n_features, n_delays)
      If fit, the inverted coefficients from the model.
  delays_ : array, shape (n_delays,), dtype int
      The delays used to fit the model, in indices. To return the delays
      in seconds, use ``self.delays_ / self.sfreq``
  valid_samples_ : slice
      The rows to keep during model fitting after removing rows with
      missing values due to time delaying. This can be used to get an
      output equivalent to using :func:`numpy.convolve` or
      :func:`numpy.correlate` with ``mode='valid'``.
  
  See Also
  --------
  mne.decoding.TimeDelayingRidge
  
  Notes
  -----
  For a causal system, the encoding model will have significant
  non-zero values only at positive lags. In other words, lags point
  backward in time relative to the input, so positive lags correspond
  to previous input time samples, while negative lags correspond to
  future input time samples.
  
  References
  ----------
  .. footbibliography::
class_docstr_tok: ["Fit","a","receptive","field","model",".","This","allows","you","to","fit","an","encoding","model","(","stimulus","to","brain",")","or","a","decoding","model","(","brain","to","stimulus",")","using","time-lagged","input","features","(","for","example",",","a","spectro-","or","spatio-temporal","receptive","field",",","or","STRF",")",":","footcite",":","`","TheunissenEtAl2001",",","WillmoreSmyth2003",",","CrosseEtAl2016",",","HoldgrafEtAl2016","`",".","Parameters","--","--","--","--","--","tmin",":","float","The","starting","lag",",","in","seconds","(","or","samples","if","``","sfreq","``","==","1",")",".","tmax",":","float","The","ending","lag",",","in","seconds","(","or","samples","if","``","sfreq","``","==","1",")",".","Must","be",">","=","tmin",".","sfreq",":","float","The","sampling","frequency","used","to","convert","times","into","samples",".","feature_names",":","array",",","shape","(","n_features",",",")","|","None","Names","for","input","features","to","the","model",".","If","None",",","feature","names","will","be","auto-generated","from","the","shape","of","input","data","after","running","`","fit","`",".","estimator",":","instance","of","sklearn.base.BaseEstimator","|","float","|","None","The","model","used","in","fitting","inputs","and","outputs",".","This","can","be","any","scikit-learn-style","model","that","contains","a","fit","and","predict","method",".","If","a","float","is","passed",",","it","will","be","interpreted","as","the","``","alpha","``","parameter","to","be","passed","to","a","Ridge","regression","model",".","If","`","None","`",",","then","a","Ridge","regression","model","with","an","alpha","of","0","will","be","used",".","fit_intercept",":","bool","|","None","If","True","(","default",")",",","the","sample","mean","is","removed","before","fitting",".","If","``","estimator","``","is","a",":","class",":","`","sklearn.base.BaseEstimator","`",",","this","must","be","None","or","match","``","estimator.fit_intercept","``",".","scoring",":","[","'r2","'",",","'corrcoef","'","]","Defines","how","predictions","will","be","scored",".","Currently","must","be","one","of","'r2","'","(","coefficient","of","determination",")","or","'corrcoef","'","(","the","correlation","coefficient",")",".","patterns",":","bool","If","True",",","inverse","coefficients","will","be","computed","upon","fitting","using","the","covariance","matrix","of","the","inputs",",","and","the","cross-covariance","of","the","inputs\/outputs",",","according","to",":","footcite",":","`","HaufeEtAl2014","`",".","Defaults","to","False",".","n_jobs",":","int","|","str","Number","of","jobs","to","run","in","parallel",".","Can","be","'cuda","'","if","CuPy","is","installed","properly","and","``","estimator","is","None","``",".","..","versionadded",":",":","0.18","edge_correction",":","bool","If","True","(","default",")",",","correct","the","autocorrelation","coefficients","for","non-zero","delays","for","the","fact","that","fewer","samples","are","available",".","Disabling","this","speeds","up","performance","at","the","cost","of","accuracy","depending","on","the","relationship","between","epoch","length","and","model","duration",".","Only","used","if","``","estimator","``","is","float","or","None",".","..","versionadded",":",":","0.18","%","(","verbose",")","s","Attributes","--","--","--","--","--","coef_",":","array",",","shape","(","[","n_outputs",",","]","n_features",",","n_delays",")","The","coefficients","from","the","model","fit",",","reshaped","for","easy","visualization",".","During",":","meth",":","`","mne.decoding.ReceptiveField.fit","`",",","if","``","y","``","has","one","dimension","(","time",")",",","the","``","n_outputs","``","dimension","here","is","omitted",".","patterns_",":","array",",","shape","(","[","n_outputs",",","]","n_features",",","n_delays",")","If","fit",",","the","inverted","coefficients","from","the","model",".","delays_",":","array",",","shape","(","n_delays",",",")",",","dtype","int","The","delays","used","to","fit","the","model",",","in","indices",".","To","return","the","delays","in","seconds",",","use","``","self.delays_","\/","self.sfreq","``","valid_samples_",":","slice","The","rows","to","keep","during","model","fitting","after","removing","rows","with","missing","values","due","to","time","delaying",".","This","can","be","used","to","get","an","output","equivalent","to","using",":","func",":","`","numpy.convolve","`","or",":","func",":","`","numpy.correlate","`","with","``","mode='valid","'","``",".","See","Also","--","--","--","--","mne.decoding.TimeDelayingRidge","Notes","--","--","-","For","a","causal","system",",","the","encoding","model","will","have","significant","non-zero","values","only","at","positive","lags",".","In","other","words",",","lags","point","backward","in","time","relative","to","the","input",",","so","positive","lags","correspond","to","previous","input","time","samples",",","while","negative","lags","correspond","to","future","input","time","samples",".","References","--","--","--","--","--","..","footbibliography",":",":"]
code: def _check_dimensions(self, X, y, predict=False):
      _validate_type(X, "array-like", "X")
      _validate_type(y, ("array-like", None), "y")
      X_dim = X.ndim
      y_dim = y.ndim if y is not None else 0
      if X_dim == 2:
          # Ensure we have a 3D input by adding singleton epochs dimension
          X = X[:, np.newaxis, :]
          if y is not None:
              if y_dim == 1:
                  y = y[:, np.newaxis, np.newaxis]  # epochs, outputs
              elif y_dim == 2:
                  y = y[:, np.newaxis, :]  # epochs
              else:
                  raise ValueError(
                      "y must be shape (n_times[, n_epochs][,n_outputs], got "
                      f"{y.shape}"
                  )
      elif X.ndim == 3:
          if y is not None:
              if y.ndim == 2:
                  y = y[:, :, np.newaxis]  # Add an outputs dim
              elif y.ndim != 3:
                  raise ValueError(
                      "If X has 3 dimensions, "
                      "y must have 2 or 3 dimensions"
                  )
      else:
          raise ValueError(
              f"X must be shape (n_times[, n_epochs], n_features), got {X.shape}"
          )
      if y is not None:
          if X.shape[0] != y.shape[0]:
              raise ValueError(
                  f"X and y do not have the same n_times\n{X.shape[0]} != "
                  f"{y.shape[0]}"
              )
          if X.shape[1] != y.shape[1]:
              raise ValueError(
                  f"X and y do not have the same n_epochs\n{X.shape[1]} != "
                  f"{y.shape[1]}"
              )
          if predict and y.shape[-1] != len(self.estimator_.coef_):
              raise ValueError(
                  "Number of outputs does not match estimator coefficients dimensions"
              )
      return X, y, X_dim, y_dim
  
imports: import numbers
  import numpy
  from scipy.stats import pearsonr
  from ..fixes import pinv
  from ..utils import _validate_type, fill_doc, verbose
  from .base import BaseEstimator, _check_estimator, get_coef
  from .time_delaying_ridge import TimeDelayingRidge
label_desc: Use image node_id 8 for calling the ReceptiveField obj's underlying member method code with example usage: obj._check_dimensions(X, y, predict) and returns: X,  y,  X_dim,  y_dim