Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attributes to spike events #1137

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8953256
add explicit output parameters to spiking output port
Oct 17, 2024
cd490c7
add explicit output parameters to spiking output port
Oct 17, 2024
ae9ffa7
add explicit output parameters to spiking output port
Oct 19, 2024
07dcfc6
add explicit output parameters to spiking output port
Oct 20, 2024
90a4aac
add explicit output parameters to spiking output port
Oct 20, 2024
224e0f3
add explicit attributes to spiking input port
Oct 21, 2024
c427eb9
add explicit output parameters to spiking output port
Oct 21, 2024
e6925af
Merge branch 'output_parameters' into input-parameters
Oct 21, 2024
a24d0cf
add explicit parameters to spiking input port
Oct 21, 2024
3d29706
add explicit output parameters to spiking output port
Oct 21, 2024
9a5ed50
Merge branch 'output_parameters' into input-parameters
Oct 21, 2024
9f5eeb8
update version numbers after 8.0.0-rc3 release
Oct 21, 2024
dd8fed6
remove qualifiers from spiking input ports
Oct 29, 2024
1329554
Merge remote-tracking branch 'clinssen/output_parameters' into remove…
Oct 29, 2024
ba3075a
Merge remote-tracking branch 'clinssen/input-parameters' into remove_…
Oct 29, 2024
be93fa3
add attributes to spiking input ports
Oct 30, 2024
7be429f
add attributes to spiking input ports
Oct 30, 2024
2036109
add attributes to spiking input ports
Oct 30, 2024
3903020
add attributes to spiking input ports
Oct 31, 2024
90bd81d
add attributes to spiking input ports
Oct 31, 2024
296d155
add attributes to spiking input ports
Nov 1, 2024
3304379
add attributes to spiking input ports
Nov 3, 2024
0e0718f
add attributes to spiking input ports
Nov 5, 2024
e8ce786
Merge remote-tracking branch 'upstream/master' into event_attributes
Nov 6, 2024
b5f8200
add attributes to spiking input ports
Nov 6, 2024
9b80425
add attributes to spiking input ports
Nov 6, 2024
6ae9e21
add attributes to spiking input ports
Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions doc/nestml_language/neurons_in_nestml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,7 @@ A neuron model written in NESTML can be configured to receive two distinct types
AMPA_spikes <- spike
I_stim pA <- continuous

The general syntax is:

::

port_name <- inputQualifier spike
port_name dataType <- continuous

The spiking input ports are declared without a data type, whereas the continuous input ports must have a data type.
For spiking input ports, the qualifier keywords decide whether inhibitory and excitatory inputs are lumped together into a single named input port, or if they are separated into differently named input ports based on their sign. When processing a spike event, some simulators (including NEST) use the sign of the amplitude (or weight) property in the spike event to indicate whether it should be considered an excitatory or inhibitory spike. By using the qualifier keywords, a single spike handler can route each incoming spike event to the correct input buffer (excitatory or inhibitory). Compare:

.. code-block:: nestml

input:
# [...]
all_spikes <- spike

In this case, all spike events will be processed through the ``all_spikes`` input port. A spike weight could be positive or negative, and the occurrences of ``all_spikes`` in the model should be considered a signed quantity.

.. code-block:: nestml

input:
# [...]
AMPA_spikes <- excitatory spike
GABA_spikes <- inhibitory spike

In this case, spike events that have a negative weight are routed to the ``GABA_spikes`` input port, and those that have a positive weight to the ``AMPA_spikes`` port.

It is equivalent if either both `inhibitory` and `excitatory` are given, or neither: an unmarked port will by default handle all incoming presynaptic spikes.

.. list-table::
:header-rows: 1
:widths: 10 60

* - Keyword
- The incoming weight :math:`w`...
* - none, or ``excitatory`` and ``inhibitory``
- ... may be positive or negative. It is added to the buffer with signed value :math:`w` (positive or negative).
* - ``excitatory``
- ... should not be negative. It is added to the buffer with non-negative magnitude :math:`w`.
* - ``inhibitory``
- ... should be negative. It is added to the buffer with non-negative magnitude :math:`-w`.



Integrating current input
Expand Down Expand Up @@ -214,12 +173,12 @@ The input ports can also be defined as vectors. For example,

neuron multi_synapse_vectors:
input:
AMPA_spikes <- excitatory spike
GABA_spikes <- inhibitory spike
AMPA_spikes <- spike
GABA_spikes <- spike
NMDA_spikes <- spike
foo[2] <- spike
exc_spikes[3] <- excitatory spike
inh_spikes[3] <- inhibitory spike
exc_spikes[3] <- spike
inh_spikes[3] <- spike

