Skip to main content

An end-to-end python analysis toolkit for eye tracking

Project description

Documentation Status

codecov

PyTrack

This is a toolkit to analyse and visualize eye tracking data. It provides the following functionality:

Feature Extraction

This involves extraction of parameters or meta-data related to blinks, fixations, saccades, microsaccades and pupil diameter. The features extracted are as follows:

Blink Fixations Saccades Microsaccades Pupil Revisits to AOI/ROI
Count Count Count Count Size Count
Avg Duration Avg Duration Velocity Velocity Time to Peak First Pass Duration
Max Duration Max Duration Amplitude Amplitude Peak Size Second Pass Duration
Duration Duration Avg Size
Slope
Area Under Curve

Statistical Analysis

After extraction of features, PyTrack can perform tests such as the student T-Test, Welch T-Test, ANOVA, RMANOVA, n-way ANOVA and Mixed ANOVA. The between and within group factors can be specified.

Visualization

PyTrack can generate a variety of plots. The visualization is through an interactive GUI. The plots that can be generated are as follows:

  1. Fixation plot
  2. Individual subject gaze heat map
  3. Aggregate subject gaze heat map
  4. Dynamic pupil size and gaze plot
  5. Microsaccade position and velocity plot
  6. Microsaccade main sequence plot

Table of Contents

Documentation

The detailed documentation for the methods and classes of PyTrack can be found here

Installation

PyTrack is built for Python3 because support for the Python2 is going to be stopped at the end of 2019. In order to install PyTrack please use any of the following:

python3 -m pip install PyTrack-NTU
pip install PyTrack-NTU
pip3 install PyTrack-NTU

Please make sure that pip is for Python3 and not Python2. Python3 can be found here or Anaconda Python3 can be found here.

NOTE: Python3 can be installed alongside Python2

Sample Data

In order to test the toolkit some sample data in SMI, EyeLink and Tobii formats can be found here. The .txt file in the folder describes the data found. The SMI and Tobii files have been taken from here.

Using PyTrack

The quickest and most concise way to get started is to go through the Python Notebooks:

  1. getting_started_ExpMode.ipynb
  2. getting_started_SAMode.ipynb
  3. getting_started_OwnData.ipynb: If you have data other than Tobii, SMI or EyeLink.

For some advanced use cases read on, and for viewing the detailed documentation of the different modules see here.

Advanced Functionality

Statistical Tests

The Experiment class contains a function called analyse() which is used to perform statistical analysis (eg: ANOVA or T test), by default there is only 1 between group factor ("Subject_type") and 1 within group factor ("Stimuli_type") that is considered. If additional factors need to be considered they need to added to the json file.

  • For example if Gender is to be considered as an additional between group factor then in the json file, under "Subjects", for each subject, a corresponding dicitionary must be created where you mention the factor name and the corresponding value. Please also note that the square brackets ('[', ']') after group type need to be changed to curly brackets ('{', '}').

  • Similarly for Stimuli, for example, if you are showing Words and Pictures to elicit different responses from a user and you additonally have 2 different brightness levels ("High" and "Low") then mention Brightness as an additional within group factor.

{
   "Subjects":{
      "group1":{
         "Subject_01": {"Gender": "M"},
         "Subject_02": {"Gender": "F"}
      },
      "group2":{
         "Subject_03": {"Gender": "F"},
         "Subject_04": {"Gender": "M"}
      }
   },
   "Stimuli":{
      "Type_1":{
         "Stim_1": {"Brightness": "High"},
         "Stim_2": {"Brightness": "Low"}
      },
      "Type_2":{
         "Stim_3": {"Brightness": "Low"},
         "Stim_4": {"Brightness": "High"}
      },
   },
}

Sample code segment to use the advanced statistical test:

from PyTrack.Experiment import Experiment

exp = Experiment(json_file="abcd/efgh/NTU_Experiment/NTU_Experiment.json")

exp.metaMatrixInitialisation()

exp.analyse(parameter_list={"all"},
            between_factor_list=["Subject_type", "Gender"],
            within_factor_list=["Stimuli_type", "Brightness"],
            statistical_test="anova",
            file_creation=True)

Accessing extracted features as a dictionary

In case you wish to get the extracted features for a particular Subject on a particular Stimulus:

from PyTrack.Experiment import Experiment

exp = Experiment(json_file="complete/path/to/NTU_Experiment/NTU_Experiment.json")

subject_name = "sub_333" #specify your own subject's name (must be in json file)
stimulus_name = "Alpha1" #specify your own stimulus name (must be in json file)

# Access metadata dictionary for particular subject and stimulus
exp.metaMatrixInitialisation()
single_meta = exp.getMetaData(sub=subject_name,
                              stim=stimulus_name)

# Access metadata dictionary for particular subject and averaged for stimulus types
exp.metaMatrixInitialisation(average_flag=True)
agg_type_meta = exp.getMetaData(sub=subject_name,
                                 stim=None)

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the GPL3 License - see the LICENSE.txt file for details

Acknowledgments

  • We would like to thank Dr. Dominique Makowski for helping us develop this toolkit.

  • The formatsBridge module was adapted from the work done by Edwin Dalmaijer in PyGazeAnalyser.

  • This work was done under the supervision of Dr. Chng Eng Siong - School of Computer Science and Engineering NTU and in collaboration with Dr. Xu Hong - School of Humanitites and Social Sciences NTU.

  • We extend our thanks to the Department of Computer Science and Engineering Manipal Isntitute of Technology[link] and the Department of Computer Science and Information Systems BITS Pilani, Hyderabad Campus [link]. -->

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyTrack-NTU-1.1.1.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

PyTrack_NTU-1.1.1-py3-none-any.whl (56.6 kB view details)

Uploaded Python 3

File details

Details for the file PyTrack-NTU-1.1.1.tar.gz.

File metadata

  • Download URL: PyTrack-NTU-1.1.1.tar.gz
  • Upload date:
  • Size: 56.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/29.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.5.0 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8

File hashes

Hashes for PyTrack-NTU-1.1.1.tar.gz
Algorithm Hash digest
SHA256 efde2c0d869187650b8fdc7211ba55ac16c07f118827ff5d4744572e68018626
MD5 aaadd3c16741a4445b4c5b70d09d22cf
BLAKE2b-256 1e1173eb0cb8426e235509c01ba101b5acb214b0631eb37a4185c8dce31a871c

See more details on using hashes here.

File details

Details for the file PyTrack_NTU-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: PyTrack_NTU-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 56.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/29.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.5.0 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8

File hashes

Hashes for PyTrack_NTU-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6739515ec43f77f388ec1dbf7501cdfc3c2c02c4adfedcd9769a9ee1a1a879e
MD5 a0d1e5594b804ed3b057a191e0764fad
BLAKE2b-256 30308634b848879dca49667b0fb5418a4f1a9d5ed9164f933e0c771970c13867

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page