class mne.decoding.ReceptiveField(tmin, tmax, sfreq, feature_names=None, estimator=None, fit_intercept=None, scoring='r2', patterns=False, n_jobs=1, edge_correction=True, verbose=None)[source]

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).


The starting lag, in seconds (or samples if sfreq == 1).


The ending lag, in seconds (or samples if sfreq == 1). Must be >= tmin.


The sampling frequency used to convert times into samples.

feature_namesarray, 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.

estimatorinstance 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_interceptbool | None

If True (default), the sample mean is removed before fitting. If estimator is a 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).


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 [Re894fafbc0df-5]. Defaults to False.

n_jobsint | str

Number of jobs to run in parallel. Can be ‘cuda’ if CuPy is installed properly and estimator is None.

New in version 0.18.


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.

New in version 0.18.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).


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.



Theunissen, F. E. et al. Estimating spatio-temporal receptive fields of auditory and visual neurons from their responses to natural stimuli. Network 12, 289-316 (2001).


Willmore, B. & Smyth, D. Methods for first-order kernel estimation: simple-cell receptive fields from responses to natural scenes. Network 14, 553-77 (2003).


Crosse, M. J., Di Liberto, G. M., Bednar, A. & Lalor, E. C. (2016). The Multivariate Temporal Response Function (mTRF) Toolbox: A MATLAB Toolbox for Relating Neural Signals to Continuous Stimuli. Frontiers in Human Neuroscience 10, 604. doi:10.3389/fnhum.2016.00604


Holdgraf, C. R. et al. Rapid tuning shifts in human auditory cortex enhance speech intelligibility. Nature Communications, 7, 13654 (2016). doi:10.1038/ncomms13654


Haufe, S., Meinecke, F., Goergen, K., Daehne, S., Haynes, J.-D., Blankertz, B., & Biessmann, F. (2014). On the interpretation of weight vectors of linear models in multivariate neuroimaging. NeuroImage, 87, 96-110. doi:10.1016/j.neuroimage.2013.10.067



(array, shape ([n_outputs, ]n_features, n_delays)) The coefficients from the model fit, reshaped for easy visualization. During, if y has one dimension (time), the n_outputs dimension here is omitted.


(array, shape ([n_outputs, ]n_features, n_delays)) If fit, the inverted coefficients from the model.


(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


(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 numpy.convolve() or numpy.correlate() with mode='valid'.


__hash__(self, /)

Return hash(self).

fit(self, X, y)

Fit a receptive field model.

get_params(self[, deep])

Get parameters for this estimator.

predict(self, X)

Generate predictions with a receptive field.

score(self, X, y)

Score predictions generated with a receptive field.

set_params(self, \*\*params)

Set the parameters of this estimator.

__hash__(self, /)

Return hash(self).

fit(self, X, y)[source]

Fit a receptive field model.

Xarray, shape (n_times[, n_epochs], n_features)

The input features for the model.

yarray, shape (n_times[, n_epochs][, n_outputs])

The output features for the model.


The instance so you can chain operations.

get_params(self, deep=True)[source]

Get parameters for this estimator.

deepbool, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

paramsmapping of str to any

Parameter names mapped to their values.

predict(self, X)[source]

Generate predictions with a receptive field.

Xarray, shape (n_times[, n_epochs], n_channels)

The input features for the model.

y_predarray, shape (n_times[, n_epochs][, n_outputs])

The output predictions. “Note that valid samples (those unaffected by edge artifacts during the time delaying step) can be obtained using y_pred[rf.valid_samples_].

score(self, X, y)[source]

Score predictions generated with a receptive field.

This calls self.predict, then masks the output of this and y` with ``self.mask_prediction_. Finally, it passes this to a sklearn.metrics scorer.

Xarray, shape (n_times[, n_epochs], n_channels)

The input features for the model.

yarray, shape (n_times[, n_epochs][, n_outputs])

Used for scikit-learn compatibility.

scoreslist of float, shape (n_outputs,)

The scores estimated by the model for each output (e.g. mean R2 of predict(X)).

set_params(self, **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