brainiak.reconstruct package¶

Inverted encoding model for recreating continuous representations.

brainiak.reconstruct.iem module¶

Inverted Encoding Model (IEM)

Method to decode and reconstruct features from data.

The implementation is roughly based on the following publications:

[Kok2013] “1.Kok, P., Brouwer, G. J., Gerven, M. A. J. van & Lange, F. P. de. Prior Expectations Bias Sensory Representations in Visual Cortex. J. Neurosci. 33, 16275–16284 (2013).

[Brouwer2011] “2.Brouwer, G. J. & Heeger, D. J. Cross-orientation suppression in human visual cortex. J. Neurophysiol. 106(5): 2108-2119 (2011).

[Brouwer2009] “3.Brouwer, G. J. & Heeger, D. J. Decoding and Reconstructing Color from Responses in Human Visual Cortex. J. Neurosci. 29, 13992–14003 (2009).

This implementation uses a set of sinusoidal basis functions to represent the set of possible feature values. A feature value is some characteristic of a stimulus, e.g. the angular location of a target along a horizontal line. This code was written to give some flexibility compared to the specific instances in Kok, 2013 & in Brouwer, 2009. Users can set the number of basis functions, or channels, and the range of possible feature values.

class brainiak.reconstruct.iem.InvertedEncoding(n_channels=6, channel_exp=5, stimulus_mode='halfcircular', range_start=0.0, range_stop=180.0, channel_density=180, stimulus_resolution=None)

Bases: sklearn.base.BaseEstimator

Basis function-based reconstruction method

Inverted encoding models (alternatively known as forward models) are used to reconstruct a feature, e.g. color of a stimulus, from patterns across voxels in functional data. The model uses n_channels number of idealized basis functions and assumes that the transformation from stimulus feature (e.g. color) to basis function is one- to-one and invertible. The response of a voxel is expressed as the weighted sum of basis functions. In this implementation, basis functions were half-wave rectified sinusoid functions raised to a power set by the user (e.g. 6).

The model: Inverted encoding models reconstruct a stimulus feature from patterns of BOLD activity by relating the activity in each voxel, B, to the values of hypothetical channels (or basis functions), C, according to Equation 1 below.

1. B = W*C

where W is a weight matrix that represents the relationship between BOLD activity and Channels. W must be estimated from training data; this implementation (and most described in the literature) uses linear regression to estimate W as in Equation 2 below [note: inv() represents matrix inverse or pseudo-inverse].

1. W_est = B_train*inv(C_train)

The weights in W_est (short for “estimated”) represent the contributions of each channel to the response of each voxel. Estimated channel responses can be computed given W_est and new voxel activity represented in matrix B_exp (short for “experiment”) through inversion of Equation 1:

1. C_est = inv(W_est)*B_exp

Given estimated channel responses, C_est, it is straighforward to obtain the reconstructed feature value by summing over channels multiplied by their channel responses and taking the argmax (i.e. the feature associated with the maximum value).

Using this model: Use fit() to estimate the weights of the basis functions given input data (e.g. beta values from fMRI data). This function will execute equation 2 above.

Use predict() to compute predicted stimulus values from new functional data. This function computes estimated channel responses, as in equation 3, then computes summed channel output and finds the argmax (within the stimulus feature space) associated with those responses.

Use score() to compute a measure of the error of the prediction based on known stimuli.

This implementation assumes a circular (or half- circular) feature domain. Future implementations might generalize the feature input space, and increase the possible dimensionality.

Parameters
• n_channels (int, default 5. Number of channels) – The number of channels, or basis functions, to be used in the inverted encoding model.

• channel_exp (int, default 6. Basis function exponent.) – The exponent of the sinuoidal basis functions, which establishes the width of the functions.

• stimulus_mode (str, default 'halfcircular' (other option is) – ‘circular’). Describes the feature domain.

• range_start (double, default 0. Lowest value of domain.) – Beginning value of range of independent variable (usually degrees).

• range_stop (double, default 180. Highest value of domain.) – Ending value of range of independent variable (usually degrees).

• channel_density (int, default 180. Number of points in the) – feature domain.

• stimulus_resolution (double, default None will set the stimulus) – resolution to be identical to the channel density. This sets the resolution at which the stimuli were presented (e.g. a spatial position with some width has a lower stimulus resolution).

channels_

matrix defining channel values

Type

[n_channels, channel density] NumPy 2D array

W_

relates estimated channel responses to response amplitude data

Type

sklearn.linear_model model containing weight matrix that

fit(X, y)

Use data and feature variable labels to fit an IEM

Parameters
• X (numpy matrix of voxel activation data. [observations, voxels]) – Should contain the beta values for each observation or trial and each voxel of training data.

• y (numpy array of response variable. [observations]) – Should contain the feature for each observation in X.

get_params()

Returns model parameters.

Returns

params

Return type

parameter of this object

predict(X)

Use test data to predict the feature

Parameters
• X (numpy matrix of voxel activation from test trials) –

• voxels] Used to predict feature ([observations,) –

• with the given observation. (associated) –

Returns

model_prediction

Return type

numpy array of estimated feature values.

score(X, y)

Calculate error measure of prediction. Default measurement is R^2, the coefficient of determination.

Parameters
• X (numpy matrix of voxel activation from new data) – [observations,voxels]

• y (numpy array of responses. [observations]) –

Returns

score_value – feature and predicted features.

Return type

the error measurement between the actual

set_params(**parameters)

Sets model parameters after initialization.

Parameters

parameters (structure with parameters and change values) –