Possible bug in Vector's record function

The basics of how to develop, test, and use models.
Post Reply
sl
Posts: 21
Joined: Wed Nov 28, 2007 12:52 am
Location: Cornell University

Possible bug in Vector's record function

Post by sl »

I found that if one uses the third form of Vector's record function (the one with the separate time vector) I get no recorded data for either vector.

Here's a sample code that reproduces the bug for me:

Code: Select all

load_file("stdrun.hoc")
create soma
insert pas

objref data_vec, time_vec
data_vec = new Vector()
time_vec = new Vector()

data_vec.record(&soma.v(0.5), time_vec)
run()

{
printf("Size of data vector: %d\n", data_vec.size())
printf("Size of time vector: %d\n", time_vec.size())
}
On my computer, it prints out 0's for both of the vectors' sizes. If I do it this way, however, everything works as expected:

Code: Select all

load_file("stdrun.hoc")
create soma
insert pas

objref data_vec, time_vec
data_vec = new Vector()
time_vec = new Vector()

data_vec.record(&soma.v(0.5))
time_vec.record(&t)
run()

{
printf("Size of data vector: %d\n", data_vec.size())
printf("Size of time vector: %d\n", time_vec.size())
}
I am using a slightly modified NEURON 6.1 on Windows, but my changes to it have not touched any of the low-level implementations so I do not think I broke it myself. I don't have access to a vanilla install of NEURON right now, but I shall test to see if this is reproducible there as well as soon as I am able.
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Possible bug in Vector's record function

Post by ted »

Not a NEURON bug. In the form vdest.record(&var, tvec), tvec is a Vector whose elements specify the times at which var will be captured to vdest. Quoting from the documentation of Vector record http://www.neuron.yale.edu/neuron/stati ... tml#record
At the end of fadvance, var will be saved if t (after being incremented by fadvance) is equal or greater than the associated time of the next index.
. . .
The record semantics can be thought of as:
var(t) -> v.x[index]

The default relationship between index and t is t = index*dt.
In the second form, t = index*Dt.
In the third form, t = tvec.x[index].

If tvec is empty, or its elements are > t at the end of the simulation, no values will be captured to vdest. In your code example that fails to record anything, tvec is empty.
sl
Posts: 21
Joined: Wed Nov 28, 2007 12:52 am
Location: Cornell University

Re: Possible bug in Vector's record function

Post by sl »

Ah, I see. I misunderstood what the manual was implying. Thanks for the clarification.
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Possible bug in Vector's record function

Post by ted »

I have made similar misinterpretations myself. Much of the documentation is concise "to a fault." Even when meanings seem evident, it is always a good idea to test before using.
Post Reply