Neuronal Cells

The neuron (or neuronal cell) represents one of the fundamental building blocks of a biomimetic neural system. These particular objects are meant to perform, per simulated time step, a calculation of output activity values given an internal arrangement of compartments (or sources where signals from other neuronal cell(s) are to be deposited). Typically, a neuron integrates an (ordinary) differential equation, which depends on the type of neuronal cell and dynamics under consideration.

Graded, Real-valued Neurons

This family of neuronal cells adheres to dynamics or performs calculations utilizing graded (real-valued/continuous) values; in other words, they do not produce any discrete signals or action potential values.

The Rate Cell

This cell evolves one set of dynamics over state z (a sort of real-valued continuous membrane potential). The “electrical” inputs that drive it include j (non-modulated signals) and j_td (modulated signals), which can be mapped to bottom-up and top-down pressures (such as those produced by error neurons) if one is building a strictly hierarchical neural model. Note that the “spikes” zF emitted are real-valued for the rate-cell and are represented via the application of a nonlinear activation function (default is the identity) configured by the user.

class ngclearn.components.RateCell(*args: Any, **kwargs: Any)[source]

A non-spiking cell driven by the gradient dynamics of neural generative coding-driven predictive processing.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane/state time constant (milliseconds)

  • prior

    a kernel for specifying the type of centered scale-shift distribution to impose over neuronal dynamics, applied to each neuron or dimension within this component (Default: (“gaussian”, 0)); this is a tuple with 1st element containing a string name of the distribution one wants to use while the second value is a leak rate scalar that controls the influence/weighting that this distribution has on the dynamics; for example, (“laplacian, 0.001”) means that a centered laplacian distribution scaled by 0.001 will be injected into this cell’s dynamics ODE each step of simulated time

    Note:

    supported scale-shift distributions include “laplacian”, “cauchy”, “exp”, and “gaussian”

  • act_fx – string name of activation function/nonlinearity to use

  • integration_type

    type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration) and “midpoint” or “rk2” (midpoint method/RK-2 integration) (Default: “euler”)

    Note:

    setting the integration type to the midpoint method will increase the accuray of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)

  • key – PRNG Key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

The Error Cell

This cell is (currently) a stateless neuron, i.e., it is not driven by an underlying differential equation, thus emulating a “fixed-point” error or mismatch calculation. Variations of the fixed-point error cell depend on the local distribution assumed over mismatch activities, e.g., Gaussian distribution yields a Gaussian error cell, which will also change the form of their internal compartments (typically a target, mu, dtarget, and dmu).

Gaussian Error Cell

This cell is (currently) fixed to be a Gaussian cell that assumes an identity covariance. Note that this neuronal cell has several important compartments: in terms of input compartments, target is for placing the desired target activity level while mu is for placing an externally produced mean prediction value, while in terms of output compartments, dtarget is the first derivative with respect to the target (sometimes used to emulate a top-down pressure/expectation in predictive coding) and dmu is the first derivative with respect to the mean parameter.

class ngclearn.components.GaussianErrorCell(*args: Any, **kwargs: Any)[source]

A simple (non-spiking) Gaussian error cell - this is a fixed-point solution of a mismatch signal.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – (Unused – currently cell is a fixed-point model)

  • leakRate – (Unused – currently cell is a fixed-point model)

  • key – PRNG Key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

Laplacian Error Cell

This cell is (currently) fixed to be a Laplacian cell that assumes an identity scale. Note that this neuronal cell has several important compartments: in terms of input compartments, target is for placing the desired target activity level while mu is for placing an externally produced mean prediction value, while in terms of output compartments, dtarget is the first derivative with respect to the target (sometimes used to emulate a top-down pressure/expectation in predictive coding) and dmu is the first derivative with respect to the mean parameter.

class ngclearn.components.LaplacianErrorCell(*args: Any, **kwargs: Any)[source]

A simple (non-spiking) Laplacian error cell - this is a fixed-point solution of a mismatch signal.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – (Unused – currently cell is a fixed-point model)

  • leakRate – (Unused – currently cell is a fixed-point model)

  • key – PRNG Key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

Spiking Neurons

These neuronal cells exhibit dynamics that involve emission of discrete action potentials (or spikes). Typically, such neurons are modeled with multiple compartments, including at least one for the electrical current j, the membrane potential v, the voltage threshold thr, and action potential s. Note that the interactions or dynamics underlying each component might itself be complex and nonlinear, depending on the neuronal cell simulated (i.e., some neurons might be running multiple differential equations under the hood).

The Simplified LIF (sLIF) Cell

