Simulation with external feedback

Moderator: wwlytton

Post Reply
ziemek
Posts: 45
Joined: Thu May 23, 2019 8:02 am
Location: Warsaw, Poland
Contact:

Simulation with external feedback

Post by ziemek »

I want to perform multiple runs for the same simulation. Between runs I want to give new stimulations to my neurons, but do not reset the simulation - the network (and its state) must remain the same.

The motivation for this comes from the artificial neural network field (ANN). Just like for ANN you can input many baches and each time read the output from the network, want to do the same for my network with NEURON.

So the activity of my neurons will be entirely driven by external feedback, which depends on the output from a single neuron (reading is performed by a rate codding).

I Tried to use VecStim, so assuming that I have a synaptic PointProcess named target my feedback input may look like this:

Code: Select all


stim = h.VecStim()
stim.play(h.Vector(np.array([10, 20])))

nc = con = h.NetCon(source, target, 1, 0)

h.continuerun(100 * ms)

stim.play(h.Vector(np.array([110, 120])))
h.continuerun(100 * ms)
Unfortunately after a first run, the second run haven't produce any stimulation at all. I assume that the NEURON creates an event_array of stimulation which can't be change this way. But there should be another way to change the pointer to the stimulation vector.

Thanks for your help!

EDIT1:
I found on the NetStim documentation that "NetStim can also be be triggered by an input event."

So I assume this can do the trick? But still I don't know how to change parameters of interval and number - which may express the intensity of the stimuli. I assume the workaround here is to create the NetStim with number=1 and then switch it on and off by NetCon signal, but how in that case control those events timing, if each time I want to create different burst Hz?

Maybe should I use:

Code: Select all

h.cvode.event(...)
But in that case you commit for the variable timestep, but I use the model where as I assume - it may give inconsistent result while timestep is variable.

EDIT2:
My current workaround is as follows:

Code: Select all


stim = h.VecStim()
stim.play(h.Vector(np.array([10, 20])))

nc = con = h.NetCon(source, target, 1, 0)

h.continuerun(100 * ms)

nc.event(110)
nc.event(120)

h.continuerun(100 * ms)
In this case I completely omit NetStim after the first run and deliver events directly to the NetCon.

It works nice, but if I have 300Hz burst to 2000 synapses I'm not sure about the efficacy of this solution.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Simulation with external feedback

Post by hines »

The problem with VecStim is that the mod file implementation did not envision this style of usage. I would recommend adding a restart procedure
which, after you replace the Vector in the middle of a simulation, would set the counter to the first element of the Vector and do a net_send to
activate the NET_RECEIVE block again. Note that it is an error if the Vector has any element less than the current time. Also there could be problems
if the previous Vector did not make it to the end as there would be an outstanding SelfEvent already on the queue. The restart procedur would have
exactly the same contents as the INITIAL block.

Code: Select all

PROCEDURE restart {
        index = 0
        element()
        if (index > 0) {
                net_send(etime - t, 1) : hopefully no event already on the queue from the previous vector
        }
}
Post Reply