A package for reconstructing pupil size and handling eye-tracker blinks.
Project description
prpip
Reconstruct pupil size during blinks in eye-tracking data with a physiologically inspired approach.
Features
- Detects blink intervals in eye-tracking data.
- Reconstructs pupil size during blinks using:
- Logarithmic recovery for long blinks (>50 ms).
- Polynomial blending for short blinks (<50 ms).
- Adds stochastic variability to mimic natural pupil fluctuations.
- Supports processing individual trials or entire datasets.
- Flexible output:
- Save reconstructed data to a new file.
- Replace blinks in the original dataset.
Installation
Install the latest version of prpip from PyPI:
pip install prpip
Quick Start
1. Import the Package
import prpip as pr
2. Process Eye-Tracker Data
# Process and save reconstructed data to a new file
pr.process_eye_tracker_data(
input_file="input.csv",
output_file="reconstructed.csv",
newfile=True # Save as a new file
)
3. Replace Blinks in Original Data
# Replace blinks in the original dataset
processed_data = pr.process_eye_tracker_data(
input_file="input.csv",
newfile=False # Replace blinks in the original data
)
Input File Requirements
The input file must be a CSV with the following columns:
Trial: Identifies the trial number.Pupil Size: The measured pupil size.
Output
The output can either:
- Add a new column
Reconstructed Pupil Size(ifnewfile=True). - Replace the
Pupil Sizecolumn with reconstructed values (ifnewfile=False).
Advanced Parameters
You can customize the behavior of the reconstruction:
-
blink_threshold: Threshold for detecting blinks. Default is0(blinks occur whenPupil Sizeis 0). -
tau: Recovery time constant for logarithmic reconstruction. Default is50. -
noise_scale: Scale of Gaussian noise added to long-blink reconstructions. Default is0.05.
Example:
pr.process_eye_tracker_data(
input_file="input.csv",
output_file="reconstructed.csv",
blink_threshold=0,
tau=60,
noise_scale=0.1,
newfile=True
)
License
This project is licensed under the MIT License.
Contributing
We welcome contributions! To contribute:
- Fork the repository on GitHub.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
Author
- Mohammad Ahsan Khodami
- Email: ahsan.khodami@gmail.com
- GitHub: AhsanKhodami
Example Input and Output
Input:
| Trial | Trial Time | Pupil Size |
|---|---|---|
| 1 | 0 | 4500 |
| 1 | 10 | 0 |
| 1 | 20 | 0 |
| 1 | 30 | 4800 |
Output:
| Trial | Trial Time | Pupil Size | Reconstructed Pupil Size |
|---|---|---|---|
| 1 | 0 | 4500 | 4500 |
| 1 | 10 | 0 | 4600 |
| 1 | 20 | 0 | 4700 |
| 1 | 30 | 4800 | 4800 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prpip-0.0.post1.tar.gz.
File metadata
- Download URL: prpip-0.0.post1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c0e983b3c9eb77bcf8e502d1e54d1fa223d1e8c8b175d859533366a1fe502c2
|
|
| MD5 |
20504aa5457420a9bc51eae3e951a0d3
|
|
| BLAKE2b-256 |
08e19c66a2032ee1fad3f1d73f784b023d6974e21722e2b1f9d5b0834612d3da
|
File details
Details for the file prpip-0.0.post1-py3-none-any.whl.
File metadata
- Download URL: prpip-0.0.post1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f1081b2b7db339fe0b9bb44c09cf6fcae778de89cba3ec5d599d2110bf647ff
|
|
| MD5 |
baf0832c906beed3e674d0919f2e38b5
|
|
| BLAKE2b-256 |
8c346f0980fafe7d2cb49c91a62fbab813c7a0c577672c304fa76f9bdf63d557
|