This project implements a comprehensive gaze tracking experiment system using WebGazer.js. It enables researchers to present stimuli, track participants' gaze patterns, and collect data for visual attention and object recognition studies.
- Overview
- Features
- System Requirements
- Installation & Setup
- Project Structure
- Usage Guide
- Technical Details
- Troubleshooting
- How to Contribute
- License
The Gaze Analysis Experiment Manager allows researchers to:
- Track participant gaze data using WebGazer.js
- Run configurable visual trials with randomized image objects
- Apply dynamic exclusions based on participant input
- Collect and store experimental data locally
- Support multiple test types (Shapes, Colors, Abstract, Pictures)
- Multiple stimulus categories: Shapes, Colors, Abstract images, and Pictures
- Configurable trials: Select from 10-50 trials per session
- Automated calibration: Built-in eye tracker calibration procedure
- Data collection: Comprehensive gaze data recording with timestamps
- Local data storage: Results saved locally as JSON files
- Secure delivery: HTTPS protocol implementation for secure content delivery
- Browser compatibility: Chrome, Firefox, Edge
- Modular JavaScript architecture
- Modern web browser with WebRTC support (Chrome, Firefox, Edge, or Chromium)
- Webcam access for eye tracking
- Node.js and npm installed (for
http-server) - SSL certificates for secure server connection
-
Install Node.js and npm from nodejs.org
-
Install the required http-server package:
npm install -g http-server
-
Install OpenSSL (if not already installed):
- Linux:
sudo apt-get install openssl(Ubuntu/Debian) orsudo yum install openssl(CentOS/RHEL) - macOS:
brew install openssl - Windows: Download from openssl.org or use a binary distribution
- Linux:
-
Generate SSL certificates (
cert.pemandkey.pem) or use provided ones
The experiment requires HTTPS for security and webcam access. Generate self-signed certificates with OpenSSL:
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pemFollow the prompts (defaults are fine for local testing). Place both cert.pem and key.pem in the project root directory.
GazeTracking/
├── cert.pem # SSL certificate
├── key.pem # SSL key
├── runexperiment.sh # Bash script to start experiment
├── scripts/ # Windows script versions
│ ├── runexperiment.ps1 # PowerShell script
│ └── runexperiment.bat # Windows batch file
├── StudentFolders/ # Contains participant folders
│ ├── [Student_Folder]/
│ │ ├── index.html
│ │ ├── trialManager.js
│ │ ├── objectExclusions.js
│ │ ├── webgazer.js
│ │ ├── localforage.min.js
│ │ ├── Shapes/
│ │ ├── Colors/
│ │ ├── Abstract/
│ │ └── Pictures/
└── AnalysisPlotting.py # Data analysis scriptStimulus images should be placed in the respective folders and named as object001.png, object002.png, etc. Update objectExclusions.js if certain stimuli should not appear together.
chmod +x runexperiment.sh
./runexperiment.sh- PowerShell:
.\scripts\runexperiment.ps1 - Command Prompt:
scripts\runexperiment.bat
- When prompted, select the base directory (default:
./StudentFolders) - Choose a student folder from the list
- The experiment will launch in your default browser
- Enter participant initials when prompted
- Select the stimulus type (Shapes, Colors, Abstract, or Pictures)
- Choose the number of trials to run (10-50)
- Complete the calibration phase by looking at and clicking yellow dots
- The experiment will run automatically, presenting stimuli and recording gaze data
- Upon completion, data will be saved locally and downloaded as a JSON file
- index.html: Main experiment interface, loads scripts and manages UI
- trialManager.js: Controls experiment flow, trial management, and data collection
- webgazer.js: Webcam-based eye tracking
- localforage.min.js: Client-side data storage
- objectExclusions.js: Defines which objects should not appear together in trials
Uses WebGazer.js for webcam-based eye tracking. Calibration requires participants to look at and click on a series of points to improve gaze prediction accuracy.
- Type 1: Target object with two identical distractors
- Type 2: Target object with two different distractors
Each trial records:
- Trial number and type
- Start and end timestamps
- Object identifiers and positions
- Continuous gaze coordinates with timestamps
- Locally using localforage
- Downloaded as a JSON file:
[INITIALS]_[TIMESTAMP]_data.json
A Python script (AnalysisPlotting.py) is provided for generating visualizations and statistical summaries from collected data.
Usage:
python AnalysisPlotting.py <path_to_json>Check the ./experimentalData/<filename> directory for the generated report and plots.
- Ensure your browser has permission to access the webcam
- Check that no other applications are using the webcam
- Try a different browser if issues persist
- Verify
http-serveris installed:npm list -g http-server - Ensure
cert.pemandkey.pemare in the correct location and readable - Check that port 8080 is available:
lsof -i :8080 - If port is in use, modify the port in the script or close the other application
- Use Chrome, Firefox, or Edge for best compatibility
- Ensure your browser is up to date
We welcome contributions! Here's how you can help:
-
Fork & Clone
- Fork the repository
- Create a feature branch
- Make your changes
-
Code Standards
- Follow existing code style
- Document new functions
- Add comments for complex logic
- Test your changes thoroughly
-
Submit Changes
- Push to your fork
- Submit a Pull Request (PR)
- Describe your changes in detail
- Reference any related issues
- New trial types
- Additional analysis tools
- Enhanced calibration methods
- Documentation (usage examples, API docs, tutorials)
- Testing (unit, integration, browser compatibility)
- Check existing issues
- Discuss major changes first
- Follow the coding style guide
- Include tests with new features
- Update documentation
For questions or help, open an issue or contact the maintainers.
Copyright 2024-11-30 Michael Ryan Hunsaker, M.Ed., Ph.D.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.