mne.decoding.ReceptiveField#
- class mne.decoding.ReceptiveField(tmin, tmax, sfreq, feature_names=None, estimator=None, fit_intercept=None, scoring='r2', patterns=False, n_jobs=None, edge_correction=True)[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) [1][2][3][4]. - Parameters:
- tminfloat
- The starting lag, in seconds (or samples if - sfreq== 1).
- tmaxfloat
- The ending lag, in seconds (or samples if - sfreq== 1). Must be >= tmin.
- sfreqfloat
- 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 - alphaparameter 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 - estimatoris 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). 
- patternsbool
- 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 [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 v0.18. 
- edge_correctionbool
- 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 - estimatoris float or None.- New in v0.18. 
 
- tmin
- Attributes:
- coef_array, shape ([n_outputs, ]n_features, n_delays)
- The coefficients from the model fit, reshaped for easy visualization. During - mne.decoding.ReceptiveField.fit(), if- yhas one dimension (time), the- n_outputsdimension 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,), dtypeint
- 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 - numpy.convolve()or- numpy.correlate()with- mode='valid'.
 
 - Methods - fit(X, y)- Fit a receptive field model. - Get metadata routing of this object. - get_params([deep])- Get parameters for this estimator. - predict(X)- Generate predictions with a receptive field. - score(X, y)- Score predictions generated with a receptive field. - set_params(**params)- Set the parameters of this estimator. - See also - 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 - fit(X, y)[source]#
- Fit a receptive field model. - Parameters:
- Returns:
- selfinstance
- The instance so you can chain operations. 
 
 - Examples using - fit:  - Spectro-temporal receptive field (STRF) estimation on continuous data Spectro-temporal receptive field (STRF) estimation on continuous data
 - get_metadata_routing()[source]#
- Get metadata routing of this object. - Please check User Guide on how the routing mechanism works. - Returns:
- routingMetadataRequest
- A - MetadataRequestencapsulating routing information.
 
- routing
 
 - predict(X)[source]#
- Generate predictions with a receptive field. - Parameters:
- Xarray, shape (n_times[, n_epochs], n_channels)
- The input features for the model. 
 
- X
- Returns:
- 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_].
 
- y_pred
 - Examples using - predict:  - Spectro-temporal receptive field (STRF) estimation on continuous data Spectro-temporal receptive field (STRF) estimation on continuous data
 - score(X, y)[source]#
- Score predictions generated with a receptive field. - This calls - self.predict, then masks the output of this and- y` with ``self.valid_samples_. Finally, it passes this to a- sklearn.metricsscorer.- Parameters:
- Returns:
 - Examples using - score:  - Spectro-temporal receptive field (STRF) estimation on continuous data Spectro-temporal receptive field (STRF) estimation on continuous data
 
Examples using mne.decoding.ReceptiveField#
 
Spectro-temporal receptive field (STRF) estimation on continuous data
