1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
.. _seclist:
SectionList
-----------
.. class:: SectionList
Syntax:
``sl = h.SectionList()``
``sl = h.SectionList(python_iterable_of_sections)``
Description:
Class for creating and managing a list of sections. Unlike a regular Python list, a ``SectionList`` allows including sections
based on neuronal morphology (e.g. subtrees).
If ``sl`` is a :class:`SectionList`, then to turn that into a Python list, use ``py_list = list(sl)``; note
that iterating over a SectionList is supported, so it may not be neccessary to create a Python list.
The second syntax creates a SectionList from the Python iterable and is equivalent
to:
.. code-block::
python
sl = h.SectionList()
for sec in python_iterable_of_sections:
sl.append(sec)
.. seealso::
:class:`SectionBrowser`, :class:`Shape`, :meth:`RangeVarPlot.list`
----
.. method:: SectionList.append
Syntax:
``sl.append(section)``
``sl.append(sec=section)``
Description:
append ``section`` to the list
----
.. method:: SectionList.remove
Syntax:
``n = sl.remove(sec=section)``
``n = sl.remove(sectionlist)``
Description:
Remove ``section`` from the list.
If ``sectionlist`` is present then all the sections in sectionlist are
removed from sl.
Returns the number of sections removed.
----
.. method:: SectionList.children
Syntax:
``sl.children(section)``
``sl.children(sec=section)``
Description:
Appends the sections connected to ``section``.
Note that this includes children connected at position 0 of
parent.
.. note::
To get a (Python) list of a section's children, use the section's
``children`` method. For example:
.. code::
python
>>> from neuron import h
>>> s = h.Section(name='s')
>>> t = h.Section(name='t')
>>> u = h.Section(name='u')
>>> t.connect(s)
t
>>> u.connect(s)
u
>>> t.children()
[]
>>> s.children()
[u, t]
----
.. method:: SectionList.subtree
Syntax:
``sl.subtree(section)``
``sl.subtree(sec=section)``
Description:
Appends the subtree of the ``section``. (including that one).
.. note::
To get a (Python) list of a section's subtree, use the section's
``subtree`` method.
.. seealso::
:meth:`Section.subtree`
----
.. method:: SectionList.wholetree
Syntax:
``sl.wholetree(section)``
``sl.wholetree(sec=section)``
Description:
Appends all sections which have a path to the ``section``.
(including the specified section). The section list has the
important property that the sections are in root to leaf order.
.. note::
To get a (Python) list of a section's wholetree, use the section's
``wholetree`` method.
.. seealso::
:meth:`Section.wholetree`
----
.. method:: SectionList.allroots
Syntax:
``sl.allroots()``
Description:
Appends all the root sections. Root sections have no parent section.
The number of root sections is the number
of real cells in the simulation.
----
.. method:: SectionList.unique
Syntax:
``n = sl.unique()``
Description:
Removes all duplicates of sections in the SectionList. I.e. ensures that
no section appears more than once. Returns the number of sections references
that were removed.
----
.. method:: SectionList.printnames
Syntax:
``.printnames()``
Description:
print the names of the sections in the list.
``sl.printnames()`` is approximately equivalent to:
.. code::
python
for sec in sl:
print(sec)
|