Page 1 of 1

why: newPlotV() != new Graph()

Posted: Sun Feb 12, 2012 9:24 am
by pfortier
Why is

Code: Select all

newPlotV()
g=graphItem
not the same as

Code: Select all

g=new Graph()
When I look at the display, I see that newPlotV() creates a voltage plot with the object stored in graphItem which I can copy to g. The same thing appears to occur with g=new Graph(). However, they are not interchangable as shown in the code below.

Code: Select all

// set globals
tstop=300
// create cell
create acell
access acell
objref izh,nc
acell izh=new IZH(0.5) // connect point process to cell
izh.a=0.02 
izh.b=0.2 
izh.c=-65 
izh.d=6
izh.f=5 
izh.g=140
izh.vv=-70
izh.u=izh.b*izh.vv
izh.I=0//10
nc = new NetCon(&izh.vv,izh) // when izh.vv > nc.threshold then izh repolarizes spike
nc.threshold=30
nc.delay = 0 
// setup neuron voltage display
objref gV
newPlotV() 
gV=graphItem 
//gV = new Graph() // this does the same as the 2 steps above but it doesn't work
gV.size(0,tstop,-100,50)
gV.addvar("izh.vv",2,2) 
run()
Thanks,
Pierre

Re: why: newPlotV() != new Graph()

Posted: Sun Feb 12, 2012 12:35 pm
by ted
Are you referring to the fact that a Graph object created by
newPlotV()
is automatically updated during a simulation, but that the Graph object created by
foo = new Graph()
is not?

Re: why: newPlotV() != new Graph()

Posted: Sun Feb 12, 2012 12:56 pm
by pfortier
Yes.

I just figured out that if I use:

Code: Select all

gV = new Graph()
graphList.append(gV)
then it correctly displays the trace. So I guess that only Graph[s] in the graphList get updated.

Re: why: newPlotV() != new Graph()

Posted: Sun Feb 12, 2012 1:36 pm
by ted
objref g
g = new Graph()
merely creates a new instance of the Graph class. g.addvar(variable_name) adds the argument variable to a List of items that will be plotted on g when g.plot(abscissa) is called. But that begs the question of how to ensure that g.plot(t) will be called at every advance of a simulation.

The answer is: append g to one of the run control system's graphLists. There are 4 graphLists, and the difference between them is what they use as the abscissa. graphList[0] uses the current value of t for the abscissa and is appropriate for most applications.

NEURON's graphLists, and how to use them, are discussed at the end of chapter 7 of The NEURON Book.

If you are curious about how newPlotV() works, and would like to discover other interesting things about NEURON's run control system (also called its "standard run system"), including many functions, procedures, and variables that may be immediately useful in your own programs, you might want to examine stdrun.hoc in nrn-x.x/share/nrn/lib/hoc (under MSWin this is c:\nrn-x.x\lib\hoc)