-
Notifications
You must be signed in to change notification settings - Fork 11
/
summary.ipynb.txt
415 lines (415 loc) · 12.7 KB
/
summary.ipynb.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Summarizing pupillometric data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.insert(0,\"..\")\n",
"import pypillometry as pp"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `pypillometry` package provides several functions for summarizing datasets. Simply `print()`ing a `PupilData` object gives a readable summary of the main properties of the dataset and also prints the complete history of operations applied to the dataset."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PupilData(fake_nutuheho, 13.9MiB):\n",
" n : 113453\n",
" nmiss : 0\n",
" perc_miss : 0.0\n",
" nevents : 200\n",
" nblinks : 0\n",
" ninterpolated : 0\n",
" blinks_per_min : 0.0\n",
" fs : 1000.0\n",
" duration_minutes : 1.8908833333333335\n",
" start_min : 0.0\n",
" end_min : 1.8908780800185903\n",
" baseline_estimated: False\n",
" response_estimated: False\n",
" History:\n",
" *\n",
"\n"
]
}
],
"source": [
"d=pp.create_fake_pupildata(ntrials=100)\n",
"print(d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" By calling the function `summary()`, summary data is returned in `dict` form:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': 'fake_nutuheho',\n",
" 'n': 113453,\n",
" 'nmiss': 0,\n",
" 'perc_miss': 0.0,\n",
" 'nevents': 200,\n",
" 'nblinks': 0,\n",
" 'ninterpolated': 0,\n",
" 'blinks_per_min': 0.0,\n",
" 'fs': 1000.0,\n",
" 'duration_minutes': 1.8908833333333335,\n",
" 'start_min': 0.0,\n",
" 'end_min': 1.8908780800185903,\n",
" 'baseline_estimated': False,\n",
" 'response_estimated': False}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d.summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using the package `pandas`, this allows to rapidly summarize properties of many datasets in a table.\n",
"\n",
"To illustrate, we create a list of datasets, each corresponding to one individual subject:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"nsubjs=10\n",
"datasets=[pp.create_fake_pupildata(ntrials=100) for _ in range(nsubjs)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now call `summary()` for each of the objects and merge the resulting `dict` into a table form:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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>name</th>\n",
" <th>n</th>\n",
" <th>nmiss</th>\n",
" <th>perc_miss</th>\n",
" <th>nevents</th>\n",
" <th>nblinks</th>\n",
" <th>ninterpolated</th>\n",
" <th>blinks_per_min</th>\n",
" <th>fs</th>\n",
" <th>duration_minutes</th>\n",
" <th>start_min</th>\n",
" <th>end_min</th>\n",
" <th>baseline_estimated</th>\n",
" <th>response_estimated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>fake_tamofase</td>\n",
" <td>113832</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.897200</td>\n",
" <td>0.0</td>\n",
" <td>1.897196</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>fake_lobavifu</td>\n",
" <td>114425</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.907083</td>\n",
" <td>0.0</td>\n",
" <td>1.907083</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>fake_paketomu</td>\n",
" <td>112977</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.882950</td>\n",
" <td>0.0</td>\n",
" <td>1.882941</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>fake_hiligovi</td>\n",
" <td>114345</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.905750</td>\n",
" <td>0.0</td>\n",
" <td>1.905735</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>fake_kolavebo</td>\n",
" <td>113732</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.895533</td>\n",
" <td>0.0</td>\n",
" <td>1.895517</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>fake_ropopodi</td>\n",
" <td>113661</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.894350</td>\n",
" <td>0.0</td>\n",
" <td>1.894346</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>fake_rilimolo</td>\n",
" <td>114402</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.906700</td>\n",
" <td>0.0</td>\n",
" <td>1.906698</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>fake_gapudome</td>\n",
" <td>113891</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.898183</td>\n",
" <td>0.0</td>\n",
" <td>1.898178</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>fake_belobeva</td>\n",
" <td>113932</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.898867</td>\n",
" <td>0.0</td>\n",
" <td>1.898865</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>fake_rihatofi</td>\n",
" <td>113304</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>1000.0</td>\n",
" <td>1.888400</td>\n",
" <td>0.0</td>\n",
" <td>1.888393</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name n nmiss perc_miss nevents nblinks ninterpolated \\\n",
"0 fake_tamofase 113832 0 0.0 200 0 0 \n",
"1 fake_lobavifu 114425 0 0.0 200 0 0 \n",
"2 fake_paketomu 112977 0 0.0 200 0 0 \n",
"3 fake_hiligovi 114345 0 0.0 200 0 0 \n",
"4 fake_kolavebo 113732 0 0.0 200 0 0 \n",
"5 fake_ropopodi 113661 0 0.0 200 0 0 \n",
"6 fake_rilimolo 114402 0 0.0 200 0 0 \n",
"7 fake_gapudome 113891 0 0.0 200 0 0 \n",
"8 fake_belobeva 113932 0 0.0 200 0 0 \n",
"9 fake_rihatofi 113304 0 0.0 200 0 0 \n",
"\n",
" blinks_per_min fs duration_minutes start_min end_min \\\n",
"0 0.0 1000.0 1.897200 0.0 1.897196 \n",
"1 0.0 1000.0 1.907083 0.0 1.907083 \n",
"2 0.0 1000.0 1.882950 0.0 1.882941 \n",
"3 0.0 1000.0 1.905750 0.0 1.905735 \n",
"4 0.0 1000.0 1.895533 0.0 1.895517 \n",
"5 0.0 1000.0 1.894350 0.0 1.894346 \n",
"6 0.0 1000.0 1.906700 0.0 1.906698 \n",
"7 0.0 1000.0 1.898183 0.0 1.898178 \n",
"8 0.0 1000.0 1.898867 0.0 1.898865 \n",
"9 0.0 1000.0 1.888400 0.0 1.888393 \n",
"\n",
" baseline_estimated response_estimated \n",
"0 False False \n",
"1 False False \n",
"2 False False \n",
"3 False False \n",
"4 False False \n",
"5 False False \n",
"6 False False \n",
"7 False False \n",
"8 False False \n",
"9 False False "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"pd.DataFrame([d.summary() for d in datasets])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}