Recording multiple variables with CVode

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
shuggiefisher

Recording multiple variables with CVode

Post 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.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Recording multiple variables with CVode

Post 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.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Recording multiple variables with CVode

Post 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.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Recording multiple variables with CVode

Post 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.
Post Reply