brainbox.modeling.neural_model

GLM fitting utilities based on NeuroGLM by Il Memming Park, Jonathan Pillow:

https://github.com/pillowlab/neuroGLM

Berk Gercek International Brain Lab, 2020

Classes

NeuralModel

Parent class for multiple types of neural models.

class NeuralModel(design_matrix, spk_times, spk_clu, binwidth=0.02, train=0.8, blocktrain=False, mintrials=100, stepwise=False)[source]

Bases: object

Parent class for multiple types of neural models. Contains core methods for extracting trial-relevant spike times and binning spikes, as well as making sure that the design matrix being used makes sense.

combine_weights()[source]

Combined fit coefficients and intercepts to produce kernels where appropriate, which describe activity.

Returns

DataFrame in which each row is the fit weights for a given spiking unit. Columns are individual covariates added during the construction process. Indices are the cluster IDs for each of the cells that were fit (NOT a simple range(start, stop) index.)

Return type

pandas.DataFrame

fit(printcond=True)[source]

Fit the current set of binned spikes as a function of the current design matrix. Requires NeuralGLM.bin_spike_trains and NeuralGLM.compile_design_matrix to be run first. Will store the fit weights to an internal variable. To access these fit weights in a pandas DataFrame use the NeuralGLM.combine_weights method.

Parameters

printcond (bool) – Whether or not to print the condition number of the design matrix. Defaults to True

Returns

  • coefs (list) – List of coefficients fit. Not recommended to use these for interpretation. Use the .combine_weights() method instead.

  • intercepts (list) – List of intercepts (bias terms) fit. Not recommended to use these for interpretation.

binf(t)[source]

Bin function for a given timestep. Returns the number of bins after trial start a given t would occur at.

Parameters

t (float) – Seconds after trial start

Returns

Number of bins corresponding to t using the binwidth of the model.

Return type

int