This cell, which is a simplified version of the leaky integrator (i.e., model described later below), models dynamics over voltage v and threshold thr (note that j is further treated as a point-wise current for simplicity). Importantly, an optional fast form of lateral inhibition can be emulated with this cell by setting the inhibitory resistance inhibit_R > 0 – this will mean that the dynamics over v include a term that is equal to a negative hollow matrix product with the spikes emitted at time t-1 (yielding a recurrent negative pressure on the membrane potential values at t).

class ngclearn.components.SLIFCell(*args: Any, **kwargs: Any)[source]

A spiking cell based on a simplified leaky integrate-and-fire (sLIF) model. This neuronal cell notably contains functionality required by the computational model employed by (Samadi et al., 2017, i.e., a surrogate derivative function and “sticky spikes”) as well as the additional incorporation of an adaptive threshold (per unit) scheme. (Note that this particular spiking cell only supports Euler integration of its voltage dynamics.)

Reference:
Samadi, Arash, Timothy P. Lillicrap, and Douglas B. Tweed. “Deep learning with
dynamic spiking neurons and fixed feedback weights.” Neural computation 29.3
(2017): 578-602.
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds (initial condition for per-cell thresholds) that govern short-term plasticity

  • inhibit_R – lateral modulation factor (DEFAULT: 6.); if >0, this will trigger a heuristic form of lateral inhibition via an internally integrated hollow matrix multiplication

  • thr_persist

    are adaptive thresholds persistent? (Default: False)

    Note:

    depending on the value of this boolean variable: True = adaptive thresholds are NEVER reset upon call to reset False = adaptive thresholds are reset to “thr” upon call to reset

  • thrGain – how much adaptive thresholds increment by

  • thrLeak – how much adaptive thresholds are decremented/decayed by

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • rho_b – threshold sparsity factor (Default: 0)

  • sticky_spikes – if True, spike variables will be pinned to action potential value (i.e, 1) throughout duration of the refractory period; this recovers a key setting used by Samadi et al., 2017

  • thr_jitter – scale of uniform jitter to add to initialization of thresholds

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save sLIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

The LIF (Leaky Integrate-and-Fire) Cell

This cell (the “leaky integrator”) models dynamics over the voltage v and threshold shift thrTheta (a homeostatic variable). Note that thr is used as a baseline level for the membrane potential threshold while thrTheta is treated as a form of short-term plasticity (full threshold is: thr + thrTheta(t)).

class ngclearn.components.LIFCell(*args: Any, **kwargs: Any)[source]

A spiking cell based on leaky integrate-and-fire (LIF) neuronal dynamics.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV)

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • one_spike – if True, a single-spike constraint will be enforced for every time step of neuronal dynamics simulated, i.e., at most, only a single spike will be permitted to emit per step – this means that if > 1 spikes emitted, a single action potential will be randomly sampled from the non-zero spikes detected

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save LIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

The Quadratic LIF (Leaky Integrate-and-Fire) Cell

This cell (the quadratic “leaky integrator”) models dynamics over the voltage v and threshold shift thrTheta (a homeostatic variable). Note that thr is used as a baseline level for the membrane potential threshold while thrTheta is treated as a form of short-term plasticity (full threshold is: thr + thrTheta(t)). The dynamics are driven by a critical voltage value as well as a voltage scaling factor for membrane potential accumulation over time.

class ngclearn.components.QuadLIFCell(*args: Any, **kwargs: Any)[source]

A spiking cell based on quadratic leaky integrate-and-fire (LIF) neuronal dynamics.

Dynamics can be taken to be governed by the following ODE:

d.Vz/d.t = a0 * (V - V_rest) * (V - V_c) + Jz * R) * (dt/tau_mem)

where:

a0 - scaling factor for voltage accumulation
V_c - critical voltage (value)
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV)

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • v_scale – scaling factor for voltage accumulation (v_c)

  • critical_V – critical voltage value (a0)

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • one_spike – if True, a single-spike constraint will be enforced for every time step of neuronal dynamics simulated, i.e., at most, only a single spike will be permitted to emit per step – this means that if > 1 spikes emitted, a single action potential will be randomly sampled from the non-zero spikes detected

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save LIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

The FitzHugh–Nagumo Cell

This cell models dynamics over voltage v and a recover variable w (where w governs the behavior of the action potential of a spiking neuronal cell). In effect, the FitzHugh-Nagumo model is a set of two coupled differential equations that simplify the four differential equation Hodgkin-Huxley (squid axon) model. A voltage v_thr can be used to extract binary spike pulses. (Note that this cell supports either Euler or midpoint method / RK-2 integration.)

class ngclearn.components.FitzhughNagumoCell(*args: Any, **kwargs: Any)[source]

