tine wrote:Your answer to the second question was easy to implement and is working fine.
A caveat: the method I presented requires that the path from origin to termination pass from parent to child for each section along the path.
Now that I re-examine the documentation of the RangeVarPlot class, I see something that would have saved some time and effort, and which works even if the path changes direction i.e. starts out by going from child to parent, before turning around and coming back down from parent to a different child: the list() method
http://www.neuron.yale.edu/neuron/stati ... .html#list
So if there is a range variable plot called rvp that originates in dendrite_1[8] and terminates in dendrite_1[13], it is enough to do
Code: Select all
objref path
path = new SectionList()
rvp.list(path)
and presto! the first element in path will refer to dendrite_1[8], the last element will refer to dendrite_1[13], and the other elements will refer, in proper sequence--from parent to child--to the sections that lie between dendrite_1[8] and dendrite_1[13]. Much cleaner than what I wrote in my previous post, which generated a SectionList in which the sequence was from child to parent.
For the first question, saving the data in a big matrix, I still have some difficulties.
and others are lurking; more about those later.
The matrix is formed with the right dimensions and put in the requested dat file without warnings, but is I open the dat file all the values are not seperated: -650-70 instead off -650 -70.
So change the format string. You'll find a brief discussion of options available in hoc here
http://www.neuron.yale.edu/neuron/stati ... tml#printf
but the fact that you asked about it suggests that you'll want to read more than what the Programmer's Reference provides. Any decent reference on C or C++ (of which there are probably several on line) should contain a more complete discussion of format strings with examples.
Now the difficulties to which I referred above.
Deferring actual file output until after completion of the run is OK as long as storage allows. However, if you're going to do that, you're probably better off taking advantage of the Vector class's record() method instead of using hoc statements to move data around at each fadvance(). Also, using int(t/dt) to calculate the column index is going to run into roundoff error at some point, with the result that you'll either skip columns, or overwrite columns that already contained data.
Here's how to avoid these problems.
After model setup but before calling run, set up Vector record at every internal node along the path of sections, starting with the most proximal section in your range variable plot and moving out to the most distal.
Code: Select all
objref path
path = new SectionList()
rvp.list(path)
objref veclist
proc buildveclist() { localobj tobj
forsec path { // iterate over each section along the path
for (x,0) { // iterate over each internal node in the current section
tobj = new Vector()
tobj.record(&v(x)) // or whatever other range variable you want to capture
veclist.append(tobj)
}
}
}
buildveclist()
Now you have a set of Vectors that will capture the time course of v at each internal node along the path. You only need a custom run procedure, and a procedure that writes results to a file after the end of the run.
Code: Select all
proc run() {
stdinit()
continuerun(tstop)
save_results()
}
proc save_results() { local i, j
. . . open output file . . .
// there are veclist.count() Vectors
// the number of values in each Vector is veclist.o(0).size--
// one value for each point in time at which a solution was computed
for i=0,veclist.o(0).size-1 { // iterate over each point in time
for j=0,veclist.count()-1 { // iterate over each point in space
. . . print veclist.o(j).x[i] to the file . . .
}
. . . print \n to the file . . .
}
. . . close output file . . .
}
That's it. No tinkering with proc advance(). The only drawback is that printing one datum at a time via hoc is not as fast as printing a whole block of numbers at once. You could speed things up by assembling a Matrix out of the recorded Vectors, but that doubles storage requirements. My preference would be to write out one Vector at a time (each row corresponds to the entire time course at a particular point in space)
Code: Select all
for i=0,veclist.count()-1 { // iterate over each point in space
. . . use the Vector class's printf() method to print veclist.o(i) to the file . . .
. . . print \n to the file . . .
}
. . . close output file . . .