Page 1 of 1

Recording multiple variables with CVode

Posted: Fri Jan 30, 2009 3:17 pm
by shuggiefisher
Hi folks,

I'm trying to record the membrane potential of a presynaptic and postsynaptic neuron. I've tried:

Code: Select all

cv = h.CVode(1)
cv.active(1)

t_record = linspace(0, tstop, (tstop/dt))
t_rec = h.Vector(t_record)
zeroed_rec = zeros((tstop/dt),dtype=float)
vpost_rec = h.Vector(zeroed_rec)
vpre_rec = h.Vector(zeroed_rec)

h.finitialize(h.v_init)
h.fcurrent()
cv.re_init()

precell.soma.push()
cv.record(precell.soma(0.5)._ref_v, vpre_rec, t_rec, 1)
h.pop_section()
postcell.dend[2].push()
cv.record(postcell.dend[2](0.5)._ref_v, vpost_rec, t_rec, 1)
h.pop_section()

h.run()

t_output = array(t_rec)
vpost_output = array(vpost_rec)
vpre_output = array(vpre_rec)
However, when I do this, vpre_output is an array of zeros, whereas vpost_output contains the correct values. If I change the order in which I specify the cv.record(), then vpre_output contains the correct values, and vpost_output contains zeros. I guess the second cv.record() just overwrites the first...

What is the correct way to do this? How can I record multiple variables while using a variable timestep integration?


thanks in advance.

Re: Recording multiple variables with CVode

Posted: Fri Jan 30, 2009 8:13 pm
by ted
A minor comment: I don't think there's any need to call finitialize(), fcurrent() or CVode re_init(), either--run() should take care of all that.

But that doesn't explain why the vector in the first record() statement is full of 0s.

Re: Recording multiple variables with CVode

Posted: Sat Jan 31, 2009 9:31 am
by hines
Looks like CVode.record is broken and I will have to fix it. Use the equivalent

Code: Select all

vpre_rec.record(precell.soma(0.5)._ref_v, t_rec, sec = precell.soma)
vpost_rec.record(postcell.dend[2](0.5)._ref_v, t_rec, sec = postcell.dend[2])
Of course you don't need the last keyword arg since you are explicitly pushing and
popping the proper section.

Re: Recording multiple variables with CVode

Posted: Sat Jan 31, 2009 10:02 am
by hines
CVode.record has been updated to allow multiple uses of tvec since, in this context,
that is a contant vector. See
http://www.neuron.yale.edu/hg/neuron/nr ... 7cbfd64068
It would be a subtle error if tvec was being recorded into,
eg. if the fourth arg was inadvertently 0.