allensdk.model.glif.glif_neuron_methods module¶
The methods in this module are used for configuring dynamics and reset rules for the GlifNeuron. For more details on how to use these methods, see Generalized LIF Models.
-
class
allensdk.model.glif.glif_neuron_methods.
GlifNeuronMethod
(method_name, method, method_params)[source]¶ Bases:
object
A simple class to keep track of the name and parameters associated with a neuron method. This class is initialized with a name, function, and parameters to pass to the function. The function then has those passed parameters fixed to a partial function using functools.partial. This class then mimics a function itself using the __call__ convention. Parameters that are not fixed in this way are assumed to be passed into the method when it is called. If the passed parameters contain an argument that is not part of the function signature, an exception will be raised.
Parameters: - method_name : string
A shorthand name that will be used to reference this method in the GlifNeuron.
- method : function
A python function to be called when this instance is called.
- method_params : dict
A dictionary mapping function arguments to values for values that should be fixed.
-
modify_parameter
(param, operator)[source]¶ Modify a function parameter needs to be modified after initialization.
Parameters: - param : string
the name of the parameter to modify
- operator : callable
a function or lambda that returns the desired modified value
Returns: - type
the new value of the variable that was just modified.
-
allensdk.model.glif.glif_neuron_methods.
dynamics_AScurrent_exp
(neuron, AScurrents_t0, time_step, spike_time_steps)[source]¶ Exponential afterspike current dynamics method takes a current at t0 and returns the current at a time step later.
-
allensdk.model.glif.glif_neuron_methods.
dynamics_AScurrent_none
(neuron, AScurrents_t0, time_step, spike_time_steps)[source]¶ This method always returns zeros for the afterspike currents, regardless of input.
-
allensdk.model.glif.glif_neuron_methods.
dynamics_threshold_inf
(neuron, threshold_t0, voltage_t0, AScurrents_t0, inj)[source]¶ Set threshold to the neuron’s instantaneous threshold.
Parameters: - neuron : class
- threshold_t0 : not used here
- voltage_t0 : not used here
- AScurrents_t0 : not used here
- inj : not used here
- AScurrents_t0 : not used here
- inj : not used here
-
allensdk.model.glif.glif_neuron_methods.
dynamics_threshold_spike_component
(neuron, threshold_t0, voltage_t0, AScurrents_t0, inj, a_spike, b_spike, a_voltage, b_voltage)[source]¶ Analytical solution for spike component of threshold. The threshold will adapt via a component initiated by a spike which decays as an exponential. The component is in reference to threshold infinity and are recorded in the neuron’s threshold components. The voltage component of the threshold is set to zero in the threshold components because it is zero here The third component refers to th_inf which is added separately as opposed to being included in the voltage component of the threshold as is done in equation 2.1 of Mihalas and Nieber 2009. Threshold infinity is removed for simple optimization.
Parameters: - neuron : class
- threshold_t0 : float
threshold input to function
- voltage_t0 : float
voltage input to function
- AScurrents_t0 : vector
values of after spike currents
- inj : float
current injected into the neuron
-
allensdk.model.glif.glif_neuron_methods.
dynamics_threshold_three_components_exact
(neuron, threshold_t0, voltage_t0, AScurrents_t0, inj, a_spike, b_spike, a_voltage, b_voltage)[source]¶ Analytical solution for threshold dynamics. The threshold will adapt via two mechanisms: 1. a voltage dependent adaptation. 2. a component initiated by a spike which decays as an exponential. These two component are in reference to threshold infinity and are recorded in the neuron’s threshold components. The third component refers to th_inf which is added separately as opposed to being included in the voltage component of the threshold as is done in equation 2.1 of Mihalas and Nieber 2009. Threshold infinity is removed for simple optimization.
Parameters: - neuron : class
- threshold_t0 : float
threshold input to function
- voltage_t0 : float
voltage input to function
- AScurrents_t0 : vector
values of after spike currents
- inj : float
current injected into the neuron
-
allensdk.model.glif.glif_neuron_methods.
dynamics_voltage_linear_exact
(neuron, voltage_t0, AScurrents_t0, inj)[source]¶ (TODO) Linear voltage dynamics.
-
allensdk.model.glif.glif_neuron_methods.
dynamics_voltage_linear_forward_euler
(neuron, voltage_t0, AScurrents_t0, inj)[source]¶ (TODO) Linear voltage dynamics.
-
allensdk.model.glif.glif_neuron_methods.
max_of_line_and_const
(x, b, c, d)[source]¶ Find the maximum of a value and a position on a line
Parameters: - x: float
x position on line 1
- c: float
slope of line 1
- d: float
y-intercept of line 1
- b: float
y-intercept of line 2
Returns: - float
the max of a line value and a constant
-
allensdk.model.glif.glif_neuron_methods.
min_of_line_and_zero
(x, c, d)[source]¶ Find the minimum of a value and a position on a line
Parameters: - x: float
x position on line 1
- c: float
slope of line 1
- d: float
y-intercept of line 1
- b: float
y-intercept of line 2
Returns: - float
the max of a line value and a constant
-
allensdk.model.glif.glif_neuron_methods.
reset_AScurrent_none
(neuron, AScurrents_t0)[source]¶ Reset afterspike currents to zero.
-
allensdk.model.glif.glif_neuron_methods.
reset_AScurrent_sum
(neuron, AScurrents_t0, r)[source]¶ Reset afterspike currents by adding summed exponentials. Left over currents from last spikes as well as newly initiated currents from current spike. Currents amplitudes in neuron.asc_amp_array need to be the amplitudes advanced though the spike cutting. I.e. In the preprocessor if the after spike currents are calculated via the GLM from spike initiation the amplitude at the time after the spike cutting needs to be calculated and neuron.asc_amp_array needs to be set to this value.
Parameters: - r : np.ndarray
a coefficient vector applied to the afterspike currents
-
allensdk.model.glif.glif_neuron_methods.
reset_threshold_inf
(neuron, threshold_t0, voltage_v1)[source]¶ Reset the threshold to instantaneous threshold.
-
allensdk.model.glif.glif_neuron_methods.
reset_threshold_three_components
(neuron, threshold_t0, voltage_v1, a_spike, b_spike)[source]¶ This method calculates the two components of the threshold: a spike (fast) component and a voltage (slow) component. The threshold_components vectors are then updated so that the traces match the voltage, current, and total threshold traces. The spike component of the threshold decays via an exponential fit specified by the amplitude a_spike and the time constant b_spike fit via the multiblip data. The voltage component does not change during the duration of the spike. The spike component are threshold component are summed along with threshold infinity to return the total threshold. Note that in the current implementation a_spike is added to the last value of the threshold_components which means that a_spike is the amplitude after spike cutting (if there is any).
- Inputs:
- neuron: class
- contains attributes of the neuron
- threshold_t0, voltage_t0: float
- are not used but are here for consistency with other methods
- a_spike: float
- amplitude of the exponential decay of spike component of threshold after spike cutting has been implemented.
- b_spike: float
- amplitude of the exponential decay of spike component of threshold
- Outputs:
- Returns: float
- the total threshold which is the sum of the spike component of threshold, the voltage component of threshold and threshold infinity (with it’s corresponding coefficient)
- neuron.threshold_components: dictionary containing
- a spike: list
- vector of spiking component of threshold that corresponds to the voltage, current, and total threshold traces
- b_spike: list
- vector of voltage component of threshold that corresponds to the voltage, current,
- and total threshold traces.
Note that this function can be changed to use a_spike at the time of the spike and then have the the spike component plus the residual decay thought the spike. There are benefits and drawbacks to this. This potential change would be beneficial as it perhaps makes more biological sense for the threshold to go up at the time of spike if the traces are ever used. Also this would mean that a_spike would not have to be adjusted thought the spike cutting after the multiblip fit. However the current implementation makes sense in that it is similar to how afterspike currents are implemented.
-
allensdk.model.glif.glif_neuron_methods.
reset_voltage_v_before
(neuron, voltage_t0, a, b)[source]¶ Reset voltage to the previous value with a scale and offset applied.
Parameters: - a : float
voltage scale constant
- b : float
voltage offset constant
-
allensdk.model.glif.glif_neuron_methods.
reset_voltage_zero
(neuron, voltage_t0)[source]¶ Reset voltage to zero.
-
allensdk.model.glif.glif_neuron_methods.
spike_component_of_threshold_exact
(th0, b_spike, t)[source]¶ Spike component of threshold modeled as an exponential decay. Implemented here as exact analytical solution.
Parameters: - th0 : float
threshold input to function
- b_spike : float
decay constant of exponential
- t : float or array
time step if used in an Euler setup time if used analytically
-
allensdk.model.glif.glif_neuron_methods.
spike_component_of_threshold_forward_euler
(th_t0, b_spike, dt)[source]¶ Spike component of threshold modeled as an exponential decay. Implemented here for forward Euler
Parameters: - th_t0 : float
threshold input to function
- b_spike : float
decay constant of exponential
- dt : float
time step
-
allensdk.model.glif.glif_neuron_methods.
voltage_component_of_threshold_exact
(th0, v0, I, t, a_voltage, b_voltage, C, g, El)[source]¶ Note this function is the exact formulation; however, dt is used because t0 is the initial time and dt is the time the function is exactly evaluated at. Note: that here, this equation is in reference to th_inf. Therefore th0 is the total threshold-thr_inf (threshold_inf replaced with 0 in the equation to be verbose). This is done so that th_inf can be optimized without affecting this function.
Parameters: - th0 : float
threshold input to function
- v0 : float
voltage input to function
- I : float
total current entering neuron (note if there are after spike currents these must be included in this value)
- t : float or array
time step if used in an Euler setup time if used analytically
- a_voltage : float
constant a
- b_voltage : float
constant b
- C : float
capacitance
- g : float
conductance (1/resistance)
- El : float
reversal potential
-
allensdk.model.glif.glif_neuron_methods.
voltage_component_of_threshold_forward_euler
(th_t0, v_t0, dt, a_voltage, b_voltage, El)[source]¶ Equation 2.1 of Mihalas and Nieber, 2009 implemented for use in forward Euler. Note here all variables are in reference to threshold infinity. Therefore thr_inf is zero here (replaced threshold_inf with 0 in the equation to be verbose). This is done so that th_inf can be optimized without affecting this function.
Parameters: - th_t0 : float
threshold input to function
- v_t0 : float
voltage input to function
- dt : float
time step
- a_voltage : float
constant a
- b_voltage : float
constant b
- El : float
reversal potential