equations:
kernel I_kernel_exc = exp(-1 / tau_syn_exc * t)
Expand Down
2 changes: 0 additions & 2 deletions doc/pynestml_toolchain/front.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ Given the fact that context conditions have the commonality of checking the cont

- *CoCoConvolveHasCorrectParameter*: Checks that *convolve* calls are not provided with complex expressions, but only variables.

- *CoCoTypeOfBufferUnique*: Checks that no keyword is stated twice in an input buffer declaration, e.g., *inhibitory inhibitory spike*.

- *CoCoUserDeclaredFunctionCorrectlyDefined*: Checks that user-defined functions are correctly defined, i.e., only parameters of the function are used, and the return type is correctly stated.

- *CoCoVariableOncePerScope*: Checks that each variable is defined at most once per scope, i.e., no variable is redefined.
Expand Down
4 changes: 2 additions & 2 deletions doc/running/running_nest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Multiple input ports with vectors in NEST

See :ref:`Multiple input ports with vectors` for an example with input ports defined as vectors.

Each connection in NEST is denoted by a receiver port or ``rport`` number which is an integer that starts with 0. All default connections in NEST have the ``rport`` 0. NESTML routes the spikes with ``excitatory`` and ``inhibitory`` qualifiers into separate input buffers, whereas NEST identifies them with the same ``rport`` number.
Each connection in NEST is denoted by a receiver port or ``rport`` number which is an integer that starts with 0. All default connections in NEST have the ``rport`` 0.

During the code generation for NEST, NESTML maintains an internal mapping between NEST ``rports`` and NESTML input ports. A list of port names defined in a model and their corresponding ``rport`` numbers can be queried from the status dictionary using the NEST API. For neurons with multiple input ports, the ``receptor_type`` values in the ``nest.Connect()`` call start from 1 as the default ``receptor_type`` 0 is excluded to avoid any accidental connections.

Expand All @@ -159,7 +159,7 @@ The above code querying for ``receptor_types`` gives a list of port names and NE
- 1
* - NMDA_spikes
- 2
* - FOO_0
* - FOO_0 XXXXX _VEC_IDX_
- 3
* - FOO_1
- 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ model iaf_psc_alpha_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ model iaf_psc_alpha_adapt_curr_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ model iaf_psc_alpha_adapt_thresh_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ model iaf_psc_alpha_adapt_thresh_OU_neuron:
A_noise pA = ((D_noise * tau_syn_exc / 2) * (1 - exp(-2 * resolution() / tau_syn_exc )))**.5

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/aeif_cond_alpha_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ model aeif_cond_alpha_neuron:
PSConInit_I nS/ms = nS * e / tau_syn_inh

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
20 changes: 14 additions & 6 deletions models/neurons/aeif_cond_exp_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ model aeif_cond_exp_neuron:
V_m mV = E_L # Membrane potential
w pA = 0 pA # Spike-adaptation current
refr_t ms = 0 ms # Refractory period timer
g_syn_exc nS = 0 nS
g_syn_inh nS = 0 nS

equations:
inline V_bounded mV = min(V_m, V_peak) # prevent exponential divergence
kernel g_inh = exp(-t / tau_syn_inh)
kernel g_exc = exp(-t / tau_syn_exc)
g_syn_exc' = -g_syn_exc / tau_syn_exc
g_syn_inh' = -g_syn_inh / tau_syn_inh

# Add inlines to simplify the equation definition of V_m
inline exp_arg real = (V_bounded - V_th) / Delta_T
inline I_spike pA = g_L * Delta_T * exp(exp_arg)
inline I_syn_exc pA = convolve(g_exc, exc_spikes) * nS * (V_bounded - E_exc)
inline I_syn_inh pA = convolve(g_inh, inh_spikes) * nS * (V_bounded - E_inh)
inline I_syn_exc pA = g_syn_exc * (V_bounded - E_exc)
inline I_syn_inh pA = g_syn_inh * nS * (V_bounded - E_inh)

V_m' = (-g_L * (V_bounded - E_L) + I_spike - I_syn_exc - I_syn_inh - w + I_e + I_stim) / C_m
w' = (a * (V_bounded - E_L) - w) / tau_w
Expand Down Expand Up @@ -96,13 +98,19 @@ model aeif_cond_exp_neuron:
I_e pA = 0 pA

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
spike_in_port <- spike
I_stim pA <- continuous

output:
spike

onReceive(spike_in_port):
# route the incoming spike on the basis of the weight: less than zero means an inhibitory spike; greater than zero means an excitatory spike
if spike_in_port < 0:
g_syn_inh += spike_in_port * nS * s
else:
g_syn_exc += spike_in_port * nS * s

