This document describes the construction and manipulation of a stylized topology, which may later be given a 3d shape. For more details and higher level functions, see:
dend = h.Section()
dend = h.Section(name='dend')
dend = h.Section(cell=mycell)
dend = h.Section(name='dend', cell=mycell)
Example 1:
soma = h.Section(name='soma') axon = h.Section(name='axon') dend = [h.Section(name='dend[%d]' % i) for i in xrange(3)] for sec in h.allsec(): print secprints the names of all the sections which have been created:
soma axon dend[0] dend[1] dend[2]
Example 2:
import itertools class MyCell: _ids = itertools.count(0) def __repr__(self): return 'MyCell[%d]' % self.id def __init__(self): self.id = self._ids.next() # create the morphology and connect it self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self) self.dend.connect(self.soma(0.5)) # create two cells my_cells = [MyCell(), MyCell()] # print the topology h.topology()Displays:
|-| MyCell[0].soma(0-1) `| MyCell[0].dend(0-1) |-| MyCell[1].soma(0-1) `| MyCell[1].dend(0-1)
See also
Section.connect(), Section.insert(), allsec()
child.connect(parent, [0 or 1])
child.connect(parent(x), [0 or 1])
Example:
from neuron import h, gui soma = h.Section(name='soma') axon = h.Section(name='axon') dend = [h.Section(name='dend[%d]' % i) for i in xrange(3)] for sec in dend: sec.connect(soma(1), 0) h.topology() s = h.Shape()![]()
Number of segments (compartments) in section. When a section is created, nseg is 1. In versions prior to 3.2, changing nseg throws away all "inserted" mechanisms including diam (if 3-d points do not exist). PointProcess, connectivity, L, and 3-d point information remain unchanged.
Starting in version 3.2, a change to nseg re-uses information contained in the old segments.
If nseg is increased, all old segments are relocated to their nearest new locations (no instance variables are modified and no pointers to data in those segments become invalid). and new segments are allocated and given mechanisms and values that are identical to the old segment in which the center of the new segment is located. This means that increasing nseg by an odd factor preserves the locations of all previous data (including all Point Processes) and, if PARAMETER range variables are constant, that all the new segments have the proper PARAMETER values. (It generally doesn't matter that ASSIGNED and STATE values do not get interpolated since those values are computed with fadvance()). If range variables are not constant then the hoc expressions used to set them should be re-executed.
If nseg is decreased then all the new segments are in fact those old segments that were nearest the centers of the new segments. Unused old segments are freed (and thus any existing pointers to variables in those freed segments are invalid). This means that decreasing nseg by an odd factor preserves the locations of all previous data. However POINT PROCESSES not located at the centers of the new segments will be discarded.
The intention is to guarantee that the following sequence
run() # sim1
for sec in h.allsec():
sec.nseg *= oddfactor
run() # sim2
for sec in h.allsec():
sec.nseg /= oddfactor
run() # sim3
will produce identical simulations for sim1 and sim3. And sim2 will be oddfactor^2 more accurate with regard to spatial discretization error.
Return the end (0 or 1) which connects to the parent. This is the value, y, used in
child.connect(parent(x), y)
Return the parent segment of the child section. This is parent(x) in:
child.connect(parent(x), y)
To get the x value, use seg.x.
Delete the specified section sec from the main section list which is used in computation.
for sec in h.allsec():
h.delete_section(sec=sec)
will remove all sections.
Note: deleted sections still exist (even though SectionRef.exists() returns 0 and an error will result if one attempts to access the section) so that other objects (such as SectionLists and Shapes) which hold pointers to these sections will still work. When the last pointer to a section is destroyed, the section memory will be freed.
Warning
If the sec argument is omitted, the currently accessed section is deleted instead.
Warning
This function does not work with Sections created in Python.
Description:
If section was created in Python, returns the cell keyword argument or None. This is accessible directly from the Section object via Section.cell(). If the section was created in HOC, returns the object that created the section, or None if created at the top level.
Warning
If no section is specified, will disconnect the currently accessed section.
Return 1.0 if the name of section matches the regular expression. Return 0.0 otherwise.
Regular expressions are like those of grep except {n1-n2} denotes an integer range and [] is literal instead of denoting a character range. For character ranges use <>. For example <a-z> or <abz45> denotes any character from a to z or to any of the characters abz45. Thus a[{8-15}] matches sections a[8] through a[15]. A match always begins from the beginning of a section name. If you don't want to require a match at the beginning use the dot.
(Note, that . matches any character and * matches 0 or more occurrences of the previous character). The interpreter always closes each string with an implicit $ to require a match at the end of the string. If you don't require a match at the end use ".*".
Example:
from neuron import h, gui soma = h.Section(name='soma') axon = h.Section(name='axon') dend = [h.Section(name='dend[%d]' % i) for i in xrange(3)] for section in h.allsec(): if h.issection('s.*', sec=section): print sectionwill print soma
for section in h.allsec(): if h.issection('d.*2]', sec=section): print sectionwill print dend[2]
for section in h.allsec(): if h.issection(".*a.*", sec=section): print sectionwill print all names which contain the letter "a"
soma axon
Note
This can also be done using Python's re module and testing the Section.hname().
Warning
If the sec keyword argument is omitted, this will operate on the currently accessed section.
Example:
for sec in h.allsec(): if h.ismembrane('hh', sec=sec) and h.ismembrane('ca_ion', sec=sec): print secwill print the names of all the sections which contain both Hodgkin-Huxley and Calcium ions.
Warning
If the sec keyword argument is omitted, returns a result based on the currently accessed section.
The name of section is placed in strvar, a HOC string reference. Such a string reference may be created by: strvar = h.ref(''); it's value is strvar[0].
This function is superseded by the easier to use, str(section).
This function is superseded by the easier to use, str(section). The below examples can be more cleanly written as: s = str(soma), print soma, and for sec in h.allsec(): for seg in sec: print seg.
Returns the name of section. Usage is
s = h.secname(sec=soma)
or
print h.secname(sec=soma)
or
for sec in h.allsec():
for seg in sec:
print('%s(%g)' % (h.secname(sec=sec), seg.x))
See also
Warning
This function is useless and currently returns an error.
Return location on parent that child is connected to. (0 <= x <= 1). This is the value, y, used in
child.connect(parent(x), y)
This information is also available via: child.parentseg().x
See also
Return the end (0 or 1) which connects to the parent. This is the value, y, used in
child.connect(parent(x), y)
Note
It is cleaner to use the equivalent section method: Section.orientation().