Page 1 of 1

Accessing neuron vectors stored in a python list

Posted: Thu Mar 22, 2018 7:44 pm
by ryang
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))

Re: Accessing neuron vectors stored in a python list

Posted: Fri Mar 23, 2018 10:20 am
by ted
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()

Re: Accessing neuron vectors stored in a python list

Posted: Fri Mar 23, 2018 1:18 pm
by ryang
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)

Re: Accessing neuron vectors stored in a python list

Posted: Fri Mar 23, 2018 1:56 pm
by ramcdougal
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.