"turn off" Netstim in the middle of simulation

Moderator: wwlytton

Post Reply
breakwave922

"turn off" Netstim in the middle of simulation

Post by breakwave922 »

I have a network model by NEURON, and each cell has its stochastic input. To do this, I used Netstim to generate random inputs for each cell.
However, I plan to "turn off" these Netstim inputs after certain time point, without terminating simulation. The certain time point is triggered by the algorithm that I designed: Network has real-time calculation of whether the collective activities have met some threshold requirement at each time step. If the requirement is met, I want to turn off Netstim events, but let simulation keep going.

I already implemented real-time detection part, but I couldn't figure out how to turn off the Netstim events after certain time point.

Any help would be appreciated.

Thanks in advance.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: "turn off" Netstim in the middle of simulation

Post by ted »

I already implemented real-time detection part
Good. That's the hard part. When the condition "time to turn off the NetStim" happens, use a NetCon's event() method to send an event with weight < 0 to the NetStim that you want to turn off. Read the Programmer's Reference documentation of the NetStim class to understand how events can turn a NetStim on or off https://www.neuron.yale.edu/neuron/stat ... ml#NetStim. Also read the documentation of the NetCon class's event() method https://www.neuron.yale.edu/neuron/stat ... tCon.event
breakwave922

Re: "turn off" Netstim in the middle of simulation

Post by breakwave922 »

Dear Ted,

Thanks for the reply. It helps!
Read the Programmer's Reference documentation of the NetStim class to understand how events can turn a NetStim on or off https://www.neuron.yale.edu/neuron/stat ... ml#NetStim. Also read the documentation of the NetCon class's event() method https://www.neuron.yale.edu/neuron/stat ... tCon.event
I found that if I use NetCon.event(t,flag) (I set flag=-1 at detected time point), it had error "can only send fake self-event to ARTIFICIAL_CELLs". As it said, the reason is I didn't use artificial cells. However, I can use NetCon.active(0) to turn the NetStim events off at&after detected time point. Alternatively, by setting NetCon.weight=0 works similarly.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: "turn off" Netstim in the middle of simulation

Post by ted »

Not flag. weight. weight is an attribute of a NetCon. Quoting directly from the documentation of NetStim:
If, in the on=1 state, the stimulator receives a negative weight event, the stimulator will change to the off state.
But to do that, you'd have to create a special NetCon, with negative weight, whose only reason to exist is to send a single event to the NetStim that you want to turn off.

I like your approach, which is more direct and doesn't require that extra NetCon.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: "turn off" Netstim in the middle of simulation

Post by ted »

I can use NetCon.active(0) to turn the NetStim events off at&after detected time point. Alternatively, by setting NetCon.weight=0 works similarly.
You should probably run a test to make sure that whatever you're doing is working properly. Executing
netcon.weight[0] = 0
at some time t should prevent events that arrive at later times from affecting the target. But does executing
netcon.active(0)
block events that are already in the event queue? One way to find out is to set up a toy network in which a presynaptic NetStim generates an event at time t1 that is sent to a postsynaptic target by a NetCon whose delay is d1. Then run a simulation in which the NetCon is inactivated at time t2 where t2 lies between t1 and t1+d1. Reasonable values would be
t1 = 5 ms
d1 = 2 ms
t2 = 6 ms
Post Reply