gif_pop_psc_exp#
- class brainpy.state.gif_pop_psc_exp(in_size, N=100, tau_m=20.0, C_m=250.0, t_ref=4.0, lambda_0=10.0, Delta_V=2.0, E_L=0.0, V_reset=0.0, V_T_star=15.0, I_e=0.0, tau_syn_ex=3.0, tau_syn_in=6.0, tau_sfa=(300.0,), q_sfa=(0.5,), len_kernel=-1, BinoRand=True, rng_seed=0, name=None)#
Population of generalized integrate-and-fire neurons (GIF) with exponential postsynaptic currents and adaptation.
gif_pop_psc_expsimulates a population of spike-response model neurons with multi-timescale adaptation and exponential postsynaptic currents. It directly models the population activity (sum of all spikes) without explicitly representing each individual neuron, following the algorithm of Schwalger et al. (2017) [1].This is a brainpy.state re-implementation of the NEST simulator model of the same name, using NEST-standard parameterization.
1. Mathematical Model
The single neuron model is defined by the hazard function:
\[h(t) = \lambda_0 \exp\left(\frac{V_m(t) - E_{\mathrm{sfa}}(t)}{\Delta_V}\right)\]After each spike, the membrane potential \(V_m\) is reset to \(V_{\mathrm{reset}}\). Spike frequency adaptation is implemented by a set of exponentially decaying traces, the sum of which is \(E_{\mathrm{sfa}}\). Upon a spike, each of the adaptation traces is incremented by the respective \(q_{\mathrm{sfa}}\) and decays with the respective time constant \(\tau_{\mathrm{sfa}}\).
2. Population Dynamics Algorithm
The model uses the algorithm from Figures 11 and 12 of [1] to simulate the population activity directly:
Membrane update: Exact exponential integration of the subthreshold membrane dynamics with exponential postsynaptic currents:
\[C_m \frac{dV}{dt} = -\frac{C_m}{\tau_m}(V - E_L) + I_{\mathrm{syn,ex}} + I_{\mathrm{syn,in}} + I_e + I_{\mathrm{stim}}\]Adaptation update: Multi-timescale adaptation state evolves as:
\[E_{\mathrm{sfa}} = V_{T^*} + \sum_j Q_{30K,j} \cdot g_j\]where \(g_j\) tracks the convolution of past spike rates with the adaptation kernel.
Population escape rate: For each refractory cohort, compute the hazard-based escape (firing) probability. Free (non-refractory) neurons and neurons emerging from refractoriness are tracked separately.
Stochastic spike generation: The expected number of spikes is computed from the population escape rates, and the actual spike count is drawn from either a binomial or Poisson distribution.
History buffer rotation: Spike counts, survival counts, mean membrane potentials, and variances of each refractory cohort are maintained in rotating circular buffers.
3. Synaptic Currents
Exponential postsynaptic currents follow first-order dynamics:
\[\tau_{\mathrm{syn}} \frac{dy}{dt} = -y\]Integrated exactly per time step:
\[y(t+h) = y_{\infty} + (y(t) - y_{\infty}) \cdot e^{-h/\tau_{\mathrm{syn}}}\]The membrane contribution from synaptic currents is computed via the exact propagator for the coupled linear system of membrane and synaptic dynamics.
Connecting two population models corresponds to full connectivity of every neuron in each population. An approximation of random connectivity can be implemented by connecting populations using a
bernoulli_synapse.- Parameters:
in_size (
int,sequenceofint) – Shape of the population. Typically a scalar for 1D populations.N (
int, optional) – Number of neurons represented by this population node. Default: 100.tau_m (
float, optional) – Membrane time constant in milliseconds. Default: 20.0.C_m (
float, optional) – Membrane capacitance in picofarads. Default: 250.0.t_ref (
float, optional) – Duration of absolute refractory period in milliseconds. Default: 4.0.lambda_0 (
float, optional) – Firing rate at threshold in 1/s (Hz). Default: 10.0.Delta_V (
float, optional) – Noise level (voltage sensitivity) of the escape rate in millivolts. Determines how sharply the firing rate increases with membrane potential. Default: 2.0.E_L (
float, optional) – Resting (leak) potential in millivolts. Default: 0.0.V_reset (
float, optional) – Reset potential after spike in millivolts. Default: 0.0.V_T_star (
float, optional) – Baseline threshold level in millivolts. Effective threshold is \(V_{T^*} + E_{\mathrm{sfa}}\). Default: 15.0.I_e (
float, optional) – Constant external DC input current in picoamperes. Default: 0.0.tau_syn_ex (
float, optional) – Excitatory synaptic time constant in milliseconds. Default: 3.0.tau_syn_in (
float, optional) – Inhibitory synaptic time constant in milliseconds. Default: 6.0.tau_sfa (
sequenceoffloat, optional) – Adaptation time constants in milliseconds. Multiple timescales can be specified as a tuple. Default: (300.0,).q_sfa (
sequenceoffloat, optional) – Adaptation kernel amplitudes in millivolts. Must have the same length as tau_sfa. Default: (0.5,).len_kernel (
int, optional) – History kernel length in time steps. If -1 (default), automatically computed to ensure convergence. Default: -1.BinoRand (
bool, optional) – If True, use binomial distribution for spike generation. If False, use Poisson distribution. Default: True.rng_seed (
int, optional) – Random number generator seed for reproducibility. Default: 0.name (
str, optional) – Name of the population. Default: None.
Parameter Mapping
gif_pop_psc_exp
gif_psc_exp
relation
tau_m
g_L
tau_m = C_m / g_L
N
—
use N gif_psc_exp neurons
State Variables
The model exposes the following read-only properties:
State variable
Description
V_mMean membrane potential (mV)
I_syn_exExcitatory synaptic current (pA)
I_syn_inInhibitory synaptic current (pA)
n_spikesNumber of spikes in current step
n_expectExpected number of spikes
theta_hatAdaptive threshold (mV)
y0External current input state (pA)
Notes
As
gif_pop_psc_exprepresents many neurons in one node, it may generate many spikes per time step. Then_spikesstate variable records the number of spikes emitted by the population each step.The computational cost of this model is largely independent of the number N of neurons represented.
Defaults follow NEST C++ source for
gif_pop_psc_exp.lambda_0is specified in 1/s (as in NEST’s Python interface); the conversion factor of 0.001 to 1/ms is applied in the update equations exactly as in NEST (the factor 0.0005 in the trapezoidal escape rate).Synaptic spike weights are interpreted in current units; positive weights go to excitatory, negative to inhibitory channel.
The model does not inherit from
Neuronbecause it represents a population, not a single spiking neuron with a surrogate gradient.Parameters are stored as plain floats (unitless) to match NEST’s internal representation.
References
See also
Examples
Create a population of 100 neurons with default parameters:
>>> import brainpy.state as bp >>> import saiunit as u >>> pop = bp.gif_pop_psc_exp(1, N=100) >>> pop.init_all_states()
Create a population with custom adaptation parameters:
>>> pop = bp.gif_pop_psc_exp( ... 1, ... N=200, ... tau_sfa=(100.0, 500.0), ... q_sfa=(0.3, 0.6), ... lambda_0=5.0 ... ) >>> pop.init_all_states()
Simulate the population with external input:
>>> with brainstate.environ.context(dt=0.1 * u.ms): ... pop.init_all_states() ... for _ in range(1000): ... n_spikes = pop.update(x=100.0) # 100 pA input ... print(f"Spikes: {n_spikes}, V_m: {pop.V_m:.2f}")
- property I_syn_ex: float#
Excitatory synaptic current in picoamperes.
- Returns:
Current excitatory synaptic current (pA), evolving according to exponential dynamics with time constant tau_syn_ex.
- Return type:
- property I_syn_in: float#
Inhibitory synaptic current in picoamperes.
- Returns:
Current inhibitory synaptic current (pA), evolving according to exponential dynamics with time constant tau_syn_in.
- Return type:
- property V_m: float#
Mean membrane potential in millivolts.
- Returns:
Population-averaged membrane potential of all neurons (mV). Updated each time step by exact exponential integration.
- Return type:
- init_state(**kwargs)[source]#
Initialize all population state variables and history buffers.
Allocates and initializes circular buffers for tracking refractory cohorts, computes integration constants, and sets initial conditions following Procedure InitPopulations from Fig. 11 of [1].
- Parameters:
**kwargs – Unused compatibility parameters accepted by the base-state API.
Notes
Computes integration time step h from the global brainstate dt.
Determines history kernel length (automatic if len_kernel < 1).
Initializes all neurons in the free (non-refractory) state.
Precomputes adaptation kernel values and propagator constants.
Resets the random number generator to rng_seed.
- property n_expect: float#
Expected number of spikes in the current time step.
- Returns:
Mean spike count computed from the population escape rates before stochastic sampling. May exceed N in principle.
- Return type:
- property n_spikes: int#
Number of spikes emitted in the current time step.
- Returns:
Spike count drawn stochastically from the expected rate, ranging from 0 to N.
- Return type:
- reset_state(**kwargs)[source]#
Reset all population state variables to initial conditions.
Equivalent to calling
init_state()again: re-initializes all history buffers, observable states, and the random number generator to their values immediately after construction.- Parameters:
**kwargs – Unused compatibility parameters accepted by the base-state API.
- property theta_hat: float#
Adaptive threshold for non-refractory neurons in millivolts.
- Returns:
Effective threshold including all adaptation contributions (mV). Equals V_T_star plus the sum of all adaptation traces.
- Return type:
- update(x=0.0)[source]#
Advance the population model by one time step.
Implements the full population update algorithm from Figures 11 and 12 of [1], including:
Exact exponential integration of membrane potential and synaptic currents
Multi-timescale adaptation state update
Escape rate computation for each refractory cohort
Stochastic spike generation (binomial or Poisson)
Circular buffer rotation for history tracking
- Parameters:
x (
float, optional) – External input current in picoamperes. Positive values are routed to the excitatory channel, negative values to the inhibitory channel. Default: 0.0.- Returns:
Number of spikes emitted by the population in this time step. Ranges from 0 to N. Stored in the
n_spikesproperty.- Return type:
Notes
Delta inputs (spike events) are collected from
_delta_inputsand separated into excitatory and inhibitory components.Current inputs are collected from
_current_inputsand accumulated into they0state for the next time step.The membrane potential
V_m, synaptic currentsI_syn_exandI_syn_in, adaptive thresholdtheta_hat, and expected spike countn_expectare all updated and accessible via properties.The actual spike count is drawn stochastically from the expected count using either a binomial or Poisson distribution (controlled by
BinoRand).