Skip to content

Commit 8ed3f53

Browse files
committed
Merge branch 'docs' into develop
2 parents 93967fd + be6f78d commit 8ed3f53

File tree

1 file changed

+106
-3
lines changed

1 file changed

+106
-3
lines changed

examples/atlas/atlas_swanson_flatmap.ipynb

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,116 @@
3030
"outputs": [],
3131
"source": [
3232
"import numpy as np\n",
33-
"from ibllib.atlas.flatmaps import plot_swanson\n",
33+
"from ibllib.atlas.flatmaps import swanson, plot_swanson\n",
3434
"from ibllib.atlas import BrainRegions\n",
35+
"\n",
3536
"br = BrainRegions()\n",
3637
"\n",
37-
"plot_swanson(br=br, annotate=True)\n"
38+
"# Plot Swanson map will default colors and acronyms\n",
39+
"plot_swanson(br=br, annotate=True)"
3840
]
3941
},
42+
{
43+
"cell_type": "markdown",
44+
"source": [
45+
"### What regions are represented in the Swanson flatmap"
46+
],
47+
"metadata": {
48+
"collapsed": false
49+
}
50+
},
51+
{
52+
"cell_type": "markdown",
53+
"source": [
54+
"The Swanson map holds 318 brain region acronyms, some of which are an aggregate of distinct brain regions in the Allen or Beryl parcellation.\n",
55+
"To find the acronyms of the regions represented in Swanson, use:"
56+
],
57+
"metadata": {
58+
"collapsed": false
59+
}
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"outputs": [],
65+
"source": [
66+
"swanson_ac = np.sort(br.acronym[np.unique(swanson())])"
67+
],
68+
"metadata": {
69+
"collapsed": false,
70+
"pycharm": {
71+
"name": "#%%\n"
72+
}
73+
}
74+
},
75+
{
76+
"cell_type": "markdown",
77+
"source": [
78+
"Regions which are \"children\" of a Swanson region will not be included in the acronyms. For example `PTLp` is in Swanson, but its children `VISa` and `VISrl`(i.e. a finer parcellation of `PTLp`) are not:"
79+
],
80+
"metadata": {
81+
"collapsed": false
82+
}
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"outputs": [],
88+
"source": [
89+
"# Example: Check if PTLp is in Swanson\n",
90+
"np.isin(['PTLp'], swanson_ac)\n",
91+
"# Example: Check if VISa and VISrl are in Swanson\n",
92+
"np.isin(['VISa', 'VISrl'], swanson_ac)"
93+
],
94+
"metadata": {
95+
"collapsed": false,
96+
"pycharm": {
97+
"name": "#%%\n"
98+
}
99+
}
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"source": [
104+
"As such, you can only plot value for a given region that is in Swanson. This was done to ensure there is no confusion about how data is aggregated and represented per region (for example, if you were to input values for both `VISa` and `VISrl`, it is unclear whether the mean, median or else should have been plotted onto the `PTLp` area - instead, we ask you to do the aggregation yourself and pass this into the plotting function).\n",
105+
"\n",
106+
"For example,"
107+
],
108+
"metadata": {
109+
"collapsed": false
110+
}
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": null,
115+
"outputs": [],
116+
"source": [
117+
"from ibllib.atlas.flatmaps import plot_swanson_vector\n",
118+
"\n",
119+
"# 'PTLp', 'CA1', 'VPM' as in Swanson and all 3 are plotted\n",
120+
"acronyms = ['PTLp', 'CA1', 'VPM']\n",
121+
"values = np.array([1.5, 3, 4])\n",
122+
"plot_swanson_vector( acronyms, values, annotate=True, annotate_list=['PTLp', 'CA1', 'VPM'],empty_color='silver')\n",
123+
"\n",
124+
"# 'VISa','VISrl' are not in Swanson, only 'CA1', 'VPM' are plotted\n",
125+
"acronyms = ['VISa','VISrl', 'CA1', 'VPM']\n",
126+
"values = np.array([1, 2, 3, 4])\n",
127+
"plot_swanson_vector( acronyms, values, annotate=True, annotate_list=['VISa','VISrl', 'CA1', 'VPM'],empty_color='silver')\n"
128+
],
129+
"metadata": {
130+
"collapsed": false,
131+
"pycharm": {
132+
"name": "#%%\n"
133+
}
134+
}
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"source": [],
139+
"metadata": {
140+
"collapsed": false
141+
}
142+
},
40143
{
41144
"cell_type": "markdown",
42145
"metadata": {},
@@ -180,4 +283,4 @@
180283
},
181284
"nbformat": 4,
182285
"nbformat_minor": 1
183-
}
286+
}

0 commit comments

Comments
 (0)