Iterating over just the sections within an object
Posted: Fri Mar 03, 2017 10:58 am
I am writing one of my first programs in NEURON + Python, and I want to make sure that I am correctly iterating over just the sections within a newly-created object. (I realized that using for sec in h.allsec() iterates over all sections in the entire program, which is not what I want.) My toy class definition is as follows:
Is this the appropriate way to iterate over just the sections within one object? It gives every appearance of working, but I want to make sure I'm not missing something that will come back to bite me down the road. Thanks.
Code: Select all
class Cell(object): def __init__(self): self.createSections() self.defineBiophysics() def createSections(self): self.slist=h.SectionList() self.soma=h.Section(name='soma', cell=self) self.slist.append(sec=self.soma) self.Bdend=h.Section(name='Bdend', cell=self) self.slist.append(sec=self.Bdend) self.Adend=h.Section(name='Adend', cell=self) self.slist.append(sec=self.Adend) #define connectivity between sections self.Bdend.connect(self.soma,0,0) self.Adend.connect(self.soma,1,0) def defineBiophysics(self): for sec in self.slist: sec.insert('pas') sec.e_pas = -70 #mv sec.g_pas = 1.0/28000.0 #S/cm2