Page 1 of 1

creating independent instances of a cell object

Posted: Fri May 09, 2014 8:39 am
by Nin
I usually define a generic cell class in Python to generate cell objects that will be treated independently in a network of neurons. For example:

Code: Select all

class DummyCell(object):
    def __init__(self):
        self.soma = h.Section( name = 'soma', cell = self )
        self.dend = h.Section( name = 'dend', cell = self )
        self.axon = h.axon( name = 'axon', cell = self )
        ....
This will allow me to create different stances of PyramidalCell, and for example, attach point processes to one of them before a simulation.
The problem comes if I want to import the topology from a hoc file

Code: Select all

class PyramidalCell(object):
    def __init__(self, hoc_file):
        h.load_file(hoc_file)
        self.soma = h.soma
        self.dend = h.dend
        self.axon = h.axon
        ....
If I now do:

Code: Select all

mycell1 = PyramidalCell(topology1.hoc')
mycell2 = PyramidalCell('topology2.hoc')
the first object (ie mycell1), which points to h.soma will now point to the morphology loaded in the second place (topology2.hoc). Is there any way to introduce the argument self=cell in the creation of that object?

Thanks in advance

Re: creating independent instances of a cell object

Posted: Fri May 09, 2014 2:46 pm
by hines
Python referencing HOC sections is complete and straightforward but sections created by python are more or less anonymous without the use of a PythonObject instance that gives access to the internal
names of the Python cell instance. What you want to do seems to me to involve many details that are left unspecified. For example, does the hoc file consist only of long lists of pt3dadd statements wrapped by
section{....} statements? Or does it also create sectons and sectionlists? Perhaps it would be worth converting morphology.hoc to morphology.py by prepending each of the pt3dadd statements with 'h.'.
One possibility is to use hoc to define the cell types and then do everything else in python.