update:
if refr_t > 0 ms:
# neuron is absolute refractory, do not evolve V_m
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/hh_cond_exp_destexhe_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ model hh_cond_exp_destexhe_neuron:
D_inh uS**2/ms = 2 * sigma_noise_inh**2 / tau_syn_inh

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/hh_cond_exp_traub_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ model hh_cond_exp_traub_neuron:
I_e pA = 0 pA

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/hh_moto_5ht_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ model hh_moto_5ht_neuron:
alpha mmol/pA = 1E-5 mmol/pA

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/hh_psc_alpha_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ model hh_psc_alpha_neuron:
beta_h_init real = 1. / ( 1. + exp( -( V_m_init / mV + 35. ) / 10. ) )

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_chxk_2008_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ model iaf_chxk_2008_neuron:
PSConInit_AHP real = G_ahp * e / tau_ahp * (ms/nS)

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
16 changes: 8 additions & 8 deletions models/neurons/iaf_cond_alpha_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ model iaf_cond_alpha_neuron:
refr_t ms = 0 ms # Refractory period timer

equations:
kernel g_inh = (e/tau_syn_inh) * t * exp(-t/tau_syn_inh)
kernel g_exc = (e/tau_syn_exc) * t * exp(-t/tau_syn_exc)
kernel g_inh = (e / tau_syn_inh) * t * exp(-t / tau_syn_inh)
kernel g_exc = (e / tau_syn_exc) * t * exp(-t / tau_syn_exc)

inline I_syn_exc pA = convolve(g_exc, exc_spikes) * nS * ( V_m - E_exc )
inline I_syn_inh pA = convolve(g_inh, inh_spikes) * nS * ( V_m - E_inh )
inline I_leak pA = g_L * ( V_m - E_L )
inline I_syn_exc pA = convolve(g_exc, exc_spikes.weight) * (V_m - E_exc)
inline I_syn_inh pA = convolve(g_inh, inh_spikes.weight) * (V_m - E_inh)
inline I_leak pA = g_L * (V_m - E_L)

V_m' = ( -I_leak - I_syn_exc - I_syn_inh + I_e + I_stim ) / C_m
V_m' = (-I_leak - I_syn_exc - I_syn_inh + I_e + I_stim) / C_m
refr_t' = -1e3 * ms/s # refractoriness is implemented as an ODE, representing a timer counting back down to zero. XXX: TODO: This should simply read ``refr_t' = -1 / s`` (see https://github.com/nest/nestml/issues/984)

parameters:
Expand All @@ -68,8 +68,8 @@ model iaf_cond_alpha_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike(weight nS)
inh_spikes <- spike(weight nS)
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_cond_beta_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ model iaf_cond_beta_neuron:
g_I_const real = 1 / (exp(-t_peak_I / tau_syn_decay_I) - exp(-t_peak_I / tau_syn_rise_I))

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_cond_exp_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ model iaf_cond_exp_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_cond_exp_sfa_rr_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ model iaf_cond_exp_sfa_rr_neuron:
I_e pA = 0 pA

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_psc_alpha_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ model iaf_psc_alpha_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_psc_exp_dend_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ model iaf_psc_exp_dend_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/iaf_psc_exp_htum_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ model iaf_psc_exp_htum_neuron:
RefractoryCountsTot integer = steps(t_ref_tot) [[RefractoryCountsTot > 0]]

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
exc_spikes <- spike
inh_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
16 changes: 8 additions & 8 deletions models/neurons/iaf_psc_exp_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ model iaf_psc_exp_neuron:
I_e pA = 0 pA

input:
exc_spikes <- excitatory spike
inh_spikes <- inhibitory spike
spike_in_port <- spike(weight pA)
I_stim pA <- continuous

output:
spike

onReceive(spike_in_port):
# route the incoming spike on the basis of the weight: less than zero means an inhibitory spike; greater than zero means an excitatory spike
if spike_in_port.weight > 0 pA:
I_syn_exc += spike_in_port.weight
else:
I_syn_inh -= spike_in_port.weight

update:
if refr_t > 0 ms:
# neuron is absolute refractory, do not evolve V_m
Expand All @@ -95,12 +101,6 @@ model iaf_psc_exp_neuron:
# neuron not refractory
integrate_odes(I_syn_exc, I_syn_inh, V_m)

onReceive(exc_spikes):
I_syn_exc += exc_spikes * pA * s

onReceive(inh_spikes):
I_syn_inh += inh_spikes * pA * s

onCondition(refr_t <= 0 ms and V_m >= V_th):
# threshold crossing
refr_t = refr_T # start of the refractory period
Expand Down
4 changes: 2 additions & 2 deletions models/neurons/izhikevich_psc_alpha_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ model izhikevich_psc_alpha_neuron:
I_e pA = 0 pA

input:
inh_spikes <- inhibitory spike
exc_spikes <- excitatory spike
inh_spikes <- spike
exc_spikes <- spike
I_stim pA <- continuous

output:
Expand Down
Loading
Loading