This package deals with the optimization of generalized integrate and fire neurons (gLIF).
Fits subthreshold and threshold parameters of a gLIF model from voltage patch clamp data. A neuron object is returned to the client that can easily be simulated using standard methods listed in the documentation.
Fits an actionable neuron to the data provided.
Parameters: |
|
---|---|
Returns: |
Return type of optimization procedure.
Extracts and returns parameter dictionaries from the subthreshold and threshold parts of the neuron.
This file will contain a library of spike induced current (sic) objects. A user may provide any list of spike induced current objects to the optimization functions as long as all of these objects are derived from the SicBase abstract class or implement methods with the same names and input arguments.
Bases: fit_neuron.optimize.sic_lib.SicBase
Exponentially decaying spike induced current. The class models the following differential equation:
When the neuron spikes, the current is incremented as follows:
time step
decay rate
value of the spike induced current
Bases: fit_neuron.optimize.sic_lib.SicBase
Step wise spike induced current that is the sum of indicator variables for the spiking history of the time since the last spike being between zero and some t_max.
time increments
actual value of the spike induced current
list of time elapsed since last spikes
time defining indicator functions
Parameter extraction of subthreshold parameters from voltage clamp data. This module defines a subthreshold model (Voltage) and defines an optimization function (estimate_volt_parameters()).
This class defines the voltage predictions of the gLIF models.
Parameters: |
|
---|
The difference equation describing the evolution of the membrane potential is the following:
where are the previous spike times relative to the current time , the are the spike induced currents, which may or may not depend explicitly on , and is an optional voltage nonlinearity function.
The updates are implemented as follows:
where is the parameter vector, and
The vector is computed at each time step by compute_X_subthresh() and the inner product is taken by update().
values of the spike induced currents
resting potential
reset potential (post spike)
The method uses the object’s param_arr attribute and parses this array as a dictionary and saves it as the instance’s param_dict attribute. This dictionary is also returned to the caller.
Updates the values of the spike induced currents and then computes . As explained in the class docstring, the voltage difference is computed as the inner product of with the parameter vector .
Note
This method can be called even if param_arr has not yet been computed. In fact, the function setup_regression() uses this functionality to compute at every time point so that linear regression can then be easily performed. This practice ensures that the regressed parameters match the compute_X_subthresh() method without any indexing mismatches. It also encourages code reuse.
time step
Estimates resting potential of neuron by letting the neuron respond to zero input for a specified amount of time.
Parameters: | t_wait – number of seconds to wait for voltage to go to resting state |
---|
current spiking state of the neuron
array of subthreshold parameter values
dictionary of parameter values
Resets all the spike induced currents to resting state by calling the reset method for all the spike induced currents (eg. see fit_neuron.optimize.sic_lib.ExpDecay_sic.reset()).
Method to be called after estimate_volt_parameters() has found an optimal set of parameters.
Parameters: | param_arr – array of subthreshold parameter values. |
---|
Calls the spike() method of all spike induced current, sets is_spiking to True, and sets the timer of the spike to t_ref.
refractory period after each spike during which the neuron will have a value of numpy.nan
A counter used to count down the time during which the neuron spikes. Whenever a spike occurs, its value is set to t_ref.
This method takes a voltage value and an input current value and returns the value of the voltage at the next time step. If the neuron is not currently is a spiking state, the method will return a float. If the neuron is in a spiking state, the method will return a numpy.nan. value. The values are updated acccording to the object’s dt attribute.
This method, only to be called when the neuron is currently spiking, updates the counter of the spike. Once the neuron has been in a spiking state for a period of time longer than t_ref, the neuron will exit the spiking state by setting is_spiking back to True.
voltage nonlinearity function, may be None
Estimates voltage parameters using data provided and stores these as attributes. Does a least squares linear regression of the voltage parameters.
Parameters: |
|
---|---|
Returns: | array of subthreshold parameters. |
The equation we are solving is the following:
where
and
The value of that minimizes this expression is the parameter vector for the subthreshold object.
Parameter extraction of threshold parameters from voltage clamp data.
Class for the threshold component of a spiking neuron. The main functionality of this class is to determine spike times stochastically.
Parameters: |
|
---|
The stochastic neuron has the following hazard rate:
where
where the parameters are the indicator variables, and the parameters are probability currents which shall be referred to as voltage chasing currents. These currents give the stochastic spike emission process a component that adapts to the history of the voltage. The equations used for the voltage chasing currents are:
After the neuron spikes, the voltage chasing currents are reset to the value of the voltage immediately following the spike:
The hazard rate is computed at each time step and compared to a uniformly distributed random number to determine whether the neuron spikes here. The computation of at each time step is done by update_X_arr(), while the inner product with the parameter vector and the random decision of whether a spike occurs or not is taken by update().
This method resets to neuron to a resting state. The spiking history is erased and the the voltage adaption currents are either erased or are set to the current value of the voltage itself.
Parameters: | V – value to which voltage chasing currents are reset to |
---|
After the optimization is done, this method allows the final value of the parameter array to be set, and parses this parameter array into a parameter dictionary.
current value of the spiking probability
max amount of time during which we care about previous spikes, see self.update
these parameters take the internal values and map them to a spike probability
Updates inner state and returns True if there is a spike, and False if there is no spike.
Updates X_arr (the vector with which we do a dot product with the threshold parameters to calculate the spiking probability).
the actual value of the currents which will be an array
these are the time constants of the voltage chasing parameters
Computes log likelihood of the spike trains given the parameters.
Parameters: |
|
---|---|
Returns: | log likelihood of the time series given parameter array |
Estimates threshold parameters that fit the raw data, and the particular form of the threshold and subthreshold components of the model.
Parameters: |
|
---|---|
Returns: | array of threshold parameters |
Takes a subset of the data and returns gradient and hessian for this subset of the data. This function is called by par_calc_log_like_update and allows this function to work in parallel, map-reduce style. Computes gradient vector as well as Hessian matrix of log likelihood w.r.t. threshold parameters, evaluated at thresh_param. The grad and hess can then be used to update thresh parameters via a Newton-Raphson step.
Performs maximum likelihood optimization.
Parallel version of Newton update. This method is called by max_likelihood(). The function splits data into chunks, passes chuncks to different processors, collects the result to obtain the gradient and hessian of the whole time series, then performs Newon update.