WebSocket server for integrating Tobii eye trackers with jsPsych experiments.
# Install with Tobii SDK support
pip install jspsych-tobii[tobii]
# Or install SDK separately
pip install jspsych-tobii
pip install tobii-research# Use built-in mock tracker
pip install jspsych-tobii
jspsych-tobii-server --mockAll trackers are supported via the tobii-research package:
- Modern Pro series (via
tobii-research2.x): Spectrum, Fusion, Nano, Spark - Older models (via
tobii-research1.x): X3-120, TX300, X2-60, T120, etc. - Mock Tracker: For testing and development without hardware
Note: If you have an older tracker like the X3-120, install
tobii-research<2(version 1.x supports these models; version 2.x dropped them).
See ADAPTER_GUIDE.md for detailed SDK information.
# Basic usage (auto-detect tracker, port 8080)
jspsych-tobii-server
# Specify port
jspsych-tobii-server --port 9000
# Enable debug logging
jspsych-tobii-server --log-level DEBUG
# Log to file
jspsych-tobii-server --log-file server.logSee the main README for JavaScript integration examples.
jspsych-tobii-server [OPTIONS]
Options:
--host HOST Server host address (default: localhost)
--port PORT Server port (default: 8080)
--tracker ADDRESS Specific tracker address (auto-detect if not specified)
--buffer-size SIZE Maximum buffer size (default: 10000)
--log-level LEVEL Logging level: DEBUG, INFO, WARNING, ERROR (default: INFO)
--log-file FILE Log file path (console if not specified)
--version Show version and exit
--help Show this help message
You can also use the server programmatically:
from jspsych_tobii import TobiiServer, ServerConfig
import asyncio
# Create configuration
config = ServerConfig(
host='localhost',
port=8080,
log_level='INFO'
)
# Create and start server
server = TobiiServer(config)
asyncio.run(server.start())- Auto-detection: Automatically finds connected Tobii eye trackers
- WebSocket Protocol: Real-time bidirectional communication
- Time Synchronization: Accurate timestamp alignment between client and server
- Calibration Support: Full calibration and validation workflow
- Data Buffering: Efficient data storage and retrieval
- Logging: Comprehensive logging for debugging
The server communicates via WebSocket using JSON messages.
Client -> Server:
start_tracking: Start eye tracking data collectionstop_tracking: Stop eye trackingcalibration_start: Begin calibrationcalibration_point: Collect calibration pointcalibration_compute: Compute calibrationvalidation_start: Begin validationvalidation_point: Collect validation pointvalidation_compute: Compute validationget_current_gaze: Get latest gaze positionget_data: Get gaze data for time rangetime_sync: Synchronize time
Server -> Client:
gaze_data: Real-time gaze data stream- Response messages for each request type
- Ensure tracker is connected (USB or network)
- Check that Tobii Eye Tracker Manager software recognizes the tracker
- Verify that no other applications are using the tracker
- Try specifying tracker address explicitly:
jspsych-tobii-server --tracker tet-tcp://192.168.1.100
- Check firewall settings
- Verify port is not in use
- Try a different port:
jspsych-tobii-server --port 9000
- Increase buffer size:
jspsych-tobii-server --buffer-size 20000
pip install -e ".[dev]"pytestblack jspsych_tobii
ruff check jspsych_tobiiMIT