Record i_membrane from extracellular in Python

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

Moderator: hines

Post Reply
selfdestructo
Posts: 32
Joined: Wed Oct 14, 2009 11:12 am

Record i_membrane from extracellular in Python

Post by selfdestructo »

Hi, could use some help with recording float variables. I have some existing .hoc-code I want to transfer to Python;

Code: Select all

objref memirec,memireclist
proc set_imem_recorders() { //Arguments: timeres_python, len(tvec)
	memireclist = new List()
	//records passive and capacitive currents
	forsec allseclist {
		for (x,0) {		
	       	//add recorder for i_membrane to each pos(x)
				memirec = new Vector(size=$2)
				memirec.record(&i_membrane(x),$1)
				memireclist.append(memirec)			
			}
	}
}
I want to declare the same function in Python, but cannot locate some _ref_ for the i_membrane variable arising after inserting the extracellular mechanism, right now I have:

Code: Select all

def set_imem_recorders(self, tstopms):
        '''record membrane currents for all compartments'''
        memireclist = self.h.List()
        for seg in self.h.allseclist:
            memirec = self.h.Vector(size=tstopms/self.timeres_python+1)
            memirec.record(seg.i_membrane, self.timeres_python) #Doesn't work!!
            memireclist.append(memirec)
which do not work of course, since seg.i_membrane is a float. Any way I can do this properly? How can I find if there exist some h._ref_ for this or some other variable?
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Record i_membrane from extracellular in Python

Post by hines »

Use:

Code: Select all

memirec.record(seg._ref_i_membrane, self.timeres_python)
However, your seg may not be a nrn.Segment object. I presume self.h.allseclist
is a Hoc List of Sections. So perhaps you need a nested loop like
for sec in self.h.allseclist:
for seg in sec:
selfdestructo
Posts: 32
Joined: Wed Oct 14, 2009 11:12 am

Re: Record i_membrane from extracellular in Python

Post by selfdestructo »

Thanks, that did the trick, so the following works:

Code: Select all

def set_imem_recorders(self, tstopms):
        '''record membrane currents for all compartments'''
        memireclist = self.h.List()
        for seg in self.h.allseclist:
            for sec in seg:
                memirec = self.h.Vector(size=tstopms/self.timeres_python+1)
                memirec.record(sec._ref_i_membrane(), self.timeres_python)
                memireclist.append(memirec)
Post Reply