creating independent instances of a cell object

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

Moderator: hines

Post Reply
Nin
Posts: 41
Joined: Thu May 03, 2007 4:04 pm
Location: Institute of Science and Technology (IST Austria)
Contact:

creating independent instances of a cell object

Post by Nin » Fri May 09, 2014 8:39 am

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

hines
Site Admin
Posts: 1576
Joined: Wed May 18, 2005 3:32 pm

Re: creating independent instances of a cell object

Post by hines » Fri May 09, 2014 2:46 pm

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.

Post Reply