Skip to content
Snippets Groups Projects
Unverified Commit cd2f5323 authored by Han Lu's avatar Han Lu Committed by GitHub
Browse files

fixed the writing (#2289)

<!-- Please make sure your PR follows our [contribution
guidelines](https://github.com/arbor-sim/arbor/tree/master/doc/contrib)
and agree to the terms outlined in the [PR
procedure](https://github.com/arbor-sim/arbor/tree/master/doc/contrib/pr.rst).
-->
parent 380bf3c7
No related branches found
No related tags found
No related merge requests found
.. _tutorialsinglecellswc: .. _tutorialsinglecellswc:
A detailed single cell model A detailed single-cell model
============================ ============================
We can expand on the :ref:`single segment cell example <tutorialsinglecell>` to create a more We can expand on the :ref:`single segment cell example <tutorialsinglecell>` to create a more
complex single cell model, and go through the process in more detail. complex single-cell model, and go through the process in more detail.
.. Note:: .. Note::
...@@ -44,18 +44,18 @@ We begin by constructing the following morphology: ...@@ -44,18 +44,18 @@ We begin by constructing the following morphology:
This can be done by manually building a segment tree. The important bit here is This can be done by manually building a segment tree. The important bit here is
that ``append`` will take an id to attach to and return the newly added id. This that ``append`` will take an id to attach to and return the newly added id. This
is exceptionally handy when building a tree structure, as we can elect to is exceptionally handy when building a tree structure, as we can elect to
remember or overwrite the last id. Alternatively, you could use numeric ids -- remember or overwrite the last id. Alternatively, you could use numeric ids ---
they are just sequentially numbered by insertion order --, but we find that this they are just sequentially numbered by insertion order --- but we find that this
becomes tedious quickly. The image above shows the numeric ids for the specific becomes tedious quickly. The image above shows the numeric ids for the specific
insertion order below, but different orders will produce the same morphology. insertion order below, but different orders will produce the same morphology.
.. code-block:: python .. code-block:: python
# Construct an empty segment tree. # Construct an empty segment tree.
tree = arbor.segment_tree() tree = A.segment_tree()
# The root of the tree has no parent # The root of the tree has no parent
root = arbor.mnpos root = A.mnpos
# The root segment: a cylindrical soma with tag 1 # The root segment: a cylindrical soma with tag 1
# NOTE: append returns the added segment's id, which we can use to # NOTE: append returns the added segment's id, which we can use to
...@@ -67,13 +67,13 @@ insertion order below, but different orders will produce the same morphology. ...@@ -67,13 +67,13 @@ insertion order below, but different orders will produce the same morphology.
dend = tree.append(soma, (40.0, 0.0, 0.0, 0.8), ( 80.0, 0.0, 0.0, 0.8), tag=3) dend = tree.append(soma, (40.0, 0.0, 0.0, 0.8), ( 80.0, 0.0, 0.0, 0.8), tag=3)
dend = tree.append(dend, (80.0, 0.0, 0.0, 0.8), (120.0, -5.0, 0.0, 0.8), tag=3) dend = tree.append(dend, (80.0, 0.0, 0.0, 0.8), (120.0, -5.0, 0.0, 0.8), tag=3)
# Construct upper part of the first fork # Construct the upper part of the first fork
# NOTE: We do not overwrite the parent here, as we need to attach the # NOTE: We do not overwrite the parent here, as we need to attach the
# lower fork later. Instead we use new names for this branch. # lower fork later. Instead, we use new names for this branch.
dend_u = tree.append(dend, (120.0, -5.0, 0.0, 0.8), (200.0, 40.0, 0.0, 0.4), tag=3) dend_u = tree.append(dend, (120.0, -5.0, 0.0, 0.8), (200.0, 40.0, 0.0, 0.4), tag=3)
dend_u = tree.append(dend_u, (200.0, 40.0, 0.0, 0.4), (260.0, 60.0, 0.0, 0.2), tag=3) dend_u = tree.append(dend_u, (200.0, 40.0, 0.0, 0.4), (260.0, 60.0, 0.0, 0.2), tag=3)
# Construct lower part of the first fork # Construct the lower part of the first fork
dend_l = tree.append(dend, (120.0, -5.0, 0.0, 0.5), (190.0, -30.0, 0.0, 0.5), tag=3) dend_l = tree.append(dend, (120.0, -5.0, 0.0, 0.5), (190.0, -30.0, 0.0, 0.5), tag=3)
# Attach another fork to the last segment, ``p``. # Attach another fork to the last segment, ``p``.
...@@ -88,7 +88,7 @@ insertion order below, but different orders will produce the same morphology. ...@@ -88,7 +88,7 @@ insertion order below, but different orders will produce the same morphology.
axon = tree.append(root, (0.0, 0.0, 0.0, 2.0), (-70.0, 0.0, 0.0, 0.4), tag=2) axon = tree.append(root, (0.0, 0.0, 0.0, 2.0), (-70.0, 0.0, 0.0, 0.4), tag=2)
axon = tree.append(axon, (-70.0, 0.0, 0.0, 0.4), (-100.0, 0.0, 0.0, 0.4), tag=2) axon = tree.append(axon, (-70.0, 0.0, 0.0, 0.4), (-100.0, 0.0, 0.0, 0.4), tag=2)
# Turn segment tree into a morphology. # Turn the segment tree into a morphology.
morph = arbor.morphology(tree); morph = arbor.morphology(tree);
The same morphology can be represented using an SWC file (interpreted according The same morphology can be represented using an SWC file (interpreted according
...@@ -134,12 +134,12 @@ the labels can be stored in a :class:`arbor.label_dict`. ...@@ -134,12 +134,12 @@ the labels can be stored in a :class:`arbor.label_dict`.
that can be applied to any morphology, and depending on its geometry, they that can be applied to any morphology, and depending on its geometry, they
will generate different regions and locations. However, we will show some will generate different regions and locations. However, we will show some
figures illustrating the effect of applying these expressions to the above figures illustrating the effect of applying these expressions to the above
morphology, in order to better visualize the final cell. morphology in order to better visualize the final cell.
More information on region and location expressions is available :ref:`here More information on region and location expressions is available :ref:`here
<labels>`. <labels>`.
The SWC file format allows association of ``tags`` with parts of the morphology The SWC file format allows the association of ``tags`` with parts of the morphology
and reserves tag values 1-4 for commonly used sections (see `here and reserves tag values 1-4 for commonly used sections (see `here
<http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html>`__ <http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html>`__
for the SWC file format). In Arbor, these tags can be added to a for the SWC file format). In Arbor, these tags can be added to a
...@@ -235,7 +235,7 @@ previously defined morphology: ...@@ -235,7 +235,7 @@ previously defined morphology:
Left: locset "root"; right: locset "terminal" Left: locset "root"; right: locset "terminal"
To make things more interesting, let's select only the terminal points which belong to the To make things more interesting, let's select only the terminal points which belong to the
previously defined "custom" region; and, separately, the terminal points which belong to the previously defined "custom" region and, separately, the terminal points which belong to the
"axon" region: "axon" region:
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
...@@ -271,7 +271,7 @@ The decorations ...@@ -271,7 +271,7 @@ The decorations
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
With the key regions and location expressions identified and labelled, we can start to With the key regions and location expressions identified and labelled, we can start to
define certain features, properties and dynamics on the cell. This is done through a define certain features, properties, and dynamics of the cell. This is done through a
:class:`arbor.decor` object, which stores a mapping of these "decorations" to certain :class:`arbor.decor` object, which stores a mapping of these "decorations" to certain
region or location expressions. region or location expressions.
...@@ -285,24 +285,23 @@ region or location expressions. ...@@ -285,24 +285,23 @@ region or location expressions.
The decor object can have default values for properties, which can then be The decor object can have default values for properties, which can then be
overridden on specific regions. It is in general better to explicitly set all overridden on specific regions. It is in general better to explicitly set all
the default properties of your cell, to avoid the confusion to having the default properties of your cell, to avoid the confusion of having
simulator-specific default values. This will therefore be our first step: simulator-specific default values. This will, therefore, be our first step:
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
:language: python :language: python
:lines: 48-62 :lines: 48-62
We have set the default initial membrane voltage mV; the default initial We have set the default initial membrane voltage mV, the default initial
temperature; the default axial resistivity to; and the default membrane temperature, the default axial resistivity, and the default membrane
capacitance to. Also, the initial properties of the *na* and *k* ions have been capacitance. Also, the initial properties of the *na* and *k* ions have been
changed. They will be utilized by the density mechanisms that we will be adding changed. They will be utilized by the density mechanisms that we will be adding
shortly. For both ions we set the default initial concentration and external shortly. For both ions we set the default initial concentration and external
concentration measures; and we set the default initial reversal potential. For concentration measures; and we set the default initial reversal potential. For
the *na* ion, we additionally indicate the the progression on the reversal the *na* ion, we additionally indicate that the progression on the reversal
potential during the simulation will be dictated by the `Nernst equation potential during the simulation will be dictated by the `Nernst equation
<https://en.wikipedia.org/wiki/Nernst_equation>`_. In the case that defaults are <https://en.wikipedia.org/wiki/Nernst_equation>`_. In the case that defaults are
not set at the cell level, there is also a global default which we will define a not set at the cell level, there is also a global default, which we will define later.
bit later.
It happens, however, that we want the temperature of the "custom" region defined It happens, however, that we want the temperature of the "custom" region defined
in the label dictionary earlier to be colder, and the initial voltage of the in the label dictionary earlier to be colder, and the initial voltage of the
...@@ -316,7 +315,7 @@ new values on the relevant regions using :meth:`arbor.decor.paint`. ...@@ -316,7 +315,7 @@ new values on the relevant regions using :meth:`arbor.decor.paint`.
With the default and initial values taken care of, we now add some density With the default and initial values taken care of, we now add some density
mechanisms. Let's *paint* a *pas* density mechanism everywhere on the cell using mechanisms. Let's *paint* a *pas* density mechanism everywhere on the cell using
the previously defined "all" region; an *hh* density mechanism on the "custom" the previously defined "all" region; an *hh* density mechanism on the "custom"
region; and an *Ih* density mechanism on the "dend" region. The *Ih* mechanism region, and an *Ih* density mechanism on the "end" region. The *Ih* mechanism
has a custom 'gbar' parameter. has a custom 'gbar' parameter.
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
...@@ -328,7 +327,7 @@ cell using :meth:`arbor.decor.place`. We place 3 current clamps of 2 nA on the ...@@ -328,7 +327,7 @@ cell using :meth:`arbor.decor.place`. We place 3 current clamps of 2 nA on the
"root" locset defined earlier, starting at time = 10, 30, 50 ms and lasting 1ms "root" locset defined earlier, starting at time = 10, 30, 50 ms and lasting 1ms
each. As well as threshold detectors on the "axon_terminal" locset for voltages each. As well as threshold detectors on the "axon_terminal" locset for voltages
above -10 mV. Every placement gets a label. The labels of detectors and synapses above -10 mV. Every placement gets a label. The labels of detectors and synapses
are used to form connection from and to them in the recipe. are used to form connections from and to them in the recipe.
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
:language: python :language: python
...@@ -338,7 +337,7 @@ are used to form connection from and to them in the recipe. ...@@ -338,7 +337,7 @@ are used to form connection from and to them in the recipe.
The number of individual locations in the ``'axon_terminal'`` locset depends The number of individual locations in the ``'axon_terminal'`` locset depends
on the underlying morphology and the number of axon branches in the on the underlying morphology and the number of axon branches in the
morphology. The number of detectors that get added on the cell is equal to morphology. The number of detectors that get added to the cell is equal to
the number of locations in the locset, and the label ``'detector'`` refers to the number of locations in the locset, and the label ``'detector'`` refers to
all of them collectively. If we want to refer to a single detector from the all of them collectively. If we want to refer to a single detector from the
group (to form a network connection for example), we need a group (to form a network connection for example), we need a
...@@ -377,7 +376,7 @@ Having created the cell, we construct an :class:`arbor.single_cell_model`. ...@@ -377,7 +376,7 @@ Having created the cell, we construct an :class:`arbor.single_cell_model`.
The global properties The global properties
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
The global properties of a single cell model include: The global properties of a single-cell model include:
1. The **mechanism catalogue**: A mechanism catalogue is a collection of density 1. The **mechanism catalogue**: A mechanism catalogue is a collection of density
and point mechanisms. Arbor has 3 built-in mechanism catalogues: ``default``, and point mechanisms. Arbor has 3 built-in mechanism catalogues: ``default``,
...@@ -402,7 +401,7 @@ The global properties of a single cell model include: ...@@ -402,7 +401,7 @@ The global properties of a single cell model include:
You may now be wondering why this is needed for the `single cell model` where You may now be wondering why this is needed for the `single cell model` where
there is only one cell by design. You can use this feature to ease moving there is only one cell by design. You can use this feature to ease moving
from simulating a set of single cell models to simulating a network of these from simulating a set of single-cell models to simulating a network of these
cells. For example, a user may choose to individually test several single cells. For example, a user may choose to individually test several single
cell models before simulating their interactions. By using the same global cell models before simulating their interactions. By using the same global
properties for each *model*, and customizing the *cell* global properties, it properties for each *model*, and customizing the *cell* global properties, it
...@@ -426,7 +425,7 @@ to -55 mV. ...@@ -426,7 +425,7 @@ to -55 mV.
During the decoration step, we also made use of 3 mechanisms: *pas*, *hh* and During the decoration step, we also made use of 3 mechanisms: *pas*, *hh* and
*Ih*. As it happens, the *pas* and *hh* mechanisms are in the default Arbor *Ih*. As it happens, the *pas* and *hh* mechanisms are in the default Arbor
catalogue, whereas the *Ih* mechanism is in the "allen" catalogue. We can extend catalogue, whereas the *Ih* mechanism is in the "allen" catalogue. We can extend
the default catalogue as follow: the default catalogue as follows:
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
:language: python :language: python
...@@ -437,7 +436,7 @@ Now all three mechanisms in the *decor* object have been made available to the m ...@@ -437,7 +436,7 @@ Now all three mechanisms in the *decor* object have been made available to the m
The probes The probes
^^^^^^^^^^ ^^^^^^^^^^
The model itself is ready for simulation. Except that the only output we would The model itself is ready for simulation, except that the only output we would
be able to measure at this point is the spikes from the threshold detectors be able to measure at this point is the spikes from the threshold detectors
placed in the decor. placed in the decor.
...@@ -474,7 +473,7 @@ occurred. ...@@ -474,7 +473,7 @@ occurred.
A more interesting result of the simulation is perhaps the output of the voltage A more interesting result of the simulation is perhaps the output of the voltage
probe previously placed on the "custom_terminal" locset. The model saves the probe previously placed on the "custom_terminal" locset. The model saves the
output of the probes as [time, value] pairs which can then be plotted. We use output of the probes as [time, value] pairs which can then be plotted. We use
`pandas` and `seaborn` for the plotting, but the user can choose the any other `pandas` and `seaborn` for the plotting, but the user can choose any other
library: library:
.. literalinclude:: ../../python/example/single_cell_detailed.py .. literalinclude:: ../../python/example/single_cell_detailed.py
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment