|
45 | 45 | "data.keys()"
|
46 | 46 | ]
|
47 | 47 | },
|
| 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 | + }, |
48 | 68 | {
|
49 | 69 | "cell_type": "code",
|
50 | 70 | "execution_count": null,
|
51 |
| - "id": "4d5a5e9b-7a27-4f77-82e1-b5fbdc1aa61d", |
| 71 | + "id": "3fd8426a-5ec7-46e0-8cb7-8e569e1a6ca5", |
52 | 72 | "metadata": {},
|
53 | 73 | "outputs": [],
|
54 | 74 | "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", |
56 | 81 | "worm_viewer.show()"
|
57 | 82 | ]
|
58 | 83 | },
|
| 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 | + }, |
59 | 94 | {
|
60 | 95 | "cell_type": "markdown",
|
61 | 96 | "id": "191dc2e5-ceda-427f-8273-c5faf1ba0d43",
|
|
94 | 129 | "## View corresponding behavior"
|
95 | 130 | ]
|
96 | 131 | },
|
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 |
| - }, |
107 | 132 | {
|
108 | 133 | "cell_type": "markdown",
|
109 | 134 | "id": "80996883-1656-4927-9d66-238af87a6f43",
|
|
140 | 165 | "source": [
|
141 | 166 | "# gives us a color for every datapoint, can then apply as a colormap to our line\n",
|
142 | 167 | "colors = [color_dict[bhv] for bhv in track['behaviors2']]\n",
|
143 |
| - "colors[:10]" |
| 168 | + "colors[420:430]" |
144 | 169 | ]
|
145 | 170 | },
|
146 | 171 | {
|
|
154 | 179 | {
|
155 | 180 | "cell_type": "code",
|
156 | 181 | "execution_count": null,
|
157 |
| - "id": "6720c034-f85a-4b70-baf2-2f1adc3137ee", |
| 182 | + "id": "b21f71b9-5aa2-465d-8c40-d768f57c1d22", |
158 | 183 | "metadata": {},
|
159 | 184 | "outputs": [],
|
160 | 185 | "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", |
161 | 190 | "track_graphic = track_fig[0, 0].add_line(np.column_stack([track['xsc'], track['ysc']]),colors=colors)"
|
162 | 191 | ]
|
163 | 192 | },
|
| 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 | + }, |
164 | 203 | {
|
165 | 204 | "cell_type": "markdown",
|
166 | 205 | "id": "50161ef9-54fc-4985-aada-6a593bb9a2a5",
|
|
186 | 225 | "id": "45a9cef6-6d68-4c4d-910d-8a9981854b80",
|
187 | 226 | "metadata": {},
|
188 | 227 | "source": [
|
189 |
| - "### Plot the concentrations" |
| 228 | + "### Plot the odor concentrations" |
190 | 229 | ]
|
191 | 230 | },
|
192 | 231 | {
|
|
196 | 235 | "metadata": {},
|
197 | 236 | "outputs": [],
|
198 | 237 | "source": [
|
| 238 | + "# create a figure for the concentrations\n", |
199 | 239 | "data_fig = fpl.Figure(names=[[\"Concentration plot\"]], size=(600, 300))\n",
|
| 240 | + "\n", |
| 241 | + "# add the graphic\n", |
200 | 242 | "data_graphic = data_fig[0, 0].add_line(np.column_stack([np.array(track['times']), np.array(track[\"xsc\"])]),colors=colors)"
|
201 | 243 | ]
|
202 | 244 | },
|
| 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 | + }, |
203 | 255 | {
|
204 | 256 | "cell_type": "code",
|
205 | 257 | "execution_count": null,
|
|
216 | 268 | "id": "2d6b1c51-bd1b-464c-be81-44fc01960fa4",
|
217 | 269 | "metadata": {},
|
218 | 270 | "source": [
|
219 |
| - "### Add an event handler to update the data" |
| 271 | + "### Add an event handler to update the concentration and behavior figures" |
220 | 272 | ]
|
221 | 273 | },
|
222 | 274 | {
|
|
0 commit comments