Note
Much of this functionality is available in Python through Section methods in recent versions of NEURON. It is, however, sometimes necessary to use this class to interoperate with legacy code.
SectionRef keeps a pointer/reference to section. If the sec= argument is omitted, the reference is to the currently accessed section.
This class overcomes a HOC limitation where sections were not treated as objects.
Returns the Section the SectionRef references.
from neuron import h
s = h.Section()
s2 = h.Section()
sref = h.SectionRef(sec=s2)
print (sref.sec==s) # False
print (sref.sec==s2) # True
Description:
Returns the parent of sref.sec.
Warning
If there is a chance that a section does not have a parent then SectionRef.has_parent() should be called first to avoid an execution error. Note that the parent is the current parent of sref.sec, not necessarily the parent when the SectionRef was created.
Returns the trueparent of sref.sec.
This is normally identical to SectionRef.parent() except when the parent's parent_connection() is equal to the parent's section_orientation().
If there is a chance that a section does not have a trueparent then SectionRef.has_trueparent() should be called first to avoid an execution error.
Returns the ith child of sref.sec. Generally it is used in a context like
for child in sref.child:
print(child.hname())
Note that the children are the current children of sref.sec, not necessarily the same as when the SectionRef was created since sections may be deleted or re-connected subsequent to the instantiation of the SectionRef.
Note
To get the number of child sections as an int, use: num = len(sref.child)
Note
An equivalent expression that evaluates to True or False is (sref.sec == h.cas()).