pypillometry 2.0a2__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. pypillometry-2.1.0/MANIFEST.in +2 -0
  2. pypillometry-2.1.0/PKG-INFO +175 -0
  3. pypillometry-2.1.0/README.md +138 -0
  4. pypillometry-2.1.0/VERSION +1 -0
  5. pypillometry-2.1.0/pypillometry/__init__.py +124 -0
  6. pypillometry-2.1.0/pypillometry/cli.py +366 -0
  7. pypillometry-2.1.0/pypillometry/config.py +45 -0
  8. pypillometry-2.1.0/pypillometry/convenience.py +462 -0
  9. pypillometry-2.1.0/pypillometry/events.py +1316 -0
  10. pypillometry-2.1.0/pypillometry/example_data.py +345 -0
  11. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/eyedata/__init__.py +22 -3
  12. pypillometry-2.1.0/pypillometry/eyedata/experimental_setup.py +1265 -0
  13. pypillometry-2.1.0/pypillometry/eyedata/eyedata.py +688 -0
  14. pypillometry-2.1.0/pypillometry/eyedata/eyedatadict.py +368 -0
  15. pypillometry-2.1.0/pypillometry/eyedata/fake_eyedata.py +132 -0
  16. pypillometry-2.1.0/pypillometry/eyedata/foreshortening_calibration.py +687 -0
  17. pypillometry-2.1.0/pypillometry/eyedata/gazedata.py +464 -0
  18. pypillometry-2.1.0/pypillometry/eyedata/generic.py +3301 -0
  19. pypillometry-2.1.0/pypillometry/eyedata/pupildata.py +1023 -0
  20. pypillometry-2.1.0/pypillometry/eyedata/spatial_calibration.py +368 -0
  21. pypillometry-2.1.0/pypillometry/hdf5.py +265 -0
  22. pypillometry-2.1.0/pypillometry/intervals.py +1424 -0
  23. pypillometry-2.1.0/pypillometry/io.py +724 -0
  24. pypillometry-2.0a2/pypillometry/__init__.py → pypillometry-2.1.0/pypillometry/logging.py +60 -30
  25. pypillometry-2.1.0/pypillometry/plot/__init__.py +14 -0
  26. pypillometry-2.1.0/pypillometry/plot/eyeplotter.py +435 -0
  27. pypillometry-2.1.0/pypillometry/plot/gazeplotter.py +528 -0
  28. pypillometry-2.1.0/pypillometry/plot/genplotter.py +689 -0
  29. pypillometry-2.1.0/pypillometry/plot/pupilplotter.py +390 -0
  30. pypillometry-2.1.0/pypillometry/quality.py +902 -0
  31. pypillometry-2.1.0/pypillometry/roi.py +623 -0
  32. pypillometry-2.1.0/pypillometry/segmented.py +1012 -0
  33. pypillometry-2.1.0/pypillometry/signal/__init__.py +26 -0
  34. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/signal/baseline.py +170 -145
  35. pypillometry-2.1.0/pypillometry/signal/fake.py +425 -0
  36. pypillometry-2.1.0/pypillometry/signal/preproc.py +521 -0
  37. pypillometry-2.1.0/pypillometry/signal/pupil.py +785 -0
  38. pypillometry-2.1.0/pypillometry/state.py +463 -0
  39. pypillometry-2.1.0/pypillometry/study.py +412 -0
  40. pypillometry-2.1.0/pypillometry/templates/eyedata_repr.html +71 -0
  41. pypillometry-2.1.0/pypillometry/templates/quality_macros.html +9 -0
  42. pypillometry-2.1.0/pypillometry/templates/quality_page.html +24 -0
  43. pypillometry-2.1.0/pypillometry/templates/quality_report.html +60 -0
  44. pypillometry-2.1.0/pypillometry/templates/quality_summary.html +26 -0
  45. pypillometry-2.1.0/pypillometry/units.py +588 -0
  46. pypillometry-2.1.0/pypillometry/viewer/__init__.py +815 -0
  47. pypillometry-2.1.0/pypillometry/viewer/canvas.py +1482 -0
  48. pypillometry-2.1.0/pypillometry/viewer/navigation.py +173 -0
  49. pypillometry-2.1.0/pypillometry/viewer/tweak.py +1115 -0
  50. pypillometry-2.1.0/pypillometry/viewer/visuals.py +570 -0
  51. pypillometry-2.1.0/pypillometry.egg-info/PKG-INFO +175 -0
  52. pypillometry-2.1.0/pypillometry.egg-info/SOURCES.txt +102 -0
  53. pypillometry-2.1.0/pypillometry.egg-info/entry_points.txt +4 -0
  54. pypillometry-2.1.0/pypillometry.egg-info/requires.txt +20 -0
  55. pypillometry-2.1.0/pypillometry.egg-info/top_level.txt +1 -0
  56. pypillometry-2.1.0/pyproject.toml +64 -0
  57. pypillometry-2.1.0/tests/data/state/make_v0_fixtures.py +55 -0
  58. pypillometry-2.1.0/tests/data/test.edf +0 -0
  59. pypillometry-2.1.0/tests/test_behaviour_events.py +173 -0
  60. pypillometry-2.1.0/tests/test_cli.py +379 -0
  61. pypillometry-2.1.0/tests/test_convenience.py +496 -0
  62. pypillometry-2.1.0/tests/test_event_meta.py +340 -0
  63. pypillometry-2.1.0/tests/test_events.py +596 -0
  64. pypillometry-2.1.0/tests/test_example_data.py +67 -0
  65. pypillometry-2.1.0/tests/test_excluded.py +263 -0
  66. pypillometry-2.1.0/tests/test_experimental_setup.py +772 -0
  67. pypillometry-2.1.0/tests/test_eyedata.py +2614 -0
  68. {pypillometry-2.0a2 → pypillometry-2.1.0}/tests/test_eyedatadict.py +151 -149
  69. pypillometry-2.1.0/tests/test_fake_data.py +579 -0
  70. pypillometry-2.1.0/tests/test_foreshortening_calibration.py +869 -0
  71. pypillometry-2.1.0/tests/test_gazedata.py +711 -0
  72. pypillometry-2.1.0/tests/test_hdf5.py +196 -0
  73. pypillometry-2.1.0/tests/test_import.py +28 -0
  74. pypillometry-2.1.0/tests/test_inplace.py +82 -0
  75. pypillometry-2.1.0/tests/test_intervals_class.py +1883 -0
  76. pypillometry-2.1.0/tests/test_io.py +393 -0
  77. pypillometry-2.1.0/tests/test_io_ssh.py +371 -0
  78. pypillometry-2.1.0/tests/test_plotting_edge_cases.py +190 -0
  79. pypillometry-2.1.0/tests/test_plotting_overlay.py +244 -0
  80. pypillometry-2.1.0/tests/test_plotting_parameters.py +369 -0
  81. pypillometry-2.1.0/tests/test_plotting_pdf.py +184 -0
  82. pypillometry-2.1.0/tests/test_plotting_return_values.py +133 -0
  83. pypillometry-2.1.0/tests/test_plotting_smoke.py +484 -0
  84. pypillometry-2.1.0/tests/test_preproc.py +412 -0
  85. pypillometry-2.1.0/tests/test_public_api.py +120 -0
  86. pypillometry-2.1.0/tests/test_pupil.py +276 -0
  87. pypillometry-2.1.0/tests/test_pupildata.py +192 -0
  88. pypillometry-2.1.0/tests/test_quality.py +287 -0
  89. pypillometry-2.1.0/tests/test_response_valid.py +157 -0
  90. pypillometry-2.1.0/tests/test_roi.py +139 -0
  91. pypillometry-2.1.0/tests/test_segmented.py +887 -0
  92. pypillometry-2.1.0/tests/test_state.py +318 -0
  93. pypillometry-2.1.0/tests/test_study.py +158 -0
  94. pypillometry-2.1.0/tests/test_suppress_output.py +26 -0
  95. pypillometry-2.1.0/tests/test_units.py +509 -0
  96. pypillometry-2.1.0/tests/test_viewer.py +101 -0
  97. pypillometry-2.0a2/PKG-INFO +0 -76
  98. pypillometry-2.0a2/README.md +0 -40
  99. pypillometry-2.0a2/docs/conf.py +0 -135
  100. pypillometry-2.0a2/docs/examples/pypillometry_conf.py +0 -345
  101. pypillometry-2.0a2/pypillometry/convenience.py +0 -273
  102. pypillometry-2.0a2/pypillometry/erpd.py +0 -246
  103. pypillometry-2.0a2/pypillometry/example_data.py +0 -201
  104. pypillometry-2.0a2/pypillometry/eyedata/eyedata.py +0 -231
  105. pypillometry-2.0a2/pypillometry/eyedata/eyedatadict.py +0 -529
  106. pypillometry-2.0a2/pypillometry/eyedata/fakedata.py +0 -185
  107. pypillometry-2.0a2/pypillometry/eyedata/gazedata.py +0 -297
  108. pypillometry-2.0a2/pypillometry/eyedata/generic.py +0 -1203
  109. pypillometry-2.0a2/pypillometry/eyedata/pupildata.py +0 -576
  110. pypillometry-2.0a2/pypillometry/intervals.py +0 -118
  111. pypillometry-2.0a2/pypillometry/io.py +0 -356
  112. pypillometry-2.0a2/pypillometry/plot/__init__.py +0 -13
  113. pypillometry-2.0a2/pypillometry/plot/eyeplotter.py +0 -5
  114. pypillometry-2.0a2/pypillometry/plot/gazeplotter.py +0 -207
  115. pypillometry-2.0a2/pypillometry/plot/genplotter.py +0 -276
  116. pypillometry-2.0a2/pypillometry/plot/pupilplotter.py +0 -213
  117. pypillometry-2.0a2/pypillometry/signal/__init__.py +0 -11
  118. pypillometry-2.0a2/pypillometry/signal/preproc.py +0 -239
  119. pypillometry-2.0a2/pypillometry/signal/pupil.py +0 -323
  120. pypillometry-2.0a2/pypillometry.egg-info/PKG-INFO +0 -76
  121. pypillometry-2.0a2/pypillometry.egg-info/SOURCES.txt +0 -44
  122. pypillometry-2.0a2/pypillometry.egg-info/requires.txt +0 -12
  123. pypillometry-2.0a2/pypillometry.egg-info/top_level.txt +0 -7
  124. pypillometry-2.0a2/setup.py +0 -36
  125. pypillometry-2.0a2/tests/test_convenience.py +0 -109
  126. pypillometry-2.0a2/tests/test_eyedata.py +0 -389
  127. pypillometry-2.0a2/tests/test_gazedata.py +0 -47
  128. pypillometry-2.0a2/tests/test_io.py +0 -100
  129. pypillometry-2.0a2/tests/test_pupil.py +0 -14
  130. pypillometry-2.0a2/tests/test_pupildata.py +0 -44
  131. {pypillometry-2.0a2 → pypillometry-2.1.0}/LICENSE +0 -0
  132. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/data/002_rlmw_events_short.asc +0 -0
  133. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/data/002_rlmw_samples_short.asc +0 -0
  134. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/data/__init__.py +0 -0
  135. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry/stan/baseline_model_asym_laplac.stan +0 -0
  136. {pypillometry-2.0a2 → pypillometry-2.1.0}/pypillometry.egg-info/dependency_links.txt +0 -0
  137. {pypillometry-2.0a2 → pypillometry-2.1.0}/setup.cfg +0 -0
  138. {pypillometry-2.0a2 → pypillometry-2.1.0}/tests/__init__.py +0 -0
