Page 1 of 1

Porting AtolTool settings to GUI-less batch simulation

Posted: Fri Nov 09, 2018 10:12 am
by mzenker
Hi,

I want to port a model from use with the GUI to a batch mode controlled by Python. Everything seems to work except for the variable timestepping settings which were done using the AtolTool (see viewtopic.php?f=28&t=3232). I have the following code in my .ses file:

Code: Select all

objectvar save_window_, rvp_
objectvar scene_vector_[6]
objectvar ocbox_, ocbox_list_, scene_, scene_list_
{ocbox_list_ = new List()  scene_list_ = new List()}

//Begin VariableTimeStep
{
ocbox_ = NumericalMethodPanel[0]
}
{object_push(ocbox_)}
{
atol_ = 0.001  CVode[0].atol(atol_)
restore(412, 1)
 atoltool_ = new AtolTool()
    ats("v", 10)
    ats("vext", 10)
    ats("mp_axnode", 0.1)
    ats("m_axnode", 0.1)
    ats("h_axnode", 0.1)
    ats("s_axnode", 0.01)
    ats("Vector", -1)
 atoltool_.scales()
}
{object_pop()}
{
ocbox_.map("VariableTimeStep", 12, 990, 287.1, 342.9)
}
objref ocbox_
//End VariableTimeStep

objectvar scene_vector_[1]
{doNotify()}
If I load that in my Python script, it fires up the AtolTool window which I don't want. So I tried to make a file with stripped and modified the code:

Code: Select all

cvode.atol(0.001)
cvode.atolscale("v", 10)
cvode.atolscale("vext", 10)
cvode.atolscale("mp_axnode", 0.1)
cvode.atolscale("m_axnode", 0.1)
cvode.atolscale("h_axnode", 0.1)
cvode.atolscale("s_axnode", 0.01)
//cvode.atolscale("Vector", -1)
The last line is commented out since it gives a "Arg out of range in user function" error. But this omitting it changes the simulation results.
So what is the correct way to port it? A negative tolerance does not make sense, but what does "-1" mean in this case?

Thank you for hints and explanations...
Matthias

Re: Porting AtolTool settings to GUI-less batch simulation

Posted: Sun Nov 11, 2018 1:29 pm
by ted
Not sure why it is necessary to do anything special. Just let your hoc code load the configured variable step control's ses file. NEURON produce the same numerical results regardless of whether it was compiled with or without InterViews, or whether it is executed on a machine that even has graphics capabilities. Also, on-screen rendering of the GUI's graphical elements can be suppressed by including
-nogui
in the command line, e.g. nrngui -nogui foo.hoc, without affecting numerical results.

By the way, what do you mean by "batch mode"? Launching a new instance of NEURON for each separate run? Or launching it once, then running simulations one after another without exiting until done? The former is fine for embarrassingly parallel simulations, but on serial hardware the latter will run a bit faster because model setup code is executed only once. Of course this assumes that a simulation produces the same result regardless of how many other simulations, which may have used other parameters, have already been executed without exiting NEURON). And time savings can be negated if a significant amount of model setup code is embedded in the simulation initialization code (an unusual practice that is generally neither necessary nor advisable).

Re: Porting AtolTool settings to GUI-less batch simulation

Posted: Mon Nov 12, 2018 8:14 am
by mzenker
Thank you for your reply and additional hints!
ted wrote: Sun Nov 11, 2018 1:29 pm Also, on-screen rendering of the GUI's graphical elements can be suppressed by including
-nogui
in the command line, e.g. nrngui -nogui foo.hoc, without affecting numerical results.
How do I do that from within Python? The AtolTool window opens even if I do not "import gui".
ted wrote: Sun Nov 11, 2018 1:29 pm By the way, what do you mean by "batch mode"?
Launching a new instance of NEURON for each separate run? Or launching it once, then running simulations one after another without exiting until done?
The latter. I am searching stimulation thresholds for different stimuli, so only the stimulus changes between successive runs.

Re: Porting AtolTool settings to GUI-less batch simulation

Posted: Mon Nov 12, 2018 12:14 pm
by ted
Sounds like a cosmetic problem to me--not a beauty spot, but not exactly a wart, as long as the tool works so I don't have to manually transcribe error tolerance scale factors into hoc or Python statements. Maybe someone else can suggest a way to use the tool from Python without actually seeing its GUI.

Re: Porting AtolTool settings to GUI-less batch simulation

Posted: Mon Nov 12, 2018 12:19 pm
by mzenker
ted wrote: Mon Nov 12, 2018 12:14 pm Sounds like a cosmetic problem to me...
You are right, of course.
I use it as it is now. I thought that not running all those plots during the simulation would save me some time in an unattended run (don't know it it's true), so while I was at it I wanted to run without the GUI completely. But the AtolTool doesn't do anything during simulation anyway, so it is no problem if it hangs around on the Desktop...

Re: Porting AtolTool settings to GUI-less batch simulation

Posted: Mon Nov 12, 2018 12:48 pm
by ted
Nothing in the Atol Scale tool's user interface is updated during a run, so it's not a problem.
Graphs with t as the independent variable that are linked to the standard run system's plotlists will be updated during a simulation, but whether or not they pose a significant computational burden will depend on many factors (how many traces are being updated etc.). Space plots (plots of range variables vs. anatomical distance along a path) and shape plots (in which color represents the dependent variable) will be refreshed only at the end of the simulation, so they're not a problem.

I don't know of a command line switch that can be used to disable NEURON's GUI rendering if you're running Python and using NEURON as a module. Maybe there's some other way to do this.