Page 1 of 1

pause function

Posted: Fri Feb 23, 2007 4:23 pm
by chinhou
Hi,

Dose NEURON have " pause " function, like Matlab pause for t second

in Matlab: pause (0.5)

what's its analog in NEURON?

Posted: Sat Feb 24, 2007 2:17 pm
by ted
No, but you can fake it with startsw().

Code: Select all

proc pause() { local t0
  t0 = startsw()
  while (startsw()-t0 < $1) { }
}

Re:

Posted: Mon Jul 01, 2013 4:31 am
by oren
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.

Re: pause function

Posted: Fri Jul 12, 2013 2:34 pm
by ted
Save this to a file called pause.hoc.

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)
  }
}
Organize your model code like this:

Code: Select all

. . . all of your model and user interface code . . .
load_file("pause.hoc")
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.