-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the docs of the starting guide (#770)
* change docs * complete with nm fetching * complete with nm fetching * Apply suggestions from code review Co-authored-by: Robin De Schepper <robin.deschepper93@gmail.com> * Update include_morphos.rst Add proposed changes. * shuffling docs around a bit * add yaml example, fix line numbers * add moved configs back to git --------- Co-authored-by: Robin De Schepper <robin.deschepper93@gmail.com>
- Loading branch information
Showing
22 changed files
with
349 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
!dev | ||
!getting-started | ||
_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
================================== | ||
Creating networks and reading data | ||
================================== | ||
|
||
Greetings traveller, it seems you've created a network. Here are some examples to help | ||
you on your way. | ||
|
||
.. include:: /examples/networks/create.rst | ||
|
||
.. include:: /examples/networks/load.rst | ||
|
||
.. include:: /examples/networks/data.rst |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
.. _include_morphos: | ||
|
||
Adding morphologies | ||
=================== | ||
|
||
.. note:: | ||
|
||
This guide is a continuation of the |:books:| :doc:`Getting Started guide </getting-started/getting-started>`. | ||
|
||
.. hint:: | ||
|
||
To follow along, download 2 morphologies from | ||
`NeuroMorpho <https://neuromorpho.org/>`_ and save them as ``neuron_A.swc`` and | ||
``neuron2.swc`` locally. | ||
|
||
Previously we constructed a stacked double layer topology, with 2 cell types. We then | ||
connected them in an all-to-all fashion. The next step assigns | ||
:doc:`morphologies </morphologies/intro>` to our cells, and connects the cells based on | ||
the intersection of their morphologies! | ||
|
||
Morphologies can be loaded from local files or to fetch from remote sources, like NeuroMorpho. | ||
|
||
Using local files | ||
----------------- | ||
|
||
You can declare source morphologies in the root :guilabel:`morphologies` list: | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
:lines: 9-10 | ||
|
||
.. code-block:: json | ||
"morphologies": [ | ||
"neuron_A" | ||
], | ||
.. literalinclude:: include_morphos.py | ||
:language: python | ||
:lines: 17,18,20 | ||
|
||
In this case a morphology is created from ``neuron_A.swc`` and given the name ``"neuron_A"``. | ||
As a second step, we associate this morphology to the ``base_type`` by referencing it by name | ||
in :guilabel:`cell_types.base_type.spatial.morphologies`: | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
:lines: 30-36 | ||
:emphasize-lines: 6-7 | ||
|
||
.. literalinclude:: include_morphos.json | ||
:language: json | ||
:lines: 41-50 | ||
:emphasize-lines: 6-8 | ||
|
||
.. literalinclude:: include_morphos.py | ||
:language: python | ||
:lines: 22 | ||
|
||
|
||
By default the name assigned to the morphology is the file name without its extension (here ``.swc``). To | ||
change the name we can use a node with a :guilabel:`name` and :guilabel:`file`: | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
:lines: 9-12 | ||
:emphasize-lines: 3-4 | ||
|
||
.. literalinclude:: include_morphos.json | ||
:language: json | ||
:lines: 12-17 | ||
:emphasize-lines: 4-5 | ||
|
||
.. literalinclude:: include_morphos.py | ||
:language: python | ||
:lines: 17-20 | ||
:emphasize-lines: 3 | ||
|
||
It is also possible to add a pipeline to perform transformations on the loaded | ||
morphology. Pipelines can be added by adding a :guilabel`pipeline` list to the morphology node. | ||
Each item in the list may either be a string reference to an importable function or a method of | ||
the :class:`~bsb.morphologies.Morphology` class. To pass parameters, use a node with the | ||
function reference placed in the guilabel:`func` attribute, and a :guilabel:`parameters` list. | ||
Here is an example what that would look like: | ||
|
||
.. tab-set-code:: | ||
|
||
.. code-block:: yaml | ||
morphologies: | ||
- file: my_neuron.swc | ||
pipeline: | ||
- center | ||
- my_module.add_axon | ||
- func: rotate | ||
parameters: | ||
- [20, 0, 20] | ||
.. code-block:: json | ||
"morphologies": [ | ||
{ | ||
"file": "my_neuron.swc", | ||
"pipeline": [ | ||
"center", | ||
"my_module.add_axon", | ||
{ | ||
"func": "rotate", | ||
"parameters": [ | ||
[20, 0, 20] | ||
] | ||
}, | ||
], | ||
} | ||
] | ||
.. note:: | ||
|
||
Parameters are passed positionally, keyword arguments must be passed in the order they appear | ||
in in the signature. If your target function has a complicated signature or keyword-only | ||
arguments, create a wrapping function and target that instead. | ||
|
||
Fetching with alternative URI schemes | ||
------------------------------------- | ||
|
||
The framework uses URI schemes to define the path of the sources that are loaded. By | ||
default it tries to load from the project local folder, using the``file`` URI scheme (``"file://"``). | ||
It is possible to fetch morphologies directly from `neuromorpho.org | ||
<https://neuromorpho.org>`_ using the NeuroMorpho scheme (``"nm://"``). You can refer to | ||
NeuroMorpho morphologies by their morphology name: | ||
|
||
.. figure:: /images/nm_what.png | ||
:figwidth: 450px | ||
:align: center | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
:lines: 9-12 | ||
:emphasize-lines: 3-4 | ||
|
||
.. literalinclude:: include_morphos.json | ||
:language: json | ||
:lines: 12-22,41-61 | ||
:emphasize-lines: 7-10,27-30 | ||
|
||
.. literalinclude:: include_morphos.py | ||
:language: python | ||
:lines: 24-35 | ||
:emphasize-lines: 2,10 | ||
|
||
|
||
Morphology intersection | ||
----------------------- | ||
|
||
Now that we have assigned morphologies to our cell types, we can use morphology-based | ||
connection strategies such as :class:`~.connectivity.detailed.voxel_intersection.VoxelIntersection`: | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
:lines: 56-64 | ||
|
||
.. literalinclude:: include_morphos.json | ||
:language: json | ||
:lines: 74-84 | ||
|
||
.. literalinclude:: include_morphos.py | ||
:language: python | ||
:lines: 42-47 | ||
|
||
.. note:: | ||
|
||
If there's multiple morphologies per cell type, they'll be assigned randomly, unless you | ||
specify a :class:`~.placement.distributor.MorphologyDistributor`. | ||
|
||
|
||
Recap | ||
----- | ||
|
||
.. tab-set-code:: | ||
|
||
.. literalinclude:: include_morphos.yaml | ||
:language: yaml | ||
|
||
.. literalinclude:: include_morphos.json | ||
:language: json | ||
|
||
.. literalinclude:: include_morphos.py | ||
:language: python |
Oops, something went wrong.