Skip to content

Commit

Permalink
Updated the tutorials
Browse files Browse the repository at this point in the history
 * Added tutorial for Simulation and reports
 * Added some of the missing use cases
  • Loading branch information
joni-herttuainen committed Oct 19, 2021
1 parent 6ba92b2 commit 54147c8
Show file tree
Hide file tree
Showing 7 changed files with 1,997 additions and 32 deletions.
10 changes: 5 additions & 5 deletions doc/source/notebooks/01_circuits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{
"data": {
"text/plain": [
"{'All': <bluepysnap.nodes.NodePopulation at 0x7f830924e908>}"
"<bluepysnap.nodes.Nodes at 0x7f8f24fd80d0>"
]
},
"execution_count": 4,
Expand All @@ -109,7 +109,7 @@
{
"data": {
"text/plain": [
"{'All': <bluepysnap.edges.EdgePopulation at 0x7f830924e588>}"
"<bluepysnap.edges.Edges at 0x7f8f24fd8350>"
]
},
"execution_count": 5,
Expand All @@ -129,7 +129,7 @@
{
"data": {
"text/plain": [
"<bluepysnap.node_sets.NodeSets at 0x7f830924e828>"
"<bluepysnap.node_sets.NodeSets at 0x7f8f24fd8850>"
]
},
"execution_count": 6,
Expand All @@ -153,7 +153,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -167,7 +167,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.12"
}
},
"nbformat": 4,
Expand Down
255 changes: 252 additions & 3 deletions doc/source/notebooks/02_node_populations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{
"data": {
"text/plain": [
"{'All': <bluepysnap.nodes.NodePopulation at 0x7fd264652ef0>}"
"<bluepysnap.nodes.Nodes at 0x7f5d706f0590>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -173,6 +173,255 @@
"node_population.property_values('layer')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Same obviously works for getting `mtype`, `etype` or any other field listed in `property_names`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are also a few other convenient methods, such as `count` (return node count), `positions`, and `orientations`. "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>x</th>\n",
" <th>y</th>\n",
" <th>z</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>10.672496</td>\n",
" <td>506.793928</td>\n",
" <td>134.536968</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>51.832798</td>\n",
" <td>511.448478</td>\n",
" <td>24.880563</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>107.851529</td>\n",
" <td>502.817301</td>\n",
" <td>-194.135898</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>42.930203</td>\n",
" <td>518.489436</td>\n",
" <td>-73.821233</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-162.259527</td>\n",
" <td>503.331452</td>\n",
" <td>-109.188986</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" x y z\n",
"0 10.672496 506.793928 134.536968\n",
"1 51.832798 511.448478 24.880563\n",
"2 107.851529 502.817301 -194.135898\n",
"3 42.930203 518.489436 -73.821233\n",
"4 -162.259527 503.331452 -109.188986"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.positions().head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One can also give an id (or a list of ids) as an argument for `positions` or `orientations`. When passed to `orientations`"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0.63780627, 0. , 0.77019683],\n",
" [-0. , 1. , 0. ],\n",
" [-0.77019683, -0. , 0.63780627]])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.orientations(1) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"a rotation matrix for the node with given id(s) is returned."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Queries\n",
"With `ids`, it is possible to list the ids of the cells in the node_population"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 1, 2, ..., 2947, 2948, 2949])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.ids()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This becomes especially handy, when one wants to filter the available data.\n",
"E.g., getting the ids of region SO"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929,\n",
" 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940,\n",
" 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.ids({'region': 'SO'})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to query data with more than one filter:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\n",
" 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n",
" 22, 23, 2937])"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.ids({'region': ['SO', 'SLM'], 'etype': 'bAC'})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or even use regex in the query:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
" 17, 18, 19, 20, 21, 22, 23])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node_population.ids({'etype': {'$regex': '.*AC'}, 'region': 'SLM'})"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -184,7 +433,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -198,7 +447,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.12"
}
},
"nbformat": 4,
Expand Down
217 changes: 197 additions & 20 deletions doc/source/notebooks/03_node_properties.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions doc/source/notebooks/04_edge_properties.ipynb

Large diffs are not rendered by default.

0 comments on commit 54147c8

Please sign in to comment.