Reset Neuron Variable at each time-step of simulation

59 views
Skip to first unread message

llew...@gmail.com

unread,
Sep 13, 2016, 9:32:01 PM9/13/16
to Brian Development
Hi there,

I am trying to simulate SNN silicon chips. I want a variable in the neuron equation to be the sum of all pre-synaptic current at each time the equation is evaluated. 

Unfortunately all of the examples the synapses only increment a neuron variable on on_pre. 

Is there a way for me to increment a value in the neuron equation so that it can add to the membrane current but then reset it after this comparison at each timestep?

as in (simplified):
dImem/dt = sum(Isynapses)/tau

rather than
dImem/dt = Iin/tau

synapses(on_pre="Iin+=Isynapse")

Doing it this way doesn't have the desired effect as Iin will just grow. Resetting Iin at each spike is also not a great solution. 

Hope that all makes sense.

Cheers,

Llewyn

Marcel Stimberg

unread,
Sep 22, 2016, 4:02:45 AM9/22/16
to brian-de...@googlegroups.com
Hi Llewyn,

If you want your synapses to only have an instantaneous effect (i.e.
only an effect during the exact time step where the spike arrived), then
you can directly increase the membrane potential instead of a separate
current variable, e.g. your equation could be (in the simplest case)
"dvm/dt = -vm/tau" and your on_pre statement would be "vm += Isynapse"
-- Isynapse would have to have units of volts in this case, of course.
This synapse model is used for example here:
http://brian2.readthedocs.io/en/stable/examples/adaptive_threshold.html

Best,
Marcel

llew...@gmail.com

unread,
Sep 26, 2016, 11:44:11 AM9/26/16
to Brian Development
Yeah that's what I ended up going with.

The problem is that the full equation is 

 dIsyneP/dt=(-Ithe-IsyneP)/(taue*(1+Ithe/(IsyneP+smallValue))) : amp

and for each synapse I just do.

IsyneP += Iw/Itau*Ith

In reality I want the IsyneP in the numerator to be incremented but not the IsyneP in the denominator. As the equation should be 

 dIsyneP/dt=(Sum(Iw)/Itau*Ith-Ithe-IsyneP)/(taue*(1+Ithe/(IsyneP+smallValue))) : amp

Where Iw is the synaptic weight. 

Cheers,

Llewyn

Marcel Stimberg

unread,
Sep 26, 2016, 11:58:31 AM9/26/16
to brian-de...@googlegroups.com
Hi Llewyn,

I'd have to think about this a bit more, I am not sure there is an
"elegant" solution. If I am not mistaken, then the differential equation
does not make much sense from a biological/physical point of view, if Iw
is the sum of synaptic activity during that time step: the synaptic
effect would scale with the length of the simulation time step.

Either way, you *can* reset a variable after every time step using
run_regularly. Something along these lines should work:

eqs = '''

dIsyneP/dt =
(Iw/Itau*Ith-Ithe-IsyneP)/(taue*(1+Ithe/(IsyneP+smallValue))) : amp

Iw : 1 # should use the appropriate unit, though

'''

group = NeuronGroup(n_neurons, eqs, ...)

group.run_regularly('Iw = 0') # Reset Iw at the start of each time step

syn = Synapses(..., group, on_pre='Iw += ...')


Hope that helps, best

Marcel


Message has been deleted

llew...@gmail.com

unread,
Sep 28, 2016, 11:31:22 AM9/28/16
to Brian Development
Hi Marcel,

Thanks for that.

Is there a way to make the synapses act as a pulse rather as instantaneous current injection?

Cheers,

Llewyn

Marcel Stimberg

unread,
Sep 29, 2016, 9:41:34 AM9/29/16
to brian-de...@googlegroups.com
Hi,


> However, performing the run_regularly I get no spikes from the neurons
> no matter how high I set the current injection. Doing it the more
> standard plausible way that is done in brian2 I can get responses but
> they go pretty strange pretty fast.

hmm, difficult to say what is going wrong there. I guess the best
approach would be to introduce several StateMonitor with different when
arguments (see
http://brian2.readthedocs.io/en/stable/user/running.html#scheduling) to
see what exactly happens during a time step.

Best,
Marcel

Marcel Stimberg

unread,
Sep 29, 2016, 9:42:46 AM9/29/16
to brian-de...@googlegroups.com
Hi,


>
> Is there a way to make the synapses act as a pulse rather as
> instantaneous current injection?

can you be a bit more specific what you mean by "act as a pulse"? I
guess the answer is "yes", but it depends what you mean by it :)

Best,
Marcel

llew...@gmail.com

unread,
Sep 29, 2016, 3:10:48 PM9/29/16
to Brian Development
Just resetting it to 0 every time-step was the problem. Extending it for several time-steps made it work and make some sense in the context that when a pre-neuron in these circuits fires the synapse will inject a current into the next part of the circuit as a pulse (So the synapse will essentially remain on for some period of time.) . 
However, obviously run_regularly will reset the variable regularly rather than from say an event. It would be more accurate if the synapse say on_pre="val+=someotherVal" but have this effect happen over a set amount of time steps once even when the pre-synaptic firing is not happening.
Hopefully I am making some sense :).

Marcel Stimberg

unread,
Sep 30, 2016, 8:51:58 AM9/30/16
to brian-de...@googlegroups.com
Hi,

if I understand correctly, you want to have some post-synaptic current
be a rectangular pulse over a certain time, right? You can implement
this using two synaptic pathways
(http://brian2.readthedocs.io/en/stable/user/synapses.html#multiple-pathways):
the first one makes the current go up and the second one makes the
current go down again. With the delay of the second pathway you set the
width of the pulse. Something along these lines (here for a 2.5ms long
pulse):

synapses = Synapses(inp, target,
on_pre={'synapse_on': 'I_syn += 1',
'synapse_off': 'I_syn -= 1'})
synapses.connect()
synapses.synapse_off.delay=2.5*ms

Best,

Marcel


Reply all
Reply to author
Forward
0 new messages