-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all plotting functions under `plot` package
- Loading branch information
1 parent
2c2dad9
commit 7f11061
Showing
18 changed files
with
341 additions
and
52 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
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,16 @@ | ||
API Documentation | ||
================= | ||
|
||
.. toctree:: | ||
:hidden: | ||
|
||
Introduction <self> | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
:toctree: _morph_tool_build | ||
|
||
morph_tool.plot | ||
morph_tool.plot.consts | ||
morph_tool.plot.dendrogram | ||
morph_tool.plot.morphology |
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
|
||
Home <self> | ||
morphdb | ||
api | ||
changelog |
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,80 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import neurom as nm | ||
from morph_tool.plot import morphology | ||
from morph_tool.plot import consts | ||
|
||
|
||
def example_afferent(): | ||
neuron = nm.load_neuron('dendrogram_plain_example.swc') | ||
data = np.array([ | ||
[4, 0, 0.81408846, 'additional value'], | ||
[6, 2, 0.545983203, 'additional value'], | ||
[1, 0, 0.4290702, 'additional value'], | ||
]) | ||
columns = [consts.POST_SECTION_ID, consts.POST_SEGMENT_ID, consts.POST_SEGMENT_OFFSET, | ||
'additional_data'] | ||
synapses = pd.DataFrame(data, columns=columns) | ||
|
||
fig = morphology.draw(neuron, synapses) | ||
fig.show() | ||
|
||
|
||
def example_efferent(): | ||
neuron = nm.load_neuron('dendrogram_plain_example.swc') | ||
data = np.array([ | ||
[4, 0, 0.81408846, 'additional value'], | ||
[6, 2, 0.645983203, 'additional value'], | ||
[1, 0, 0.4290702, 'additional value'], | ||
]) | ||
columns = [consts.PRE_SECTION_ID, consts.PRE_SEGMENT_ID, consts.PRE_SEGMENT_OFFSET, | ||
'additional_data'] | ||
synapses = pd.DataFrame(data, columns=columns) | ||
|
||
fig = morphology.draw(neuron, synapses) | ||
fig.show() | ||
|
||
|
||
def example_afferent_efferent(): | ||
neuron = nm.load_neuron('dendrogram_plain_example.swc') | ||
data = np.array([ | ||
[4, 0, 0.81408846, np.nan, np.nan, np.nan], | ||
[6, 2, 0.145983203, np.nan, np.nan, np.nan], | ||
[np.nan, np.nan, np.nan, 1, 0, 0.4290702], | ||
[np.nan, np.nan, np.nan, 1, 0, 0.29180855], | ||
[np.nan, np.nan, np.nan, 1, 0, 0.68261607], | ||
]) | ||
columns = [consts.POST_SECTION_ID, consts.POST_SEGMENT_ID, consts.POST_SEGMENT_OFFSET, | ||
consts.PRE_SECTION_ID, consts.PRE_SEGMENT_ID, consts.PRE_SEGMENT_OFFSET] | ||
synapses = pd.DataFrame(data, columns=columns) | ||
|
||
fig = morphology.draw(neuron, synapses) | ||
fig.show() | ||
|
||
|
||
def circuit_example(): | ||
"""Example that shows how to plot a morphology with synapses from a Sonata circuit. | ||
To make this example work, you would need a proper SONATA circuit. | ||
""" | ||
from bluepysnap import Circuit | ||
from bluepysnap.bbp import Synapse | ||
circuit = Circuit('/path/to/sonata_circuit_config.json') | ||
edge_properties = [ | ||
'afferent_section_id', 'afferent_segment_id', 'afferent_segment_offset', | ||
Synapse.U_SYN, Synapse.D_SYN, Synapse.F_SYN, Synapse.G_SYNX, | ||
] | ||
morph_id = 110 | ||
synapses = circuit.edges['default'].afferent_edges(morph_id, edge_properties) | ||
morph_filepath = circuit.nodes['All'].morph.get_filepath(morph_id) | ||
neuron = nm.load_neuron(morph_filepath) | ||
|
||
fig = morphology.draw(neuron, synapses) | ||
fig.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
# circuit_example() | ||
# example_afferent() | ||
example_efferent() | ||
# example_afferent_efferent() |
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,7 @@ | ||
"""Module for plotting functions. In order to use it, you must install morph-tool as: | ||
.. code:: bash | ||
pip install morph-tool[plot] | ||
""" |
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,38 @@ | ||
"""Constants for names that are required to be in columns of ``synapses`` arg of | ||
``morph_tool.plot`` package. These constants are the same as edge properties of `Sonata | ||
<https://github.com/AllenInstitute/sonata/blob/master/docs/SONATA_DEVELOPER_GUIDE.md# | ||
edges---optional-reserved-attributes>`__. So you can use these constants, their values as plain | ||
strings or constants from `bluepysnap <https://github.com/BlueBrain/snap/>`__ library: | ||
An example of using constants or plain strings: | ||
.. literalinclude:: ../../../examples/dendrogram.py | ||
:pyobject: plain_example | ||
An example of using with a circuit and bluepysnap constants: | ||
.. literalinclude:: ../../../examples/dendrogram.py | ||
:pyobject: circuit_example | ||
""" | ||
|
||
#: Contains string `@target_node` that must be used as column name in `synapses` arg. | ||
TARGET_NODE_ID = '@target_node' | ||
#: Contains string `@source_node` that must be used as column name in `synapses` arg. | ||
SOURCE_NODE_ID = '@source_node' | ||
|
||
#: Contains string `afferent_section_id` that must be used as column name in `synapses` arg. | ||
POST_SECTION_ID = 'afferent_section_id' | ||
#: Contains string `afferent_section_pos` that must be used as column name in `synapses` arg. | ||
POST_SECTION_POS = 'afferent_section_pos' | ||
#: Contains string `afferent_segment_id` that must be used as column name in `synapses` arg. | ||
POST_SEGMENT_ID = 'afferent_segment_id' | ||
#: Contains string `afferent_segment_offset` that must be used as column name in `synapses` arg. | ||
POST_SEGMENT_OFFSET = 'afferent_segment_offset' | ||
|
||
#: Contains string `efferent_section_id` that must be used as column name in `synapses` arg. | ||
PRE_SECTION_ID = 'efferent_section_id' | ||
#: Contains string `efferent_section_pos` that must be used as column name in `synapses` arg. | ||
PRE_SECTION_POS = 'efferent_section_pos' | ||
#: Contains string `efferent_segment_id` that must be used as column name in `synapses` arg. | ||
PRE_SEGMENT_ID = 'efferent_segment_id' | ||
#: Contains string `efferent_segment_offset` that must be used as column name in `synapses` arg. | ||
PRE_SEGMENT_OFFSET = 'efferent_segment_offset' |
Oops, something went wrong.