Skip to content

Commit

Permalink
add timestep() predefined function akin to resolution()
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed Sep 22, 2024
1 parent 2d5e24d commit 5461579
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 4 deletions.
98 changes: 98 additions & 0 deletions models/neurons/iaf_psc_delta_fixed_timestep_neuron.nestml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""
iaf_psc_delta_fixed_timestep - Current-based leaky integrate-and-fire neuron model with delta-kernel post-synaptic currents
###########################################################################################################################

Description
+++++++++++

iaf_psc_delta is an implementation of a leaky integrate-and-fire model
where the potential jumps on each spike arrival.

The threshold crossing is followed by an absolute refractory period
during which the membrane potential is clamped to the resting potential.

Spikes arriving while the neuron is refractory, are discarded by
default. If the property ``with_refr_input`` is set to true, such
spikes are added to the membrane potential at the end of the
refractory period, dampened according to the interval between
arrival and end of refractoriness.

The general framework for the consistent formulation of systems with
neuron like dynamics interacting by point events is described in
[1]_. A flow chart can be found in [2]_.

This model differs from ``iaf_psc_delta_fixed_timestep`` in that it
assumes a fixed-timestep simulator, so the function ``resolution()``
can be used.


References
++++++++++

.. [1] Rotter S, Diesmann M (1999). Exact simulation of
time-invariant linear systems with applications to neuronal
modeling. Biologial Cybernetics 81:381-402.
DOI: https://doi.org/10.1007/s004220050570
.. [2] Diesmann M, Gewaltig M-O, Rotter S, & Aertsen A (2001). State
space analysis of synchronous spiking in cortical neural
networks. Neurocomputing 38-40:565-571.
DOI: https://doi.org/10.1016/S0925-2312(01)00409-X


See also
++++++++

iaf_psc_alpha, iaf_psc_exp
"""
model iaf_psc_delta_fixed_timestep_neuron:
state:
V_m mV = E_L # Membrane potential
refr_t ms = 0 ms # Refractory period timer
is_refractory boolean = false

equations:
kernel K_delta = delta(t)
V_m' = -(V_m - E_L) / tau_m + convolve(K_delta, spikes) * (mV / ms) + (I_e + I_stim) / C_m

parameters:
tau_m ms = 10 ms # Membrane time constant
C_m pF = 250 pF # Capacity of the membrane
refr_T ms = 2 ms # Duration of refractory period
tau_syn ms = 2 ms # Time constant of synaptic current
E_L mV = -70 mV # Resting membrane potential
V_reset mV = -70 mV # Reset potential of the membrane
V_th mV = -55 mV # Spike threshold
V_min mV = -inf * 1 mV # Absolute lower value for the membrane potential

# constant external input current
I_e pA = 0 pA

input:
spikes <- spike
I_stim pA <- continuous

output:
spike

update:
if is_refractory:
# neuron is absolute refractory, do not evolve V_m
refr_t -= resolution()
else:
# neuron not refractory, so evolve all ODEs (including V_m)
integrate_odes()

onCondition(not is_refractory and V_m >= V_th):
# threshold crossing
V_m = V_reset

if refr_T > 0 ms:
refr_t = refr_T # start of the refractory period
is_refractory = true

emit_spike()

onCondition(is_refractory and refr_t <= resolution() / 2):
# end of refractory period
refr_t = 0 ms
is_refractory = false
8 changes: 4 additions & 4 deletions tests/nest_tests/stdp_triplet_synapse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
def nestml_generate_target():
r"""Generate the neuron model code"""

files = [os.path.join("models", "neurons", "iaf_psc_delta_neuron.nestml"),
files = [os.path.join("models", "neurons", "iaf_psc_delta_fixed_timestep_neuron.nestml"),
os.path.join("models", "synapses", "stdp_triplet_synapse.nestml")]
input_path = [os.path.realpath(os.path.join(os.path.dirname(__file__), os.path.join(
os.pardir, os.pardir, s))) for s in files]
Expand All @@ -53,7 +53,7 @@ def nestml_generate_target():
suffix="_nestml",
codegen_opts={"neuron_parent_class": "StructuralPlasticityNode",
"neuron_parent_class_include": "structural_plasticity_node.h",
"neuron_synapse_pairs": [{"neuron": "iaf_psc_delta_neuron",
"neuron_synapse_pairs": [{"neuron": "iaf_psc_delta_fixed_timestep_neuron",
"synapse": "stdp_triplet_synapse",
"post_ports": ["post_spikes"]}],
"delay_variable": {"stdp_triplet_synapse": "d"},
Expand Down Expand Up @@ -365,11 +365,11 @@ def _test_stdp_triplet_synapse(delay, spike_times_len):
}

if experiment == "test_nestml_pair_synapse":
neuron_model_name = "iaf_psc_delta_neuron_nestml__with_stdp_triplet_synapse_nestml"
neuron_model_name = "iaf_psc_delta_fixed_timestep_neuron_nestml__with_stdp_triplet_synapse_nestml"
neuron_opts = {"tau_minus__for_stdp_triplet_synapse_nestml": syn_opts["tau_minus"],
"tau_y__for_stdp_triplet_synapse_nestml": syn_opts["tau_y"]}

synapse_model_name = "stdp_triplet_synapse_nestml__with_iaf_psc_delta_neuron_nestml"
synapse_model_name = "stdp_triplet_synapse_nestml__with_iaf_psc_delta_fixed_timestep_neuron_nestml"
nest_syn_opts = {"d": delay}
nest_syn_opts.update(syn_opts)
nest_syn_opts.pop("tau_minus") # these have been moved to the neuron
Expand Down

0 comments on commit 5461579

Please sign in to comment.