pause function

The basics of how to develop, test, and use models.
Post Reply
chinhou

pause function

Post 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?
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

No, but you can fake it with startsw().

Code: Select all

proc pause() { local t0
  t0 = startsw()
  while (startsw()-t0 < $1) { }
}
oren
Posts: 55
Joined: Fri Mar 22, 2013 1:03 am

Re:

Post 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.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: pause function

Post 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.
Post Reply