@@ -0,0 +1,2 @@
1
+ # the tests and their data in the source distribution (not installed)
2
+ recursive-include tests *.py *.edf
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: pypillometry
3
+ Version: 2.1.0
4
+ Summary: Pupillometry and Eye-tracking in Python.
5
+ Author-email: Matthias Mittner <matthias.mittner@uit.no>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ihrke/pypillometry
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Topic :: Scientific/Engineering
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: numpy
20
+ Requires-Dist: scipy
21
+ Requires-Dist: cmdstanpy
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: pandas
24
+ Requires-Dist: jinja2
25
+ Requires-Dist: requests
26
+ Requires-Dist: loguru
27
+ Requires-Dist: tqdm
28
+ Requires-Dist: h5py
29
+ Requires-Dist: eyelinkio
30
+ Requires-Dist: PyQt5
31
+ Requires-Dist: vispy>=0.14
32
+ Requires-Dist: backports.zstd; python_version < "3.14"
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest; extra == "test"
35
+ Requires-Dist: pytest-cov; extra == "test"
36
+ Dynamic: license-file
37
+
38
+ <p align="center">
39
+ <img src="https://raw.githubusercontent.com/ihrke/pypillometry/master/logo/pypillometry_logo_200x200.png" alt="pypillometry logo" width="160">
40
+ </p>
41
+
42
+ <h1 align="center">pypillometry</h1>
43
+
44
+ <p align="center">
45
+ <b>Preprocessing, analysis and visualization of pupillometric and eye-tracking data in Python.</b>
46
+ </p>
47
+
48
+ <p align="center">
49
+ <a href="https://pypi.org/project/pypillometry/"><img src="https://img.shields.io/pypi/v/pypillometry.svg" alt="PyPI version"></a>
50
+ <a href="https://pypi.org/project/pypillometry/"><img src="https://img.shields.io/pypi/pyversions/pypillometry.svg" alt="Python versions"></a>
51
+ <a href="https://github.com/ihrke/pypillometry/actions/workflows/run-tests.yml"><img src="https://github.com/ihrke/pypillometry/actions/workflows/run-tests.yml/badge.svg" alt="tests"></a>
52
+ <a href="https://codecov.io/gh/ihrke/pypillometry"><img src="https://codecov.io/gh/ihrke/pypillometry/graph/badge.svg?token=BFSKNGT772" alt="coverage"></a>
53
+ <a href="https://ihrke.github.io/pypillometry/"><img src="https://img.shields.io/badge/docs-online-blue.svg" alt="documentation"></a>
54
+ <br>
55
+ <a href="https://doi.org/10.21105/joss.02348"><img src="https://joss.theoj.org/papers/3b06f4f3d5b703fd99c7e622b7edebe4/status.svg" alt="JOSS paper"></a>
56
+ <a href="https://doi.org/10.5281/zenodo.3925528"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.3925528.svg" alt="DOI"></a>
57
+ <a href="https://github.com/ihrke/pypillometry/blob/master/LICENSE"><img src="https://img.shields.io/github/license/ihrke/pypillometry.svg" alt="license"></a>
58
+ </p>
59
+
60
+ <p align="center">
61
+ <a href="https://ihrke.github.io/pypillometry/">Documentation</a> ·
62
+ <a href="https://ihrke.github.io/pypillometry/getting_started/quickstart.html">Quickstart</a> ·
63
+ <a href="https://ihrke.github.io/pypillometry/tutorials/index.html">Tutorials</a> ·
64
+ <a href="https://ihrke.github.io/pypillometry/api/index.html">API reference</a>
65
+ </p>
66
+
67
+ ---
68
+
69
+ **pypillometry** reads recordings from eye trackers (e.g., Eyelink EDF files),
70
+ cleans them (blinks, artifacts, filtering), cuts them into event-related
71
+ segments and plots the results. Pupil size and gaze position of one or both
72
+ eyes are kept together in a single object, and every processing step is
73
+ recorded in the object's history.
74
+
75
+ ![Raw and cleaned pupil data, and the average pupil response to 300 stimuli](https://raw.githubusercontent.com/ihrke/pypillometry/master/docs/images/readme_overview.png)
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ pip install pypillometry
81
+ ```
82
+
83
+ pypillometry requires Python 3.11 or newer. See the
84
+ [installation guide](https://ihrke.github.io/pypillometry/getting_started/installation.html)
85
+ for the development version and conda environments.
86
+
87
+ ## Quick example
88
+
89
+ From raw data to an event-related pupil response, using one of the bundled
90
+ example datasets:
91
+
92
+ ```python
93
+ import pypillometry as pp
94
+ from pypillometry import u
95
+
96
+ d = pp.get_example_data("rlmw_002") # or: pp.EyeData.from_eyelink("recording.edf")
97
+ d.pupil_blinks_detect(apply_mask=True) # detect and mask blinks
98
+ d.pupil_blinks_interpolate() # interpolate them
99
+ d.pupil_lowpass_filter(cutoff=4) # 4 Hz low-pass filter
100
+
101
+ # pupil response from 500 ms before to 2.5 s after each stimulus
102
+ intervals = d.get_intervals("S_", (-500, 2500) * u.ms)
103
+ erpd = d.get_segments(intervals, "left_pupil").baseline_correct((-500, 0))
104
+ erpd.plot()
105
+ ```
106
+
107
+ The [quickstart](https://ihrke.github.io/pypillometry/getting_started/quickstart.html)
108
+ walks through this example step by step.
109
+
110
+ ## Features
111
+
112
+ - **Reading data** from Eyelink EDF and ASC files, saved pickle files, and
113
+ whole studies from a local folder or [OSF](https://osf.io)
114
+ - **Binocular data**: pupil size and gaze of both eyes in one object
115
+ - **Blinks**: detection, merging and interpolation (Mathôt, 2013)
116
+ - **Filtering**: low-pass filtering, smoothing, downsampling, scaling
117
+ - **Events and intervals** with flexible selection by label, function or time
118
+ - **Event-related pupil dilation** for single subjects and groups
119
+ - **Units** everywhere: `3 * u.min`, `"200 ms"`, `60 * u.cm`
120
+ - **Interactive viewer** for long recordings, and command-line tools
121
+ - **Modeling** of tonic baseline and phasic pupil responses (Mittner & Groot, 2025)
122
+
123
+ ## Interactive viewer and command-line tools
124
+
125
+ `pp.view(d)` opens a fast, zoomable viewer for long recordings; `pp.tweak()`
126
+ lets you adjust preprocessing parameters while watching the result. The same
127
+ viewer is available from the command line:
128
+
129
+ ```bash
130
+ pypilview recording.edf # view an Eyelink file or a saved object
131
+ edf2pypil recording.edf # convert EDF once, load much faster later
132
+ pypilinfo data/*.pkl # print a summary of one or more files
133
+ ```
134
+
135
+ ![The pypilview viewer showing pupil size and gaze of both eyes](https://raw.githubusercontent.com/ihrke/pypillometry/master/docs/images/viewer_eyedata.png)
136
+
137
+ See [interactive tools](https://ihrke.github.io/pypillometry/user_guide/viewer.html)
138
+ and [command-line programs](https://ihrke.github.io/pypillometry/getting_started/cli.html)
139
+ in the documentation.
140
+
141
+ ## Coming from version 1?
142
+
143
+ Version 2 is a major restructuring: it handles eye-tracking data in addition
144
+ to pupillometry, and more than one eye at a time. Scripts written for
145
+ version 1 need to be updated (see the
146
+ [changelog](https://ihrke.github.io/pypillometry/development/changelog.html)).
147
+ Version 1 is still available on the
148
+ [v1 branch](https://github.com/ihrke/pypillometry/tree/v1), with its
149
+ [documentation](https://ihrke.github.io/pypillometry/v1/html/index.html), and
150
+ can be installed with `pip install "pypillometry<2"`.
151
+
152
+ ## Citing pypillometry
153
+
154
+ If you use pypillometry in your research, please cite
155
+
156
+ > Mittner, M. (2020). pypillometry: A Python package for pupillometric
157
+ > analyses. *Journal of Open Source Software*, 5(51), 2348.
158
+ > <https://doi.org/10.21105/joss.02348>
159
+
160
+ If you use the estimation of tonic and phasic pupil components, please also
161
+ cite
162
+
163
+ > Mittner, M., & Groot, J. M. (2025). A novel method for modeling tonic and
164
+ > phasic pupil dynamics in humans. *Behavior Research Methods*, 57(9), 233.
165
+ > <https://doi.org/10.3758/s13428-025-02755-7>
166
+
167
+ ## Contributing
168
+
169
+ Bug reports and feature requests are welcome on the
170
+ [issue tracker](https://github.com/ihrke/pypillometry/issues). See the
171
+ [development guide](https://ihrke.github.io/pypillometry/development/index.html)
172
+ for how to contribute code.
173
+
174
+ pypillometry is maintained by Matthias Mittner (<matthias.mittner@uit.no>)
175
+ and released under the [MIT license](https://github.com/ihrke/pypillometry/blob/master/LICENSE).
@@ -0,0 +1,138 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/ihrke/pypillometry/master/logo/pypillometry_logo_200x200.png" alt="pypillometry logo" width="160">
3
+ </p>
4
+
5
+ <h1 align="center">pypillometry</h1>
6
+
7
+ <p align="center">
8
+ <b>Preprocessing, analysis and visualization of pupillometric and eye-tracking data in Python.</b>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://pypi.org/project/pypillometry/"><img src="https://img.shields.io/pypi/v/pypillometry.svg" alt="PyPI version"></a>
13
+ <a href="https://pypi.org/project/pypillometry/"><img src="https://img.shields.io/pypi/pyversions/pypillometry.svg" alt="Python versions"></a>
14
+ <a href="https://github.com/ihrke/pypillometry/actions/workflows/run-tests.yml"><img src="https://github.com/ihrke/pypillometry/actions/workflows/run-tests.yml/badge.svg" alt="tests"></a>
15
+ <a href="https://codecov.io/gh/ihrke/pypillometry"><img src="https://codecov.io/gh/ihrke/pypillometry/graph/badge.svg?token=BFSKNGT772" alt="coverage"></a>
16
+ <a href="https://ihrke.github.io/pypillometry/"><img src="https://img.shields.io/badge/docs-online-blue.svg" alt="documentation"></a>
17
+ <br>
18
+ <a href="https://doi.org/10.21105/joss.02348"><img src="https://joss.theoj.org/papers/3b06f4f3d5b703fd99c7e622b7edebe4/status.svg" alt="JOSS paper"></a>
19
+ <a href="https://doi.org/10.5281/zenodo.3925528"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.3925528.svg" alt="DOI"></a>
20
+ <a href="https://github.com/ihrke/pypillometry/blob/master/LICENSE"><img src="https://img.shields.io/github/license/ihrke/pypillometry.svg" alt="license"></a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="https://ihrke.github.io/pypillometry/">Documentation</a> ·
25
+ <a href="https://ihrke.github.io/pypillometry/getting_started/quickstart.html">Quickstart</a> ·
26
+ <a href="https://ihrke.github.io/pypillometry/tutorials/index.html">Tutorials</a> ·
27
+ <a href="https://ihrke.github.io/pypillometry/api/index.html">API reference</a>
28
+ </p>
29
+
30
+ ---
31
+
32
+ **pypillometry** reads recordings from eye trackers (e.g., Eyelink EDF files),
33
+ cleans them (blinks, artifacts, filtering), cuts them into event-related
34
+ segments and plots the results. Pupil size and gaze position of one or both
35
+ eyes are kept together in a single object, and every processing step is
36
+ recorded in the object's history.
37
+
38
+ ![Raw and cleaned pupil data, and the average pupil response to 300 stimuli](https://raw.githubusercontent.com/ihrke/pypillometry/master/docs/images/readme_overview.png)
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install pypillometry
44
+ ```
45
+
46
+ pypillometry requires Python 3.11 or newer. See the
47
+ [installation guide](https://ihrke.github.io/pypillometry/getting_started/installation.html)
48
+ for the development version and conda environments.
49
+
50
+ ## Quick example
51
+
52
+ From raw data to an event-related pupil response, using one of the bundled
53
+ example datasets:
54
+
55
+ ```python
56
+ import pypillometry as pp
57
+ from pypillometry import u
58
+
59
+ d = pp.get_example_data("rlmw_002") # or: pp.EyeData.from_eyelink("recording.edf")
60
+ d.pupil_blinks_detect(apply_mask=True) # detect and mask blinks
61
+ d.pupil_blinks_interpolate() # interpolate them
62
+ d.pupil_lowpass_filter(cutoff=4) # 4 Hz low-pass filter
63
+
64
+ # pupil response from 500 ms before to 2.5 s after each stimulus
65
+ intervals = d.get_intervals("S_", (-500, 2500) * u.ms)
66
+ erpd = d.get_segments(intervals, "left_pupil").baseline_correct((-500, 0))
67
+ erpd.plot()
68
+ ```
69
+
70
+ The [quickstart](https://ihrke.github.io/pypillometry/getting_started/quickstart.html)
71
+ walks through this example step by step.
72
+
73
+ ## Features
74
+
75
+ - **Reading data** from Eyelink EDF and ASC files, saved pickle files, and
76
+ whole studies from a local folder or [OSF](https://osf.io)
77
+ - **Binocular data**: pupil size and gaze of both eyes in one object
78
+ - **Blinks**: detection, merging and interpolation (Mathôt, 2013)
79
+ - **Filtering**: low-pass filtering, smoothing, downsampling, scaling
80
+ - **Events and intervals** with flexible selection by label, function or time
81
+ - **Event-related pupil dilation** for single subjects and groups
82
+ - **Units** everywhere: `3 * u.min`, `"200 ms"`, `60 * u.cm`
83
+ - **Interactive viewer** for long recordings, and command-line tools
84
+ - **Modeling** of tonic baseline and phasic pupil responses (Mittner & Groot, 2025)
85
+
86
+ ## Interactive viewer and command-line tools
87
+
88
+ `pp.view(d)` opens a fast, zoomable viewer for long recordings; `pp.tweak()`
89
+ lets you adjust preprocessing parameters while watching the result. The same
90
+ viewer is available from the command line:
91
+
92
+ ```bash
93
+ pypilview recording.edf # view an Eyelink file or a saved object
94
+ edf2pypil recording.edf # convert EDF once, load much faster later
95
+ pypilinfo data/*.pkl # print a summary of one or more files
96
+ ```
97
+
98
+ ![The pypilview viewer showing pupil size and gaze of both eyes](https://raw.githubusercontent.com/ihrke/pypillometry/master/docs/images/viewer_eyedata.png)
99
+
100
+ See [interactive tools](https://ihrke.github.io/pypillometry/user_guide/viewer.html)
101
+ and [command-line programs](https://ihrke.github.io/pypillometry/getting_started/cli.html)
102
+ in the documentation.
103
+
104
+ ## Coming from version 1?
105
+
106
+ Version 2 is a major restructuring: it handles eye-tracking data in addition
107
+ to pupillometry, and more than one eye at a time. Scripts written for
108
+ version 1 need to be updated (see the
109
+ [changelog](https://ihrke.github.io/pypillometry/development/changelog.html)).
110
+ Version 1 is still available on the
111
+ [v1 branch](https://github.com/ihrke/pypillometry/tree/v1), with its
112
+ [documentation](https://ihrke.github.io/pypillometry/v1/html/index.html), and
113
+ can be installed with `pip install "pypillometry<2"`.
114
+
115
+ ## Citing pypillometry
116
+
117
+ If you use pypillometry in your research, please cite
118
+
119
+ > Mittner, M. (2020). pypillometry: A Python package for pupillometric
120
+ > analyses. *Journal of Open Source Software*, 5(51), 2348.
121
+ > <https://doi.org/10.21105/joss.02348>
122
+
123
+ If you use the estimation of tonic and phasic pupil components, please also
124
+ cite
125
+
126
+ > Mittner, M., & Groot, J. M. (2025). A novel method for modeling tonic and
127
+ > phasic pupil dynamics in humans. *Behavior Research Methods*, 57(9), 233.
128
+ > <https://doi.org/10.3758/s13428-025-02755-7>
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and feature requests are welcome on the
133
+ [issue tracker](https://github.com/ihrke/pypillometry/issues). See the
134
+ [development guide](https://ihrke.github.io/pypillometry/development/index.html)
135
+ for how to contribute code.
136
+
137
+ pypillometry is maintained by Matthias Mittner (<matthias.mittner@uit.no>)
138
+ and released under the [MIT license](https://github.com/ihrke/pypillometry/blob/master/LICENSE).
@@ -0,0 +1 @@
1
+ v2.1.0
@@ -0,0 +1,124 @@
1
+ """Python-package to help with processing of pupillometric and eyetracking data.
2
+
3
+ This package provides classes for handling pupillometric and eyetracking data
4
+ as well as tools for plotting and analyzing these data.
5
+
6
+ Unit Handling:
7
+ --------------
8
+ Times, distances and angles can carry units, either from the `pypillometry.u`
9
+ namespace (``3 * u.min``, ``(-200, 800) * u.ms``, ``60 * u.cm``,
10
+ ``20 * u.deg``) or as strings (``"3 min"``, ``"60 cm"``, ``"20 deg"``).
11
+
12
+ - Github: https://github.com/ihrke/pypillometry
13
+ - Documentation: https://ihrke.github.io/pypillometry
14
+
15
+ """
16
+
17
+ import os.path
18
+
19
+ # ---------------------------------------------------------------------------
20
+ # Data classes
21
+ from .eyedata import (
22
+ GenericEyeData, EyeData, PupilData, GazeData, FakeEyeData,
23
+ EyeDataDict, ExperimentalSetup, SpatialCalibration,
24
+ ForeshorteningCalibration, keephistory,
25
+ )
26
+ from .plot import EyePlotter, PupilPlotter, GazePlotter
27
+ from .segmented import (
28
+ SegmentedEyeData, GroupLevelSegmentedData, group_segments,
29
+ )
30
+ from .events import Events, ClockSync, sync_clocks
31
+ from .intervals import Intervals, merge_intervals
32
+ from .roi import ROI, CircularROI, RectangularROI
33
+ from .quality import QualityReport, QualityMetric
34
+
35
+ # ---------------------------------------------------------------------------
36
+ # Reading and writing data
37
+ from .io import (
38
+ read_eyelink, read_pickle, write_pickle, download, fetch_url, local_copy,
39
+ osf_authenticate,
40
+ )
41
+ from .study import load_study_local, load_study_osf, get_osf_project_files
42
+ from .example_data import (
43
+ get_available_datasets, get_example_data, get_rlmw_002,
44
+ get_rlmw_002_short, get_rlmw_010_edf,
45
+ )
46
+
47
+ # ---------------------------------------------------------------------------
48
+ # Signal processing
49
+ from .signal import (
50
+ # baseline
51
+ bspline, butter_lowpass, butter_lowpass_filter, downsample,
52
+ baseline_envelope, baseline_envelope_iter_bspline, baseline_pupil_model,
53
+ # preprocessing
54
+ smooth_window, velocity_savgol, detect_blinks_velocity,
55
+ detect_blinks_zero, blink_onsets_mahot,
56
+ # pupil response
57
+ lowpass_filter_iterative, pupil_signal_quality, pupil_kernel,
58
+ pupil_kernel_t, pupil_get_max_duration, plot_prf,
59
+ pupil_build_design_matrix, pupil_response, pupil_response_coverage,
60
+ pupilresponse_nnls,
61
+ pupil_eye_offset,
62
+ # synthetic data
63
+ fake_pupil_baseline, fake_gaze_fixations, add_measurement_noise,
64
+ generate_foreshortening_data,
65
+ )
66
+ from .convenience import zscale
67
+
68
+ # ---------------------------------------------------------------------------
69
+ # Viewer
70
+ from .viewer import view, tweak
71
+
72
+ # ---------------------------------------------------------------------------
73
+ # Units, settings and logging
74
+ from .units import u, Unit, Quantity, parse_time, parse_distance, parse_angle
75
+ from .config import set_default_inplace, get_default_inplace
76
+ from .logging import (
77
+ logging_disable, logging_enable, logging_set_level, logging_get_level,
78
+ loglevel, nologging, initialize_logging,
79
+ )
80
+ from loguru import logger # available as pp.logger, not part of __all__
81
+
82
+ __all__ = [
83
+ # data classes
84
+ "GenericEyeData", "EyeData", "PupilData", "GazeData", "FakeEyeData",
85
+ "EyeDataDict", "ExperimentalSetup", "SpatialCalibration",
86
+ "ForeshorteningCalibration", "keephistory",
87
+ "EyePlotter", "PupilPlotter", "GazePlotter",
88
+ "SegmentedEyeData", "GroupLevelSegmentedData", "group_segments",
89
+ "Events", "ClockSync", "sync_clocks",
90
+ "Intervals", "merge_intervals",
91
+ "ROI", "CircularROI", "RectangularROI",
92
+ "QualityReport", "QualityMetric",
93
+ # reading and writing data
94
+ "read_eyelink", "read_pickle", "write_pickle", "download", "fetch_url",
95
+ "local_copy", "osf_authenticate",
96
+ "load_study_local", "load_study_osf", "get_osf_project_files",
97
+ "get_available_datasets", "get_example_data", "get_rlmw_002",
98
+ "get_rlmw_002_short", "get_rlmw_010_edf",
99
+ # signal processing
100
+ "bspline", "butter_lowpass", "butter_lowpass_filter", "downsample",
101
+ "baseline_envelope", "baseline_envelope_iter_bspline",
102
+ "baseline_pupil_model",
103
+ "smooth_window", "velocity_savgol", "detect_blinks_velocity",
104
+ "detect_blinks_zero", "blink_onsets_mahot",
105
+ "lowpass_filter_iterative", "pupil_signal_quality", "pupil_kernel",
106
+ "pupil_kernel_t", "pupil_get_max_duration", "plot_prf",
107
+ "pupil_build_design_matrix", "pupil_response", "pupil_response_coverage",
108
+ "pupilresponse_nnls",
109
+ "pupil_eye_offset",
110
+ "fake_pupil_baseline", "fake_gaze_fixations", "add_measurement_noise",
111
+ "generate_foreshortening_data",
112
+ "zscale",
113
+ # viewer
114
+ "view", "tweak",
115
+ # units, settings and logging
116
+ "u", "Unit", "Quantity", "parse_time", "parse_distance", "parse_angle",
117
+ "set_default_inplace", "get_default_inplace",
118
+ "logging_disable", "logging_enable", "logging_set_level",
119
+ "logging_get_level", "loglevel", "nologging", "initialize_logging",
120
+ ]
121
+
122
+ initialize_logging()
123
+
124
+ __package_path__ = os.path.abspath(os.path.dirname(__file__))