Skip to content

Commit 1199fba

Browse files
committed
update c elegans
1 parent 060869d commit 1199fba

File tree

1 file changed

+68
-16
lines changed

1 file changed

+68
-16
lines changed

c_elegans.ipynb

+68-16
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,52 @@
4545
"data.keys()"
4646
]
4747
},
48+
{
49+
"cell_type": "markdown",
50+
"id": "aeed3cd6-a406-42ee-9363-902d65072900",
51+
"metadata": {},
52+
"source": [
53+
"## Look at all the tracks"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"id": "5a5e7ae7-6a74-4d3f-9b21-1f674095c7d3",
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
63+
"# restrict the data to the same time window \n",
64+
"min_frames = min(np.array(data[0][\"images\"]).shape[0], np.array(data[1][\"images\"]).shape[0], np.array(data[2][\"images\"]).shape[0])\n",
65+
"min_frames"
66+
]
67+
},
4868
{
4969
"cell_type": "code",
5070
"execution_count": null,
51-
"id": "4d5a5e9b-7a27-4f77-82e1-b5fbdc1aa61d",
71+
"id": "3fd8426a-5ec7-46e0-8cb7-8e569e1a6ca5",
5272
"metadata": {},
5373
"outputs": [],
5474
"source": [
55-
"worm_viewer = fpl.ImageWidget(data=[np.array(data[0][\"images\"]), np.array(data[1][\"images\"]), np.array(data[2][\"images\"])], cmap=\"gray\", figure_kwargs={\"size\": (700, 560)})\n",
75+
"# view the raw images \n",
76+
"worm_viewer = fpl.ImageWidget(data=[np.array(data[0][\"images\"])[:min_frames], np.array(data[1][\"images\"])[:min_frames], np.array(data[2][\"images\"])[:min_frames]], \n",
77+
" cmap=\"gray\", \n",
78+
" names=[\"track 0\", \"track 1\", \"track 2\"],\n",
79+
" figure_shape=(1,3),\n",
80+
" figure_kwargs={\"size\": (1000, 560)})\n",
5681
"worm_viewer.show()"
5782
]
5883
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"id": "79aa3668-bad9-4aa4-b729-e997d5cc970b",
88+
"metadata": {},
89+
"outputs": [],
90+
"source": [
91+
"worm_viewer.close()"
92+
]
93+
},
5994
{
6095
"cell_type": "markdown",
6196
"id": "191dc2e5-ceda-427f-8273-c5faf1ba0d43",
@@ -94,16 +129,6 @@
94129
"## View corresponding behavior"
95130
]
96131
},
97-
{
98-
"cell_type": "code",
99-
"execution_count": null,
100-
"id": "b21f71b9-5aa2-465d-8c40-d768f57c1d22",
101-
"metadata": {},
102-
"outputs": [],
103-
"source": [
104-
"track_fig = fpl.Figure(names=[[\"Worm track\"]],size=(900,700))"
105-
]
106-
},
107132
{
108133
"cell_type": "markdown",
109134
"id": "80996883-1656-4927-9d66-238af87a6f43",
@@ -140,7 +165,7 @@
140165
"source": [
141166
"# gives us a color for every datapoint, can then apply as a colormap to our line\n",
142167
"colors = [color_dict[bhv] for bhv in track['behaviors2']]\n",
143-
"colors[:10]"
168+
"colors[420:430]"
144169
]
145170
},
146171
{
@@ -154,13 +179,27 @@
154179
{
155180
"cell_type": "code",
156181
"execution_count": null,
157-
"id": "6720c034-f85a-4b70-baf2-2f1adc3137ee",
182+
"id": "b21f71b9-5aa2-465d-8c40-d768f57c1d22",
158183
"metadata": {},
159184
"outputs": [],
160185
"source": [
186+
"# create a figure to plot the tracks\n",
187+
"track_fig = fpl.Figure(names=[[\"Worm track\"]],size=(900,700))\n",
188+
"\n",
189+
"# add the tracks to the plot\n",
161190
"track_graphic = track_fig[0, 0].add_line(np.column_stack([track['xsc'], track['ysc']]),colors=colors)"
162191
]
163192
},
193+
{
194+
"cell_type": "code",
195+
"execution_count": null,
196+
"id": "a55650d9-314a-4220-8114-728ac3929e92",
197+
"metadata": {},
198+
"outputs": [],
199+
"source": [
200+
"track_fig.show()"
201+
]
202+
},
164203
{
165204
"cell_type": "markdown",
166205
"id": "50161ef9-54fc-4985-aada-6a593bb9a2a5",
@@ -186,7 +225,7 @@
186225
"id": "45a9cef6-6d68-4c4d-910d-8a9981854b80",
187226
"metadata": {},
188227
"source": [
189-
"### Plot the concentrations"
228+
"### Plot the odor concentrations"
190229
]
191230
},
192231
{
@@ -196,10 +235,23 @@
196235
"metadata": {},
197236
"outputs": [],
198237
"source": [
238+
"# create a figure for the concentrations\n",
199239
"data_fig = fpl.Figure(names=[[\"Concentration plot\"]], size=(600, 300))\n",
240+
"\n",
241+
"# add the graphic\n",
200242
"data_graphic = data_fig[0, 0].add_line(np.column_stack([np.array(track['times']), np.array(track[\"xsc\"])]),colors=colors)"
201243
]
202244
},
245+
{
246+
"cell_type": "code",
247+
"execution_count": null,
248+
"id": "9c15204c-f5fb-4e8b-b25e-b5962bf4adf2",
249+
"metadata": {},
250+
"outputs": [],
251+
"source": [
252+
"data_fig.show(maintain_aspect=False)"
253+
]
254+
},
203255
{
204256
"cell_type": "code",
205257
"execution_count": null,
@@ -216,7 +268,7 @@
216268
"id": "2d6b1c51-bd1b-464c-be81-44fc01960fa4",
217269
"metadata": {},
218270
"source": [
219-
"### Add an event handler to update the data"
271+
"### Add an event handler to update the concentration and behavior figures"
220272
]
221273
},
222274
{

0 commit comments

Comments
 (0)