This file was created from the following Jupyter-notebook: docs/summary.ipynb
Interactive version: Binder badge

Summarizing pupillometric dataΒΆ

[2]:
import sys
sys.path.insert(0,"..")
import pypillometry as pp

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.

[6]:
d=pp.create_fake_pupildata(ntrials=100)
print(d)
PupilData(fake_nutuheho, 13.9MiB):
 n                 : 113453
 nmiss             : 0
 perc_miss         : 0.0
 nevents           : 200
 nblinks           : 0
 ninterpolated     : 0
 blinks_per_min    : 0.0
 fs                : 1000.0
 duration_minutes  : 1.8908833333333335
 start_min         : 0.0
 end_min           : 1.8908780800185903
 baseline_estimated: False
 response_estimated: False
 History:
 *

By calling the function summary(), summary data is returned in dict form:

[7]:
d.summary()
[7]:
{'name': 'fake_nutuheho',
 'n': 113453,
 'nmiss': 0,
 'perc_miss': 0.0,
 'nevents': 200,
 'nblinks': 0,
 'ninterpolated': 0,
 'blinks_per_min': 0.0,
 'fs': 1000.0,
 'duration_minutes': 1.8908833333333335,
 'start_min': 0.0,
 'end_min': 1.8908780800185903,
 'baseline_estimated': False,
 'response_estimated': False}

Using the package pandas, this allows to rapidly summarize properties of many datasets in a table.

To illustrate, we create a list of datasets, each corresponding to one individual subject:

[8]:
nsubjs=10
datasets=[pp.create_fake_pupildata(ntrials=100) for _ in range(nsubjs)]

We can now call summary() for each of the objects and merge the resulting dict into a table form:

[12]:
import pandas as pd
pd.DataFrame([d.summary() for d in datasets])
[12]:
name n nmiss perc_miss nevents nblinks ninterpolated blinks_per_min fs duration_minutes start_min end_min baseline_estimated response_estimated
0 fake_tamofase 113832 0 0.0 200 0 0 0.0 1000.0 1.897200 0.0 1.897196 False False
1 fake_lobavifu 114425 0 0.0 200 0 0 0.0 1000.0 1.907083 0.0 1.907083 False False
2 fake_paketomu 112977 0 0.0 200 0 0 0.0 1000.0 1.882950 0.0 1.882941 False False
3 fake_hiligovi 114345 0 0.0 200 0 0 0.0 1000.0 1.905750 0.0 1.905735 False False
4 fake_kolavebo 113732 0 0.0 200 0 0 0.0 1000.0 1.895533 0.0 1.895517 False False
5 fake_ropopodi 113661 0 0.0 200 0 0 0.0 1000.0 1.894350 0.0 1.894346 False False
6 fake_rilimolo 114402 0 0.0 200 0 0 0.0 1000.0 1.906700 0.0 1.906698 False False
7 fake_gapudome 113891 0 0.0 200 0 0 0.0 1000.0 1.898183 0.0 1.898178 False False
8 fake_belobeva 113932 0 0.0 200 0 0 0.0 1000.0 1.898867 0.0 1.898865 False False
9 fake_rihatofi 113304 0 0.0 200 0 0 0.0 1000.0 1.888400 0.0 1.888393 False False
This file was created from the following Jupyter-notebook: docs/summary.ipynb
Interactive version: Binder badge