|
10 | 10 | "\n",
|
11 | 11 | "We will walk through how to compute network burst summary statistics such that we can use them for inference, get samples from the trained density estimator, and then simulate and analyze a few of those discovered model configurations to check if they indeed reproduce the target observation.\n",
|
12 | 12 | "\n",
|
| 13 | + "Many thanks to [Tereza Zuskinova](https://github.com/TerezaZuskinova) at IST Austria for her help in developing and testing this demo.\n", |
| 14 | + "\n", |
13 | 15 | "For more details, visit the [AutoMIND preprint](https://www.biorxiv.org/content/10.1101/2024.08.21.608969v1).\n",
|
14 | 16 | "\n",
|
15 | 17 | "---\n",
|
|
114 | 116 | "metadata": {},
|
115 | 117 | "source": [
|
116 | 118 | "### Load and process target data from raw spike times\n",
|
117 |
| - "Here, we use another recording from the organoid dataset, and demonstrate how to start from raw spike times to computing summary features amenable to be used for inference." |
| 119 | + "Here, we use another recording from the organoid dataset, and demonstrate how to start from raw spike times to computing summary features amenable to be used for inference.\n", |
| 120 | + "\n", |
| 121 | + "You can download the `.npz` file [here](https://figshare.com/s/3f1467f8fb0f328aed16) in `./observations`." |
118 | 122 | ]
|
119 | 123 | },
|
120 | 124 | {
|
|
164 | 168 | "spikes_in_list[0]"
|
165 | 169 | ]
|
166 | 170 | },
|
167 |
| - { |
168 |
| - "cell_type": "code", |
169 |
| - "execution_count": 5, |
170 |
| - "metadata": {}, |
171 |
| - "outputs": [], |
172 |
| - "source": [ |
173 |
| - "\n", |
174 |
| - "\n", |
175 |
| - "# data_all = np.load(\"../../../data/MEA_muotri/trujillo/spikes_only.npz\", allow_pickle=True)\n", |
176 |
| - "# idx = 26\n", |
177 |
| - "# print(data_all[\"recs\"][idx], data_all[\"t\"][idx][-1])\n", |
178 |
| - "# spikes_in_list = data_all[\"spikes\"][idx][0]\n", |
179 |
| - "# t_end = 250.\n", |
180 |
| - "# rec_name = data_all[\"recs\"][idx]\n", |
181 |
| - "# # org_spikes_all, org_t_all, org_name_all = (\n", |
182 |
| - "# # data_all[\"spikes\"],\n", |
183 |
| - "# # data_all[\"t\"],\n", |
184 |
| - "# # data_all[\"recs\"],\n", |
185 |
| - "# # )\n", |
186 |
| - "# np.savez('./example_raw_data.npz', spikes=spikes_in_list, t_end=t_end, recording_name=rec_name, fs=12500)" |
187 |
| - ] |
188 |
| - }, |
189 | 171 | {
|
190 | 172 | "cell_type": "markdown",
|
191 | 173 | "metadata": {},
|
|
197 | 179 | },
|
198 | 180 | {
|
199 | 181 | "cell_type": "code",
|
200 |
| - "execution_count": 6, |
| 182 | + "execution_count": null, |
201 | 183 | "metadata": {},
|
202 | 184 | "outputs": [],
|
203 | 185 | "source": [
|
204 |
| - "spikes_dict = data_utils.convert_spike_array_to_dict(spikes_in_list, fs, 'exc_spikes') # \n", |
205 |
| - "spikes_dict['t_end'] = t_end\n", |
206 |
| - "spikes_dict['inh_spikes'] = {}\n", |
| 186 | + "spikes_dict = data_utils.convert_spike_array_to_dict(spikes_in_list, fs, 'exc_spikes')\n", |
| 187 | + "spikes_dict['t_end'] = t_end # end recording time, you can take this as the last spike time plus a little more.\n", |
207 | 188 | "\n",
|
208 | 189 | "# Analyze data with the same params_dict as the simulated data. \n",
|
209 | 190 | "# Note that depending on your own data, some settings may need to be adjusted in params_dict['params_analysis'].\n",
|
|
221 | 202 | },
|
222 | 203 | {
|
223 | 204 | "cell_type": "code",
|
224 |
| - "execution_count": 7, |
| 205 | + "execution_count": 6, |
225 | 206 | "metadata": {},
|
226 | 207 | "outputs": [
|
227 | 208 | {
|
|
238 | 219 | "source": [
|
239 | 220 | "xlims = [0, 250]\n",
|
240 | 221 | "fig, axs = plt.subplots(2,1,figsize=(2, 1))\n",
|
241 |
| - "plot_utils._plot_raster_pretty(spikes_dict, XL=xlims, every_other=50, fontsize=5, ax=axs[0])\n", |
| 222 | + "plot_utils._plot_raster_pretty(spikes_dict, plot_inh=False, XL=xlims, every_other=50, fontsize=5, ax=axs[0])\n", |
242 | 223 | "plot_utils._plot_rates_pretty(\n",
|
243 | 224 | " spikes_analyzed[1],\n",
|
244 | 225 | " XL=xlims, \n",
|
|
267 | 248 | },
|
268 | 249 | {
|
269 | 250 | "cell_type": "code",
|
270 |
| - "execution_count": 8, |
| 251 | + "execution_count": 7, |
271 | 252 | "metadata": {},
|
272 | 253 | "outputs": [
|
273 | 254 | {
|
|
317 | 298 | "0 1.421244 "
|
318 | 299 | ]
|
319 | 300 | },
|
320 |
| - "execution_count": 8, |
| 301 | + "execution_count": 7, |
321 | 302 | "metadata": {},
|
322 | 303 | "output_type": "execute_result"
|
323 | 304 | }
|
|
329 | 310 | },
|
330 | 311 | {
|
331 | 312 | "cell_type": "code",
|
332 |
| - "execution_count": 9, |
| 313 | + "execution_count": 8, |
333 | 314 | "metadata": {},
|
334 | 315 | "outputs": [
|
335 | 316 | {
|
|
369 | 350 | },
|
370 | 351 | {
|
371 | 352 | "cell_type": "code",
|
372 |
| - "execution_count": 10, |
| 353 | + "execution_count": 9, |
373 | 354 | "metadata": {},
|
374 | 355 | "outputs": [
|
375 | 356 | {
|
376 | 357 | "data": {
|
377 | 358 | "application/vnd.jupyter.widget-view+json": {
|
378 |
| - "model_id": "8c869864d4634528b092c3e95293da68", |
| 359 | + "model_id": "332026e114db48129bb0a59970f5749b", |
379 | 360 | "version_major": 2,
|
380 | 361 | "version_minor": 0
|
381 | 362 | },
|
|
1065 | 1046 | "[20 rows x 30 columns]"
|
1066 | 1047 | ]
|
1067 | 1048 | },
|
1068 |
| - "execution_count": 10, |
| 1049 | + "execution_count": 9, |
1069 | 1050 | "metadata": {},
|
1070 | 1051 | "output_type": "execute_result"
|
1071 | 1052 | }
|
|
1108 | 1089 | },
|
1109 | 1090 | {
|
1110 | 1091 | "cell_type": "code",
|
1111 |
| - "execution_count": 11, |
| 1092 | + "execution_count": 10, |
1112 | 1093 | "metadata": {},
|
1113 | 1094 | "outputs": [
|
1114 | 1095 | {
|
|
1156 | 1137 | },
|
1157 | 1138 | {
|
1158 | 1139 | "cell_type": "code",
|
1159 |
| - "execution_count": 12, |
| 1140 | + "execution_count": 11, |
1160 | 1141 | "metadata": {},
|
1161 | 1142 | "outputs": [
|
1162 | 1143 | {
|
|
1187 | 1168 | },
|
1188 | 1169 | {
|
1189 | 1170 | "cell_type": "code",
|
1190 |
| - "execution_count": 13, |
| 1171 | + "execution_count": 12, |
1191 | 1172 | "metadata": {},
|
1192 | 1173 | "outputs": [
|
1193 | 1174 | {
|
1194 | 1175 | "name": "stdout",
|
1195 | 1176 | "output_type": "stream",
|
1196 | 1177 | "text": [
|
1197 | 1178 | "cache non-existent.\n",
|
1198 |
| - "20241121-1242|20241121-85|20241121-1629|20241121-5|20241121-375|20241121-1401|20241121-1002|20241121-343|20241121-1975|20241121-1430|20241121-211|20241121-1429|20241121-1791|20241121-360|20241121-1479|20241121-565|20241121-794|20241121-1121|20241121-1938|20241121-1829|Simulations took 158.22 seconds.\n", |
| 1179 | + "20241121-211|20241121-1121|20241121-794|20241121-565|20241121-1938|20241121-1242|20241121-85|20241121-1429|20241121-1975|20241121-1829|20241121-5|20241121-1401|20241121-375|20241121-360|20241121-1629|20241121-343|20241121-1479|20241121-1791|20241121-1430|20241121-1002|Simulations took 158.26 seconds.\n", |
1199 | 1180 | "cache non-existent.\n"
|
1200 | 1181 | ]
|
1201 | 1182 | }
|
|
1233 | 1214 | },
|
1234 | 1215 | {
|
1235 | 1216 | "cell_type": "code",
|
1236 |
| - "execution_count": 14, |
| 1217 | + "execution_count": 13, |
1237 | 1218 | "metadata": {},
|
1238 | 1219 | "outputs": [],
|
1239 | 1220 | "source": [
|
|
1254 | 1235 | },
|
1255 | 1236 | {
|
1256 | 1237 | "cell_type": "code",
|
1257 |
| - "execution_count": 15, |
| 1238 | + "execution_count": 14, |
1258 | 1239 | "metadata": {},
|
1259 | 1240 | "outputs": [],
|
1260 | 1241 | "source": [
|
|
1268 | 1249 | },
|
1269 | 1250 | {
|
1270 | 1251 | "cell_type": "code",
|
1271 |
| - "execution_count": 16, |
| 1252 | + "execution_count": 15, |
1272 | 1253 | "metadata": {},
|
1273 | 1254 | "outputs": [
|
1274 | 1255 | {
|
|
1395 | 1376 | " ) \n",
|
1396 | 1377 | " ax2.set_ylabel(\"Rate\", labelpad=-5)\n",
|
1397 | 1378 | "\n",
|
1398 |
| - " plot_utils._plot_raster_pretty(spikes_dict, XL=xlims, every_other=50, fontsize=5, ax=ax3)\n", |
| 1379 | + " # plot real data next to it\n", |
| 1380 | + " plot_utils._plot_raster_pretty(spikes_dict, XL=xlims, plot_inh=False, every_other=50, fontsize=5, ax=ax3)\n", |
1399 | 1381 | " plot_utils._plot_rates_pretty(\n",
|
1400 | 1382 | " spikes_analyzed[1],\n",
|
1401 | 1383 | " XL=xlims, \n",
|
|
0 commit comments