Record from multiple neurons

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

Moderator: hines

Post Reply

Record from multiple neurons

Post by Mrohani57 »

Hi everyone,

I have a fascicle in PNS, consist of 'fiberNum' fibers, I need to record from each one of these fibers,
I have tried this in HOC:
objref vvec, tvec,rcrd

tvec = new Vector(timeStepsNum)
rcrd = new Vector(timeStepsNum)
vvec = new Matrix(timeStepsNum,fiberNum)
tvec.record(&t, dt) // record time
for k=0, fiberNum-1{
rcrd.record(&node[k][node2check].v( 0.5 ), dt)

and this in NEURON-python :
node_v= h.Vector()
for i in range(fiberNum):

and none of them are working, I mean voltage and vvec are both empty,
what is the source of the problem?
Posts: 225
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Record from multiple neurons

Post by ramcdougal »

The basic sequence is to: (1) for each location, create a vector and do the record; (2) finitialize (this is done automatically if you use run() ( in Python)); (3) simulate for some time; then (4) store the results as you wish.

With respect to (1), you are only ever creating a single vector. If you're recording time series, you need a separate vector for each value being recorded. Create new vectors and store them in a list using a for loop or list comprehension. e.g. if in Python I wanted to store the membrane potentials at the center of a list of sections my_secs:

Code: Select all

my_secs_v = [h.Vector().record(sec(0.5)._ref_v) for sec in my_secs]
For (2) and (3): this wasn't in your snippet, but presumably it's happening somewhere. In particular, there simulation MUST be initialized after recording is setup or no values will be recorded.

For (4), you're trying to store values before the simulation has been run. There are no values to store at that point.

For what it's worth, node_v.to_python() is equivalent to list (node_v). I'm guessing voltage is a numpy array? I'm not sure, but you probably don't need to do the to_python since Vectors are iterable... It's very rare to need to copy a Vector into another data type. If the Vector doesn't work directly without conversion, usually vector.as_numpy() will work and that has essentially no overhead as it reuses the memory instead of making a copy.
Site Admin
Posts: 5919
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Record from multiple neurons

Post by ted »

To emphasize what ramcdougal wrote
For (4), you're trying to store values before the simulation has been run. There are no values to store at that point.
(and remove any ambiguity that there might still be), the Vector record() method captures values "on the fly" in the course of a simulation. If you execute one or more Vector record() statements, the vector(s) that will capture values will remain empty until you either call finitialize() (which will capture the value(s) at time t == 0), or call run() or do something equivalent (like
etc.). For more information about Vector record(), read the Programmers' Reference entry.
Post Reply