From 5461579a0c906f77a0a6efe50abc2f7cc729de3c Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Sun, 22 Sep 2024 21:51:06 +0200 Subject: [PATCH] add timestep() predefined function akin to resolution() --- ...iaf_psc_delta_fixed_timestep_neuron.nestml | 98 +++++++++++++++++++ tests/nest_tests/stdp_triplet_synapse_test.py | 8 +- 2 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 models/neurons/iaf_psc_delta_fixed_timestep_neuron.nestml diff --git a/models/neurons/iaf_psc_delta_fixed_timestep_neuron.nestml b/models/neurons/iaf_psc_delta_fixed_timestep_neuron.nestml new file mode 100644 index 000000000..bde070619 --- /dev/null +++ b/models/neurons/iaf_psc_delta_fixed_timestep_neuron.nestml @@ -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 diff --git a/tests/nest_tests/stdp_triplet_synapse_test.py b/tests/nest_tests/stdp_triplet_synapse_test.py index 28a9402e9..544369166 100644 --- a/tests/nest_tests/stdp_triplet_synapse_test.py +++ b/tests/nest_tests/stdp_triplet_synapse_test.py @@ -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] @@ -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"}, @@ -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