The Fitzhugh-Nagumo neuronal cell model; a two-variable simplification of the Hodgkin-Huxley (squid axon) model. This cell model iteratively evolves voltage “v” and recovery “w” (which represents the combined effects of sodium channel deinactivation and potassium channel deactivation in the Hodgkin-Huxley model).

The specific pair of differential equations that characterize this cell are (for adjusting v and w, given current j, over time):

tau_m * dv/dt = v - (v^3)/3 - w + j
tau_w * dw/dt = v + a - b * w
References:
FitzHugh, Richard. “Impulses and physiological states in theoretical
models of nerve membrane.” Biophysical journal 1.6 (1961): 445-466.

Nagumo, Jinichi, Suguru Arimoto, and Shuji Yoshizawa. “An active pulse
transmission line simulating nerve axon.” Proceedings of the IRE 50.10
(1962): 2061-2070.
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • tau_w – recover variable time constant (Default: 12.5 ms)

  • alpha – dimensionless recovery variable shift factor “a” (Default: 0.7)

  • beta – dimensionless recovery variable scale factor “b” (Default: 0.8)

  • gamma – power-term divisor (Default: 3.)

  • v_thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes)

  • v0 – initial condition / reset for voltage

  • w0 – initial condition / reset for recovery

  • integration_type

    type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration) and “midpoint” or “rk2” (midpoint method/RK-2 integration) (Default: “euler”)

    Note:

    setting the integration type to the midpoint method will increase the accuray of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)

  • key – PRNG key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]

The Izhikevich Cell

This cell models dynamics over voltage v and a recover variable w (where w governs the behavior of the action potential of a spiking neuronal cell). In effect, the Izhikevich model is a set of two coupled differential equations that simplify the more complex dynamics of the Hodgkin-Huxley model. Note that this Izhikevich model can be configured to model particular classes of neurons, including regular spiking (RS), intrinsically bursting (IB), chattering (CH), fast spiking (FS), low-threshold spiking (LTS), and resonator (RZ) neurons. (Note that this cell supports either Euler or midpoint method / RK-2 integration.)

class ngclearn.components.IzhikevichCell(*args: Any, **kwargs: Any)[source]

A spiking cell based on Izhikevich’s model of neuronal dynamics. Note that this a two-variable simplification of more complex multi-variable systems (e.g., Hodgkin-Huxley model). This cell model iteratively evolves voltage “v” and recovery “w”, the last of which represents the combined effects of sodium channel deinactivation and potassium channel deactivation.

The specific pair of differential equations that characterize this cell are (for adjusting v and w, given current j, over time):

tau_m * dv/dt = 0.04 v^2 + 5v + 140 - w + j * R_m
tau_w * dw/dt = (v * b - w), where tau_w = 1/a
References:
Izhikevich, Eugene M. “Simple model of spiking neurons.” IEEE Transactions
on neural networks 14.6 (2003): 1569-1572.

Note: Izhikevich’s constants/hyper-parameters ‘a’, ‘b’, ‘c’, and ‘d’ have been remapped/renamed (see arguments below). Note that the default settings for this component cell is for a regular spiking cell; to recover other types of spiking cells (depending on what neuronal circuitry one wants to model), one can recover specific models with the following particular values:

Intrinsically bursting neurons: v_reset=-55, w_reset=4
Chattering neurons: v_reset = -50, w_reset = 2
Fast spiking neurons: tau_w = 10
Low-threshold spiking neurons: tau_w = 10, coupling_factor = 0.25, w_reset = 2
Resonator neurons: tau_w = 10, coupling_factor = 0.26
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant (Default: 1 ms)

  • R_m – membrane resistance value

  • v_thr – voltage threshold value to cross for emitting a spike (in milliVolts, or mV) (Default: 30 mV)

  • v_reset – voltage value to reset to after a spike (in mV) (Default: -65 mV), i.e., ‘c’

  • tau_w – recovery variable time constant (Default: 50 ms), i.e., 1/’a’

  • w_reset – recovery value to reset to after a spike (Default: 8), i.e., ‘d’

  • coupling_factor – degree of to which recovery is sensitive to any subthreshold fluctuations of voltage (Default: 0.2), i.e., ‘b’

  • v0 – initial condition / reset for voltage (Default: -65 mV)

  • w0 – initial condition / reset for recovery (Default: -14)

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • integration_type

    type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration) and “midpoint” or “rk2” (midpoint method/RK-2 integration) (Default: “euler”)

    Note:

    setting the integration type to the midpoint method will increase the accuray of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
verify_connections()[source]
reset(**kwargs)[source]