An end-to-end python analysis toolkit for eye tracking
Project description
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:
- Fixation plot
- Individual subject gaze heat map
- Aggregate subject gaze heat map
- Dynamic pupil size and gaze plot
- Microsaccade position and velocity plot
- Microsaccade main sequence plot
Table of Contents
- PyTrack
- Table of Contents
- Documentation
- Installation
- Sample Data
- Using PyTrack
- Advanced Functionality
- Authors
- License
- Acknowledgments
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:
- getting_started_ExpMode.ipynb
- getting_started_SAMode.ipynb
- 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
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
Hashes for PyTrack_NTU-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6739515ec43f77f388ec1dbf7501cdfc3c2c02c4adfedcd9769a9ee1a1a879e |
|
MD5 | a0d1e5594b804ed3b057a191e0764fad |
|
BLAKE2b-256 | 30308634b848879dca49667b0fb5418a4f1a9d5ed9164f933e0c771970c13867 |