Accessing neuron vectors stored in a python list

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

Moderator: hines

Post Reply
ryang
Posts: 10
Joined: Wed Mar 21, 2018 6:34 pm

Accessing neuron vectors stored in a python list

Post by ryang » Thu Mar 22, 2018 7:44 pm

I am trying to access neuron vector objects stored in a python list that have recorded the conductances at a synapse ( syn is a list of mod objects in code below). I cannot figure out how to access them from the list so that I can sum them up and plot the trace. The code I have to create the list is shown below. The simple case of creating one vector and using record on it works just fine and I'm able to plot the results. I've been looking for examples of something similar but I'm coming up short.

Code: Select all

syn_g_rec_list = []
for i in range(len(syn)):
	syn_g_rec_list.append(h.Vector().record(syn[i]._ref_g,1))

ted
Site Admin
Posts: 5369
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Accessing neuron vectors stored in a python list

Post by ted » Fri Mar 23, 2018 10:20 am

Is this enough to get you on the right track?

Code: Select all

from neuron import h
veclist = []
for i in range(3):
  veclist.append(h.Vector(4))
  veclist[i].indgen(0.1+i)
  print 'vector', i
  veclist[i].printf()

ryang
Posts: 10
Joined: Wed Mar 21, 2018 6:34 pm

Re: Accessing neuron vectors stored in a python list

Post by ryang » Fri Mar 23, 2018 1:18 pm

Yes! Thank you. For anyone else's future reference my code adjustment is shown.

Code: Select all

syn_g_rec_list = []
for i in range(len(syn)):
	syn_g_rec_list.append(h.Vector(h.tstop))
	syn_g_rec_list[i].record(syn[i]._ref_g,1)

ramcdougal
Posts: 141
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: Accessing neuron vectors stored in a python list

Post by ramcdougal » Fri Mar 23, 2018 1:56 pm

A quick clarification:

The underlying issue was that vector.record returns a status (typically 1.0) and not the vector, so the original version was simply recording all the statuses and discarding the vectors.

Post Reply