Multiple simulations: spawning a new graph on each run

The basics of how to develop, test, and use models.
Post Reply
tsa
Posts: 31
Joined: Mon Mar 26, 2007 12:44 pm

Multiple simulations: spawning a new graph on each run

Post by tsa »

Hello,

I am also trying to automate multiple simulations. I am examining a single bursting cell and varying a maximal conductance with each automated simulation. Though I have the automated process to vary the conductance and repeatedly run the simulation down correctly I have not figured out how to make each trial output to a separate graph without overwriting the previous trials. Currently each trial outputs a voltage trace to the same graph via the Keep Lines option but this makes examining the data quite difficult due to trace overlap. Any advice would be greatly appreciated.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Multiple simulations: spawning a new graph on each run

Post by ted »

Each time you spawn a graph that you want to save, append it to a List. Example:

Code: Select all

objref g, glist
glist = new List()

proc myrun() {
  g = new Graph()
  glist.append(g)
  run()
}
tsa
Posts: 31
Joined: Mon Mar 26, 2007 12:44 pm

Re: Multiple simulations: spawning a new graph on each run

Post by tsa »

Thanks Ted, however now I am returned multiple graph windows as the simulations complete but no voltage trace is plotted on any of the graphs.
My code for myrun is as follows:

proc myrun() {
graph5 = new Graph()
graph5.addvar("Cell[0].soma.v(0.5)", 3,1,0.8,0.9,2)
glist.append(graph5)
run()
}
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Multiple simulations: spawning a new graph on each run

Post by ted »

Did you rescale the axes with View = plot?
g.exec_menu("View = plot")
Be sure to read the Programmer's Reference info about the Graph class's exec_menu method.

If you don't like the default appearance created by View = plot, you can have complete control over axis scaling etc. by following the approach described here
How to use hoc to plot a variable vs. time
http://www.neuron.yale.edu/phpBB/viewto ... f=30&t=552
tsa
Posts: 31
Joined: Mon Mar 26, 2007 12:44 pm

Re: Multiple simulations: spawning a new graph on each run

Post by tsa »

The axis are scaled correctly and using "view = plot" does not reveal anything new. On a separate graph I can visualize the voltage traces as the simulations run, though each voltage trace is overwritten at the beginning of a new simulation. However, no traces appear on the graph's created by the myrun() procedure.
tsa
Posts: 31
Joined: Mon Mar 26, 2007 12:44 pm

Re: Multiple simulations: spawning a new graph on each run

Post by tsa »

I realized I omitted the vital line: graphlist[0].append(graph5). With its inclusion I now have a new graph created upon each trial and each new graph plots the voltage trace. However, each graph respawns the previous voltage trace as each new trial is automatically run. Is there a way to essentially turn off the automated updating of the graph upon the completion of each simulation?
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Multiple simulations: spawning a new graph on each run

Post by ted »

tsa wrote:However, each graph respawns the previous voltage trace as each new trial is automatically run.
Actually, each graph will show the results from the _current_ simulation, because each graph has the same variable in its plot list, and that variable's values are generated anew in the course of each simulation.

So use the Vector class's record() method to capture the time course of variables of interest, then plot them after the end of each simulation. Example (assumes the existence of a section called soma):

Code: Select all

objref vvec, tvec, glist, g
vvec = new Vector()
vvec.record(&soma.v(0.5))
tvec = new Vector()
tvec.record(&t)
glist  = new List()

proc myrun() {
  run()
  g = new Graph()
  vvec.plot(&g, t)
  glist.append(g)
}
Post Reply