EyeTrack is a sophisticated MATLAB algorithm for processing and analyzing eye movement data from electrooculography (EOG) recordings. It detects and classifies blinks, saccades, and fixations using advanced signal processing techniques across both horizontal and vertical EOG channels.
- Robust blink detection in the vertical EOG channel
- Independent saccade detection in both vertical and horizontal channels
- Minimum duration thresholding for saccades and fixations
- Integration of vertical and horizontal channel data for comprehensive event classification
- Clear delineation of overlapping events with priority given to blinks
- Visualization tools for analysis results
The algorithm is structured into six primary stages:
- Preprocessing: Applies moving median and bandpass filters to reduce noise and eliminate low-frequency drift.
- Blink Detection: Identifies blinks using peak detection and derivative analysis.
- Saccade Detection: Analyzes both channels to detect saccades using thresholds on the EOG signal derivative.
- Saccade Duration Thresholding: Applies a minimum duration threshold to differentiate genuine saccades from artifacts.
- Label Fusion: Integrates vertical and horizontal label signals for a composite representation.
- Fixation Identification and Thresholding: Identifies and thresholds fixations between detected saccades and blinks.
- Clone this repository:
git clone https://github.com/abbrash/Eye-Movement-Analysis-Algorithm-Using-EOG.git
- Ensure you have MATLAB installed (version R2019b or later recommended).
- Add the eye-track directory to your MATLAB path.
-
Ensure your EOG data file (e.g., 'test.mat') is in the same directory as the main script or specify the full path.
-
Open the main script ('main.m') and set the parameters at the beginning of the script:
dataFile = 'test.mat'; % Name of the data file to be processed time_task = [1 52]; % Time range for the task (in seconds) thresh_sac_dur = 10; % Minimum duration of saccades (in samples) thresh_fix_dur = 50; % Minimum duration of fixations (in samples) sample_rate = 250; % Sampling rate in Hz thresh_blinks = 0.260; % Threshold to detect blinks thresh_sacc_ver = 0.0030; % Threshold to detect vertical saccades thresh_sacc_hor = 0.0035; % Threshold to detect horizontal saccades windowSize = 1500; % Window size for moving average
-
Run the main script in MATLAB. The script will:
- Preprocess the EOG data
- Detect blinks, saccades, and fixations
- Generate visualizations
- Calculate and display statistics
- Save results and workspace
-
The script outputs:
- Printed statistics in the MATLAB console
- Visualization figures
- Saved files:
eye_movement_results_[timestamp].mat
: Contains a structure with all calculated statisticseye_movement_workspace_[timestamp].mat
: Complete workspace for further analysiseye_movement_summary_[timestamp].txt
: Text file with key results
-
To access the results programmatically after running the script:
- Use the
results
structure for all calculated statistics - The
label_sig
variable contains the composite label where:- 3 = blinks
- 2 = saccades
- 1 = fixations
- 0 = unknown events
- Use the
Example of accessing results:
% After running the main script
disp(['Number of blinks: ' num2str(results.blink_stats.number)]);
disp(['Mean fixation duration: ' num2str(results.fix_stats.duration_mean) ' ms']);
When you run the main script, you'll get output similar to the following:
Total recording time: 51.00 seconds
Total fixation time: 30.97 seconds (60.72%)
Total saccade time: 8.24 seconds (16.16%)
Total blink time: 6.01 seconds (11.78%)
Blink Statistics:
Number of blinks: 15
Blink amplitude mean: 0.4264
Blink amplitude standard deviation: 0.0550
Blink duration mean: 396.53 ms
Blink duration standard deviation: 61.33 ms
Saccade Statistics:
Number of saccades: 49
Saccade amplitude mean: 0.0462
Saccade amplitude standard deviation: 0.0460
Saccade duration mean: 84.98 ms
Saccade duration standard deviation: 347.74 ms
Fixation Statistics:
Number of fixations: 54
Fixation duration mean: 2964.44 ms
Fixation duration standard deviation: 1663.59 ms
Results saved to: eye_movement_results_20241020_131304.mat
Workspace saved to: eye_movement_workspace_20241020_131304.mat
Summary saved to: eye_movement_summary_20241020_131304.txt
This output provides a comprehensive summary of the eye movement analysis, including:
- Overall time distribution between fixations, saccades, and blinks
- Detailed statistics for each type of eye movement event
- Information about the saved result files for further analysis
In addition to this textual output, the script generates several visualization plots to help you interpret the data visually. These plots include:
- Vertical Eye Movements
- Horizontal Eye Movements
- Combined Eye Movement Labels
These visualizations offer a graphical representation of the detected eye movements over time, allowing for easy identification of patterns and events in the data.
The algorithm generates several plots to visualize the eye movement data and its analysis:
This plot shows:
- Raw vertical EOG signal (black)
- Detected blinks (red)
- Detected vertical saccades (green)
- Blink threshold (dashed red line)
- Vertical eye movement derivative with saccade threshold
- Vertical label signal showing blinks, saccades, and fixations over time
This plot displays:
- Raw horizontal EOG signal (black)
- Detected horizontal saccades (green)
- Horizontal eye movement derivative with saccade threshold
- Horizontal label signal showing saccades and fixations over time
This plot provides an overview of all detected eye movement events:
- Blinks (level 3)
- Saccades (level 2)
- Fixations (level 1)
- Undefined events (level 0)
These visualizations allow for easy interpretation of the eye movement data, showing the temporal distribution of different eye events and how they relate to the raw EOG signals.
- Reading behavior analysis
- Visual attention studies
- Neurological assessments
- Human-computer interaction research
This project was developed and tested using the EOG device from the Biomechatronic Lab at K. N. Toosi University of Technology, Tehran, Iran. The work was conducted under the supervision of Dr. Mehdi Delrobaei.
- Biomechatronic Lab: LinkedIn
- Dr. Mehdi Delrobaei:
We welcome contributions that build upon this work or extend its capabilities. If you're interested in contributing, please:
- Fork the repository
- Create a new branch for your feature or bug fix
- Commit your changes
- Push to the branch
- Create a new Pull Request
For major changes, please open an issue first to discuss what you would like to change. Please ensure to update tests as appropriate and adhere to the project's coding standards.
If you encounter any issues or have feature requests, please use the GitHub Issues tab to report them.
We appreciate all contributions to improve and expand this project!
This project is licensed under the MIT License - see the LICENSE.md file for details.
Email - [email protected]
Project Link: https://github.com/abbrash/Eye-Movement-Analysis-Algorithm-Using-EOG