allensdk.model.glif.glif_neuron module

exception allensdk.model.glif.glif_neuron.GlifBadResetException(message, dv)[source]

Bases: exceptions.Exception

Exception raised when voltage is still above threshold after a reset rule is applied.

class allensdk.model.glif.glif_neuron.GlifNeuron(El, dt, asc_tau_array, R_input, C, asc_amp_array, spike_cut_length, th_inf, th_adapt, coeffs, AScurrent_dynamics_method, voltage_dynamics_method, threshold_dynamics_method, AScurrent_reset_method, voltage_reset_method, threshold_reset_method, init_voltage, init_threshold, init_AScurrents, **kwargs)[source]

Bases: object

Implements the current-based Mihalas Neiber GLIF neuron. Simulations model the voltage, threshold, and afterspike currents of a neuron given an input stimulus. A set of modular dynamics rules are applied until voltage crosses threshold, at which point a set of modular reset rules are applied. See glif_neuron_methods.py for a list of what options there are for voltage, threshold, and afterspike current dynamics and reset rules.

Parameters:
El : float

resting potential

dt : float

duration between time steps

asc_tau_array: np.ndarray

TODO

R_input : float

input resistance

C : float

capacitance

asc_amp_arrap : np.ndarray

afterspike current vector. one element per element of asc_tau_array.

spike_cut_length : int

how many time steps to replace with NaNs when a spike occurs.

th_inf : float

instantaneous threshold

coeffs : dict

dictionary coefficients premultiplied to neuron properties during simulation. used for optimization.

AScurrent_dynamics_method : dict

dictionary containing the ‘name’ of the afterspike current dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

voltage_dynamics_method : dict

dictionary containing the ‘name’ of the voltage dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

threshold_dynamics_method : dict

dictionary containing the ‘name’ of the threshold dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

AScurrent_reset_method : dict

dictionary containing the ‘name’ of the afterspike current dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

voltage_reset_method : dict

dictionary containing the ‘name’ of the voltage dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

threshold_reset_method : dict

dictionary containing the ‘name’ of the threshold dynamics method to use and a ‘params’ dictionary parameters to pass to that function.

init_voltage : float

initial voltage value

init_threshold : float

initial spike threshold value

init_AScurrents : np.ndarray

initial afterspike current vector. one element per element of asc_tau_array.

TYPE = 'GLIF'
append_threshold_components(spike, voltage)[source]
static configure_library_method(method_type, params)[source]

Create a GlifNeuronMethod instance out of a library of functions organized by type name. This refers to the METHOD_LIBRARY in glif_neuron_methods.py, which lays out the available functions that can be used for dynamics and reset rules.

Parameters:
method_type : string

the name of a function category (e.g. ‘AScurrent_dynamics_method’ for the afterspike current dynamics methods)

params : dict

a dictionary with two members. ‘name’: the string name of function you want, and ‘params’: parameters you want to pass to that function

Returns:
GlifNeuronMethod

a GlifNeuronMethod instance

static configure_method(method_name, method, method_params)[source]

Create a GlifNeuronMethod instance given a name, a function, and function parameters. This is just a shortcut to the GlifNeuronMethod constructor.

Parameters:
method_name : string

name for refering to this method later

method : function

a python function

method_parameters : dict

function arguments whose values should be fixed

Returns:
GlifNeuronMethod

a GlifNeuronMethod instance

dynamics(voltage_t0, threshold_t0, AScurrents_t0, inj, time_step, spike_time_steps)[source]

Update the voltage, threshold, and afterspike currents of the neuron for a single time step.

Parameters:
voltage_t0 : float

the current voltage of the neuron

threshold_t0 : float

the current spike threshold level of the neuron

AScurrents_t0 : np.ndarray

the current state of the afterspike currents in the neuron

inj : float

the current value of the current injection into the neuron

time_step : int

the current time step of the neuron simulation

spike_time_steps : list

a list of all of the time steps of spikes in the neuron

Returns:
tuple

voltage_t1 (voltage at next time step), threshold_t1 (threshold at next time step), AScurrents_t1 (afterspike currents at next time step)

classmethod from_dict(d)[source]
reset(voltage_t0, threshold_t0, AScurrents_t0)[source]

Apply reset rules to the neuron’s voltage, threshold, and afterspike currents assuming a spike has occurred (voltage is above threshold).

Parameters:
voltage_t0 : float

the current voltage of the neuron

threshold_t0 : float

the current spike threshold level of the neuron

AScurrents_t0 : np.ndarray

the current state of the afterspike currents in the neuron

Returns:
tuple

voltage_t1 (voltage at next time step), threshold_t1 (threshold at next time step), AScurrents_t1 (afterspike currents at next time step)

run(stim)[source]

Run neuron simulation over a given stimulus. This steps through the stimulus applying dynamics equations. After each step it checks if voltage is above threshold. If so, self.spike_cut_length NaNs are inserted into the output voltages, reset rules are applied to the voltage, threshold, and afterspike currents, and the simulation resumes.

Parameters:
stim : np.ndarray

vector of scalar current values

Returns:
dict
a dictionary containing:

‘voltage’: simulated voltage values, ‘threshold’: threshold values during the simulation, ‘AScurrents’: afterspike current values during the simulation, ‘grid_spike_times’: spike times (in uits of self.dt) aligned to simulation time steps, ‘interpolated_spike_times’: spike times (in units of self.dt) linearly interpolated between time steps, ‘spike_time_steps’: the indices of grid spike times, ‘interpolated_spike_voltage’: voltage of the simulation at interpolated spike times, ‘interpolated_spike_threshold’: threshold of the simulation at interpolated spike times

tau_m
to_dict()[source]

Convert the neuron to a serializable dictionary.

allensdk.model.glif.glif_neuron.interpolate_spike_time(dt, time_step, threshold_t0, threshold_t1, voltage_t0, voltage_t1)[source]

Given two voltage and threshold values, the dt between them and the initial time step, interpolate a spike time within the dt interval by intersecting the two lines.

allensdk.model.glif.glif_neuron.interpolate_spike_value(dt, interpolated_spike_time_offset, v0, v1)[source]

Take a value at two adjacent time steps and linearly interpolate what the value would be at an offset between the two time steps.

allensdk.model.glif.glif_neuron.line_crossing_x(dx, a0, a1, b0, b1)[source]

Find the x value of the intersection of two lines.

allensdk.model.glif.glif_neuron.line_crossing_y(dx, a0, a1, b0, b1)[source]

Find the y value of the intersection of two lines.