Skip to main content

Python EyeLinkParser

Sebastiaan Mathôt and contributors
Copyright 2016-2023
http://www.cogsci.nl/smathot

About

The python-eyelinkparser module provides a framework to parse EyeLink data files in .asc format, that is, the format that you get after converting an .edf file with edf2asc. This module is mostly for personal use, and is not very well documented.

Installation

pip install python-eyelinkparser

Expected format

The parser assumes monocular recording.

Expected messages

By default, the parser assumes that particular messages are sent to the logfile. If you use different messages, you need to override functions in _eyelinkparser.EyeLinkParser. This is not explained here, but you can look in the source code to see how it works.

Trial start:

start_trial [trialid]

Trial end:

end_trial
stop_trial

Variables:

var [name] [value]

Start of a period of continuous data:

start_phase [name]
phase [name]

End of a period of continuous data:

end_phase [name]
stop_phase [name]

Function reference

eyelinkparser.EyeLinkParser(folder='data', ext=('.asc', '.edf', '.tar.xz'), downsample=None, maxtracelen=None, traceprocessor=None, phasefilter=None, phasemap={}, trialphase=None, edf2asc_binary='edf2asc', multiprocess=False, asc_encoding=None, pupil_size=True, gaze_pos=True, time_trace=True)

The main parser class. This is generally not created directly, but through the eyelinkparser.parse() function, which takes the same keywords as the EyeLinkParser constructor (i.e. the keywords below).

Parameters

  • folder: str, optional : The folder that contains .edf or .asc data files, or files compressed as .tar.xz archives.

  • ext: str or tuple, optional : Allowed file extensions, or a tuple of extensions, for data files.

  • downsample: int or None, optional : Indicates whether traces (if any) should be downsampled. For example, a value of 10 means that the signal becomes 10 times shorter. Downsample creates a simple traceprocessor, and can therefore not be used in combination with the traceprocessor argument.

  • maxtracelen: int or None, optional : A maximum length for traces. Longer traces are truncated and a UserWarning is emitted. This length refers to the trace after downsampling/ processing.

  • traceprocessor: callable or None, optional : A function that is applied to each trace before the trace is written to the SeriesColumn. This can be used to apply a series of operations that are best done on the raw signal, such as first correcting blinks and then downsampling the signal.

    The function must accept two arguments: first a label for the trace, which is 'pupil', 'xcoor', 'ycoor', or 'time'. This allows the function to distinguish the different kinds of singals; second, the trace itself.

    See eyelinkparser.defaulttraceprocessor for a convenience function that applies blink correction and downsampling.

  • trialphase: str or None, optional : Indicates the name of a phase that should be automatically started when the trial starts, or None when no trial should be automatically started. This is mostly convenient for processing trials that consist of a single long epoch, or when no start_phase messages were written to the log file.

  • phasefilter: callable or None, optional : A function that receives a phase name as argument, and returns a bool indicating whether that phase should be retained.

  • phasemap: dict, optional : A dict in which keys are phase names that are renamed to the associated values. This is mostly useful to merge subsequent traces, in which case the key is the first trace and the value is the second trace.

  • edf2asc_binary: str, optional : The name of the edf2asc executable, which if available can be used to automatically convert .edf files to .asc. If not available, the parser can only parse .asc files.

  • multiprocess: bool or int or None, optional : Indicates whether each file should be processed in a different process. This can speed up parsing considerably. If not False, this should be an int to indicate the number of processes, or None to indicate that the number of processes should be the same as the number of cores.

  • asc_encoding: str or None, optional : Indicates the character encoding of the .asc files, or None to use system default.

  • pupil_size: bool, optional : Indicates whether pupil-size traces should be stored. If enabled, pupil size is stored as ptrace_[phase] columns.

  • gaze_pos: bool, optional : Indicates whether horizontal and vertical gaze-position traces should be stored. If enabled, gaze position is stored as xtrace_[phase] and ytrace_[phase] columns.

  • time_trace: bool, optional : Indicates whether timestamp traces should be stored, which indicate the timestamps of the corresponding pupil and gaze-position traces. If enabled, timestamps are stored as ptrace_[phase] columns.

Examples

import eyelinkparser as ep
dm = ep.parse(defaulttraceprocessor=ep.defaulttraceprocessor(
    blinkreconstruct=True, downsample=True, mode='advanced'))

Tutorial

For a tutorial about using EyeLinkParser, see:

License

python-eyelinkparser is licensed under the GNU General Public License v3.

Release files for python-eyelinkparser 0.17.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-eyelinkparser 0.17.3
File Size Uploaded
python-eyelinkparser-0.17.3.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-eyelinkparser 0.17.3
File Interpreter ABI Platform
python_eyelinkparser-0.17.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 36.9 kB

Release files / python-eyelinkparser-0.17.3.tar.gz

Download URL python-eyelinkparser-0.17.3.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6735b9f1ddec29c68f8f968b167c8d23d84986cd2c525d46bc30e5a4e227e507
BLAKE2b-256 checksum
How to use checksums
e594e407a3e17753827435cc3cc5fec1a3c0855bad0f0ba7b4699bfdc3f0097d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / python_eyelinkparser-0.17.3-py2.py3-none-any.whl

Download URL python_eyelinkparser-0.17.3-py2.py3-none-any.whl
Size 21.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d7e76518c7ff3db95ab7e9cb74b1101e8474736a4ff26502006eb2133ad26e18
BLAKE2b-256 checksum
How to use checksums
2d4da6a3a2bfa12da422d0c04d4bb771f8204e1412c298f294734ee129590ae6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.17.3 This release

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.16.0

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page