Update summed variables with general function

22 views
Skip to first unread message

Wilhelm Braun

unread,
Oct 24, 2019, 11:10:36 AM10/24/19
to Brian Development
Dear all,

I would like to update a summed synaptic variable according to a rule that, for example, states that whenever the input exceeds a certain value, the variable should jump, but stay constant/ assume some other value otherwise. Can I also make this time-dependent, e.g. say that the jump should only happen when the number of synaptic input spikes exceeds a certain value in a certain fixed time window?
The code below is directly copied from the brian2 documentation, with a simplification. Can it somehow be augmented with a simple if-statement to take into account the above features?

Thanks a lot for your suggestions.

Best,

Wilhelm

neurons = NeuronGroup(1, model='''dv/dt=(gtot-v)/(10*ms) : 1
gtot : 1'''
)
S
= Synapses(input, neurons,
model
='''gtot_post = g : 1 (summed) #gtot is directly increased upon arrival of a pre-synaptic spike
w : 1 # synaptic weight'''
, on_pre='g+=w') #How to add if-statement here that says how g should be increased depending on number and timing of incoming spikes?


Marcel Stimberg

unread,
Oct 24, 2019, 12:19:05 PM10/24/19
to brian-de...@googlegroups.com
Hi Wilhelm,

your problem does not seem to call for a "simple if-statement", since
all neuron/synapse code is written from the point of view of a single
neuron/synapse, and you therefore cannot express conditions over several
neurons/synapses. I don't think a summed variable is what you need here
either, this is really only needed for synaptic effects where you need
to keep track of the individual contributions all the time due to
non-linearities.

I'm not sure whether I understood your problem 100% correctly, but the
following two approaches might give you some ideas:

1. You use an "effective input" that is a heaviside function of the
actual input:

inp_threshold = 2
inp_strength =3
neurons = NeuronGroup(1, model='''dv/dt = (effective_inp - v)/(10*ms) : 1
                                  effective_inp = int(inp >
inp_threshold)*inp_strength : 1
                                  dinp/dt = -inp/(5*ms) : 1''')
S= Synapses(input, neurons, model='w : 1', on_pre='inp += w')

The effective input will be 3 whenever the total input is over 2, and 0
otherwise. The total input will decay with a time constant of 5ms, so
the spreading out inputs over a long time will not trigger it, and the
effective input will only stay active for a while.

2. A similar approach, but instead of directly transforming the raw
input into an effective input, you use the raw input to trigger an event
that increase the membrane potential (could also trigger a current or a
conductance of course).

inp_threshold = 2
inp_strength =3
neurons = NeuronGroup(1, model='''dv/dt = - v/(10*ms) :
                                  dinp/dt = -inp/(5*ms) : 1''',
                      events={'input_triggered': 'inp > inp_threshold'})
neurons.run_on_event('input_triggered', 'v += inp_strength')
S= Synapses(input, neurons, model='w : 1', on_pre='inp += w')

Best,

  Marcel


Wilhelm Braun

unread,
Oct 30, 2019, 1:21:09 PM10/30/19
to Brian Development
Thank you very much for this detailed reply. It helped a lot.

Can you maybe additionally tell me whether it is possible to evoke the 'input_triggered' event only after a certain refractory period, such that 'inp' needs to be larger than 'inp_threshold' AND a fixed time needs to have elapsed since the last 'input_triggered' event on that synapse?

Thanks for your reply.

Best,

Wilhelm

Marcel Stimberg

unread,
Oct 30, 2019, 1:36:24 PM10/30/19
to brian-de...@googlegroups.com
Hi,

> Can you maybe additionally tell me whether it is possible to evoke the
> 'input_triggered' event only after a certain refractory period, such
> that 'inp' needs to be larger than 'inp_threshold' AND a fixed time
> needs to have elapsed since the last 'input_triggered' event on that
> synapse?

This would indeed be quite similar to a refractory period of a neuron,
you can store the time of the last event for each neuron and use it as
part of the condition:

inp_threshold = 2
inp_strength = 3
event_delay = 5*ms
neurons = NeuronGroup(1, model='''dv/dt = - v/(10*ms) :
                                  dinp/dt = -inp/(5*ms) : 1
                                  last_event : second''',
                       events={'input_triggered': '(inp >
inp_threshold) and (t>last_event+event_delay)'})
neurons.run_on_event('input_triggered', '''v += inp_strength
                                           last_event = t''')
neurons.last_event = -1e9*ms  # initial value = "never"

Wilhelm Braun

unread,
Nov 5, 2019, 4:29:28 AM11/5/19
to Brian Development
Thanks a lot for your quick reply.
Best, Wilhelm
Reply all
Reply to author
Forward
0 new messages