Hi,
Dose NEURON have " pause " function, like Matlab pause for t second
in Matlab: pause (0.5)
what's its analog in NEURON?
pause function
-
- Site Admin
- Posts: 6299
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
No, but you can fake it with startsw().
Code: Select all
proc pause() { local t0
t0 = startsw()
while (startsw()-t0 < $1) { }
}
Re:
ted wrote:No, but you can fake it with startsw().Code: Select all
proc pause() { local t0 t0 = startsw() while (startsw()-t0 < $1) { } }
Normally in Matlab I use the pause option, so that I can plot with delay multiplay graphs on the same plot. and see them add to the graph one by one in 0.5 s interval( Each 0.5s new one adds )
I tried using your option to do this. But it did not worked, the graphs are frozen until the script ends.
This is part of my code:
Code: Select all
for i=1, Delay_v.size(){
Se.dur1 = Delay_v.x[i-1] + SEdur //each run of the loop a different duration of SEClamp
STARTSEC = Delay_v.x[i-1] // The time the SEClamp start
finitialize(Start_Voltage)
while(t<t_stop) { fadvance()
V_Graph.plot(t)
I_Graph.plot(t)
InaIk_Graph.plot(t)
}
V_Graph.flush()
I_Graph.flush()
InaIk_Graph.flush()
pause(1)
}
Is there anything that can be done?
Thank You.
-
- Site Admin
- Posts: 6299
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: pause function
Save this to a file called pause.hoc.Organize your model code like this:Then at the oc> prompt enter a command like
pauserun(1,0.5)
where the first argument is the time in seconds that you want to wait to see the stimulation advance, and the second argument is the model time in milliseconds that it will advance.
Code: Select all
// argument is in seconds
func pause() { local tmp
tmp=startsw()
while (startsw()-tmp<$1) { }
return startsw()-tmp
}
// At intervals of $1 seconds runs for $2 ms model time,
// then pauses, until t>=tstop.
proc pauserun() {
runStopIn = $2
stdinit()
while (t<tstop) {
running_ = 1
continuerun(t+runStopIn)
stoprun=1
pause($1)
}
}
Code: Select all
. . . all of your model and user interface code . . .
load_file("pause.hoc")
pauserun(1,0.5)
where the first argument is the time in seconds that you want to wait to see the stimulation advance, and the second argument is the model time in milliseconds that it will advance.