Hi,
If I use,
self.hillock = [h.Section(cell=self)]
In the above syntax, why should we use "cell=self"? What is the importance of that? Thank you.
Section creation
Moderator: hines
-
- Posts: 70
- Joined: Wed Jan 18, 2012 12:25 am
- Location: University of Pavia
Re: Section creation
A general idiom for Python cell objects is:
The "cell=self" tells NEURON what Python object this section belongs to. To be honest, I'm not sure if it is really required or poses a problem if you are doing single-cell modeling and perhaps Michael Hines can give a better answer. For multiple cells, however, any specific reference to "soma" is quickly lost without it. For example:
This code produces the following:
Notice that "soma" is not really descriptive in that there are two of them and they cannot be discriminated by name alone. Adding "cell=self" sort of helps.
Produces:
This is only helpful in that it tells me I have a "Cell" object. If I had two or more cell object types, I could then kind of differentiate at least what class the section belonged to. What I really recommend doing is modifying the name dynamically:
which produces
Again, the first part might be a bit ugly, but the last part tells me explicitly what section of what cell I have.
Code: Select all
from neuron import h
class Cell(object):
def __init__(self):
self.soma = h.Section(name='soma', cell=self)
Code: Select all
from neuron import h
class Cell(object):
def __init__(self, id=0):
self.soma = h.Section(name='soma')
self.id = id
if id == 0:
self.soma.insert('hh')
cell1 = Cell(0)
cell2 = Cell(1)
h.psection(sec=cell1.soma)
print "**********"
h.psection(sec=cell2.soma)
Code: Select all
soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
}
**********
soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 1*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
}
Code: Select all
from neuron import h
class Cell(object):
def __init__(self, id=0):
self.soma = h.Section(name='soma', cell=self)
self.id = id
if id == 0:
self.soma.insert('hh')
cell1 = Cell(0)
cell2 = Cell(1)
h.psection(sec=cell1.soma)
print "**********"
h.psection(sec=cell2.soma)
Code: Select all
<__main__.Cell object at 0x101995e50>.soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
}
**********
<__main__.Cell object at 0x1019a3090>.soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 1*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
}
Code: Select all
from neuron import h
class Cell(object):
def __init__(self, id=0):
self.soma = h.Section(name='cell_%d_soma' %id, cell=self)
self.id = id
if id == 0:
self.soma.insert('hh')
cell1 = Cell(0)
cell2 = Cell(1)
h.psection(sec=cell1.soma)
print "**********"
h.psection(sec=cell2.soma)
Code: Select all
<__main__.Cell object at 0x101995e50>.cell_0_soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
}
**********
<__main__.Cell object at 0x1019a3090>.cell_1_soma { nseg=1 L=100 Ra=35.4
/*location 0 attached to cell 1*/
/* First segment only */
insert morphology { diam=500}
insert capacitance { cm=1}
}
-
- Posts: 70
- Joined: Wed Jan 18, 2012 12:25 am
- Location: University of Pavia
Re: Section creation
Dear mctavish,
Thank you very much for your detailed explanation illustrated with examples. It helped me a lot in understanding the usage of "cell=self". Thank you once again.
Thank you very much for your detailed explanation illustrated with examples. It helped me a lot in understanding the usage of "cell=self". Thank you once again.