diff --git a/doc/concepts/labels.rst b/doc/concepts/labels.rst index a9a2d4589acfe08379383d476ed12c6b07107724..97ba60a639a260266be8a714e50d442bdc2d7d85 100644 --- a/doc/concepts/labels.rst +++ b/doc/concepts/labels.rst @@ -654,5 +654,5 @@ the regions or locsets defined in the label dictionary by referring to their lab API --- -* :ref:`Python <py_labels>` +* :ref:`Python <pylabels>` * *TODO*: C++ documentation. diff --git a/doc/python/index.rst b/doc/python/index.rst index f9cf4589b70158a46955fee1cc9c1e037c7fca7a..4aaca8276a1ae0d03eae4f9d03dd5ffae137722d 100644 --- a/doc/python/index.rst +++ b/doc/python/index.rst @@ -51,3 +51,4 @@ These details are described and examples are given in the next sections :ref:`py morphology labels mechanisms + single_cell_model diff --git a/doc/python/labels.rst b/doc/python/labels.rst index 37492a2a6f08209272a7b570ca7fd77d598c52a5..faef567512838d9cfd04b92a6b1fbf8ebc4b47ab 100644 --- a/doc/python/labels.rst +++ b/doc/python/labels.rst @@ -1,8 +1,36 @@ -.. _py_labels: +.. _pylabels: Cell labels =========== +.. currentmodule:: arbor + +.. py:class:: label_dict + + Stores labels and their associated expressions as key-value pairs. + + .. method:: label_dict() + + Create an empty label dictionary + + .. method:: label_dict(dictionary) + + Initialize a label dictionary from a ``dictionary`` with string labels as keys, + and corresponding string definitions as values. + + .. code-block:: python + + labels = arbor.label_dict({'soma': '(tag 1)', # region + 'center': '(location 0 0.5)'}) # locset + + .. attribute:: regions + + The region definitons in the dictionary. + + .. attribute:: locsets + + The locset definitons in the dictionary. + The ``arbor.label_dict`` type is used for creating and manipulating label dictionaries, which can be initialised with a dictionary that defines (label, expression) pairs. For example, a dictionary that uses tags that correspond to SWC diff --git a/doc/python/single_cell_model.rst b/doc/python/single_cell_model.rst new file mode 100644 index 0000000000000000000000000000000000000000..20be222e25930e25c859238f10e54b1867c63c03 --- /dev/null +++ b/doc/python/single_cell_model.rst @@ -0,0 +1,76 @@ +.. _pysinglecellmodel: + +Single cell model +================= + +.. currentmodule:: arbor + +.. py:class:: single_cell_model + + Wrapper for simplified description and execution of single cell models. + Only available in the python library. + Abstracts away the details of a :class:`recipe`, :class:`context` and + :class:`domain_decomposition` for simulations of single, stand-alone + cable cells. + The simulation can not be distributed over several machines. + + .. method:: single_cell_model(cable_cell) + + Construct a :class:`single_cell_model` from a :class:`cable_cell` + + .. method:: run(tfinal, dt) + + Run the model from time t= ``0`` to t= ``tflinal`` with a dt= ``dt``. + + .. method:: probe(what, where, frequency) + + Sample a variable on the cell: + + :param what: Name of the variable to record (currently only 'voltage'). + :param where: :class:`location` at which to sample the variable. + :param frequency: The frequency at which to sample [Hz]. + + .. method:: spikes() + + Returns a list spike times [ms] after a call to :class:`single_cell_model.run`. + + .. method:: traces() + + Returns a list of :class:`trace` after a call to :class:`single_cell_model.run`. + Each element in the list holds the trace of one of the probes added via + :class:`single_cell_model.probe`. + + .. attribute:: properties + + The :class:`cable_global_properties` of the model. + + .. attribute:: catalogue + + The :class:`mechanism_catalogue` of the model. + +.. py:class:: trace + + Stores a trace obtained from a probe after running a model. + + .. attribute:: variable + + Name of the variable being recorded. Currently only 'voltage'. + + .. attribute:: loc + + :class:`location` of the trace + + .. attribute:: t + + Sample times [ms] + + .. attribute:: v + + Sample values [units specific to sample variable] + +.. Note:: + + The :class:`single_cell_model` is used in our :ref:`tutorials <gs_other_examples>`. + The examples illustrate how to construct a :class:`cable_cell` and use it to form + a :class:`single_cell_model`; how to add probes; how to run the model; and how to + visualize the results. \ No newline at end of file diff --git a/doc/tutorial/single_cell_model.rst b/doc/tutorial/single_cell_model.rst index 0167bba6c3db5f176b3dc8eaf90193dd93125fb6..5e98fbd5095665d08b4c986576756c127848f1a5 100644 --- a/doc/tutorial/single_cell_model.rst +++ b/doc/tutorial/single_cell_model.rst @@ -99,9 +99,8 @@ Single cell model Once the cell description has been built, the next step is to build and run the simulation. Arbor provides an interface for constructing single cell models with the -:class:`arbor.single_cell_model<arbor.single_cell_model>` -helper that creates a model from a cell description, with an interface for -recording outputs and running the simulation. +:class:`arbor.single_cell_model` helper that creates a model from a cell description, with +an interface for recording outputs and running the simulation. .. code-block:: python @@ -114,10 +113,10 @@ recording outputs and running the simulation. # (7) Run simulation for 30 ms of simulated activity. m.run(tfinal=30) -Step **(5)** instantiates the :class:`arbor.single_cell_model<arbor.single_cell_model>` +Step **(5)** instantiates the :class:`arbor.single_cell_model` with our single-compartment cell. -Step **(6)** adds a :meth:`arbor.single_cell_model.probe()<arbor.single_cell_model.probe>` +Step **(6)** adds a :meth:`arbor.single_cell_model.probe` used to record variables from the model. Three pieces of information are provided: the type of quantity we want probed (voltage), the location where we want to probe ('"center"'), and the frequency at which we want to sample (10kHz). @@ -146,12 +145,12 @@ the spike detector and a voltage probes from our model have produced. df = pandas.DataFrame({'t/ms': m.traces[0].time, 'U/mV': m.traces[0].value}) seaborn.relplot(data=df, kind="line", x="t/ms", y="U/mV",ci=None).savefig('single_cell_model_result.svg') -Step **(8)** accesses :meth:`arbor.single_cell_model.spikes<arbor.single_cell_model.spikes>` +Step **(8)** accesses :meth:`arbor.single_cell_model.spikes` to print the spike times. A single spike should be generated at around the same time the stimulus we provided in step (3) gets activated (10ms). Step **(9)** plots the measured potentials during the runtime of the simulation. The sampled quantities -can be accessed through :meth:`arbor.single_cell_model.traces<arbor.single_cell_model.traces>`. +can be accessed through :meth:`arbor.single_cell_model.traces`. We should be seeing something like this: .. figure:: single_cell_model_result.svg