Hello I am trying to run a loop of different plots
Using a for loop in my biophysics hoc file I am able to change a specific ion channel in steps of 0.1.
What I would like to do is to be able to call the biophysics hoc in each iteration and plot the corresponding waveforms on different plots
Some direction in this matter would be greatly appreciated
Thanks
multiple itertions of plots
Moderator: wwlytton
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: multiple itertions of plots
Start by writing an outline that expresses the whole task as a sequence of simpler tasks. Example:This assumes that you want each simulation's results to appear in a separate graph.
Note that "run a simulation" is simply run() if you are using NEURON's standard run system; if you aren't, why aren't you?
Code: Select all
someparameter = startvalue
while (someparameter <= endvalue) {
run a simulation
plot results
increase someparameter by someincrement
}
Note that "run a simulation" is simply run() if you are using NEURON's standard run system; if you aren't, why aren't you?
Re: multiple itertions of plots
Hey Ted
I worked thanks
Only problem is all 10 plots are graphing the last iteration of the loop, any way I can get it to graph a plot for every iteration?
Thanks
I worked thanks
Only problem is all 10 plots are graphing the last iteration of the loop, any way I can get it to graph a plot for every iteration?
Thanks
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: multiple itertions of plots
Yes, and you probably noticed that each time you add a new graph, the simulation takes longer to run. The problem is that each graph has the same list of variables that are to be plotted vs. t.
Instead of plotting somevar vs. t, you need to
Then you can create a series of recordings of somevar and t, and plot each recorded pair in its own Graph. Here's how.where newgraph() is
If you want to make your program a bit nicer, change your while loop to a procedure like soThen you can launch a batch run like so
batchrun(startvalue, endvalue)
Instead of plotting somevar vs. t, you need to
Code: Select all
// after model setup but before your loop that runs a bunch of simulations
. . . code that sets up Vector recording of somevar and t to a pair of Vectors somevarvec and tvec . . .
Code: Select all
// the ith element of each of these lists
// will correspond to the i+1'th run
objref somevarveclist, tveclist, glist
somevarveclist = new List()
tveclist = new List()
glist = new List()
someparameter = startvalue
while (someparameter <= endvalue) {
run a simulation
glist.append(newgraph(somevarvec, tvec))
increase someparameter by someincrement
}
Code: Select all
obfunc newgraph() { localobj xtmp, ytmp, gtmp
ytmp = $o1.c // make copies of the data to be plotted
xtmp = $o2.c
somevarveclist.append(ytemp) // save these copies
tveclist.append(xtmp)
gtmp = new Graph() // plot them
ytmp.plot(gtmp,xtmp)
gtmp.exec_menu("View = plot")
return gtmp
}
Code: Select all
objref paramvals
paramvals = new Vector()
proc batchrun() {
paramvals = new Vector()
somevarveclist = new List() // discard results of previous batch run
tveclist = new List()
glist = new List()
someparameter = $1
while (someparameter <= $2) {
run a simulation
glist.append(newgraph(somevarvec, tvec))
paramvals.append(someparameter)
increase someparameter by someincrement
}
}
batchrun(startvalue, endvalue)