{ "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": [ "
\n", " | name | \n", "n | \n", "nmiss | \n", "perc_miss | \n", "nevents | \n", "nblinks | \n", "ninterpolated | \n", "blinks_per_min | \n", "fs | \n", "duration_minutes | \n", "start_min | \n", "end_min | \n", "baseline_estimated | \n", "response_estimated | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "fake_tamofase | \n", "113832 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.897200 | \n", "0.0 | \n", "1.897196 | \n", "False | \n", "False | \n", "
1 | \n", "fake_lobavifu | \n", "114425 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.907083 | \n", "0.0 | \n", "1.907083 | \n", "False | \n", "False | \n", "
2 | \n", "fake_paketomu | \n", "112977 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.882950 | \n", "0.0 | \n", "1.882941 | \n", "False | \n", "False | \n", "
3 | \n", "fake_hiligovi | \n", "114345 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.905750 | \n", "0.0 | \n", "1.905735 | \n", "False | \n", "False | \n", "
4 | \n", "fake_kolavebo | \n", "113732 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.895533 | \n", "0.0 | \n", "1.895517 | \n", "False | \n", "False | \n", "
5 | \n", "fake_ropopodi | \n", "113661 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.894350 | \n", "0.0 | \n", "1.894346 | \n", "False | \n", "False | \n", "
6 | \n", "fake_rilimolo | \n", "114402 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.906700 | \n", "0.0 | \n", "1.906698 | \n", "False | \n", "False | \n", "
7 | \n", "fake_gapudome | \n", "113891 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.898183 | \n", "0.0 | \n", "1.898178 | \n", "False | \n", "False | \n", "
8 | \n", "fake_belobeva | \n", "113932 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.898867 | \n", "0.0 | \n", "1.898865 | \n", "False | \n", "False | \n", "
9 | \n", "fake_rihatofi | \n", "113304 | \n", "0 | \n", "0.0 | \n", "200 | \n", "0 | \n", "0 | \n", "0.0 | \n", "1000.0 | \n", "1.888400 | \n", "0.0 | \n", "1.888393 | \n", "False | \n", "False | \n", "