Skip to main content

WebSocket server for integrating Tobii Pro eye trackers with jsPsych

Project description

jspsych-tobii (Python Server)

WebSocket server for integrating Tobii eye trackers with jsPsych experiments.

Installation

# Install with Tobii SDK support
pip install jspsych-tobii[tobii]

# Or install SDK separately
pip install jspsych-tobii
pip install tobii-research

For Testing Without Hardware

# Use built-in mock tracker
pip install jspsych-tobii
jspsych-tobii-server --mock

Supported Hardware

All trackers are supported via the tobii-research package:

  • Modern Pro series (via tobii-research 2.x): Spectrum, Fusion, Nano, Spark
  • Older models (via tobii-research 1.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.

Quick Start

Start Server

# 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.log

Use with jsPsych

See the main README for JavaScript integration examples.

Command-Line Options

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

Python API

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())

Features

  • 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

WebSocket Protocol

The server communicates via WebSocket using JSON messages.

Message Types

Client -> Server:

  • start_tracking: Start eye tracking data collection
  • stop_tracking: Stop eye tracking
  • calibration_start: Begin calibration
  • calibration_point: Collect calibration point
  • calibration_compute: Compute calibration
  • validation_start: Begin validation
  • validation_point: Collect validation point
  • validation_compute: Compute validation
  • get_current_gaze: Get latest gaze position
  • get_data: Get gaze data for time range
  • time_sync: Synchronize time

Server -> Client:

  • gaze_data: Real-time gaze data stream
  • Response messages for each request type

Troubleshooting

Tracker Not Found

  1. Ensure tracker is connected (USB or network)
  2. Check that Tobii Eye Tracker Manager software recognizes the tracker
  3. Verify that no other applications are using the tracker
  4. Try specifying tracker address explicitly:
    jspsych-tobii-server --tracker tet-tcp://192.168.1.100
    

Connection Issues

  1. Check firewall settings
  2. Verify port is not in use
  3. Try a different port:
    jspsych-tobii-server --port 9000
    

Performance Issues

  1. Increase buffer size:
    jspsych-tobii-server --buffer-size 20000
    

Development

Install Development Dependencies

pip install -e ".[dev]"

Run Tests

pytest

Code Formatting

black jspsych_tobii
ruff check jspsych_tobii

License

MIT

Support

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

jspsych_tobii-0.1.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jspsych_tobii-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file jspsych_tobii-0.1.0.tar.gz.

File metadata

  • Download URL: jspsych_tobii-0.1.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jspsych_tobii-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb7522a5828d64de3e0838f52a385af0a72208935abfeefd16fc88839515cdca
MD5 8e1f6210b1b77d8237db0f35adedd3e4
BLAKE2b-256 1db3db2c6ed15a4ee12c41a8a9afcd90421124f6d39f5b134308bc760c616fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for jspsych_tobii-0.1.0.tar.gz:

Publisher: release-python.yml on jspsych/tobii-integration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jspsych_tobii-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jspsych_tobii-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jspsych_tobii-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd0c8f3b293e4033924a6cc0adaaf46aa1916512fc4b0b0395dad233b25be6f
MD5 13cd292439446fd5f4cf346483658eca
BLAKE2b-256 8d61014e973b710fb8310c1cc7bb7d2b6e69a9ba4740375eb62f325c83bc9e82

See more details on using hashes here.

Provenance

The following attestation bundles were made for jspsych_tobii-0.1.0-py3-none-any.whl:

Publisher: release-python.yml on jspsych/tobii-integration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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