FOR DEVELOPERS

Explore developer resources

Build. Integrate. Innovate. Learn how easy it is to transform your products and solutions with AI-powered eye-tracking from HarmonEyes.

Pupil Labs Neon Batch Example

The batch API allows you to process pre-recorded eye tracking data offline. This is ideal for analyzing historical recordings or batch processing multiple sessions. See the API Reference section for detailed method documentation.

Complete Batch Processing Example

import harmoneyes_theia
from zoneinfo import ZoneInfo

# Initialize SDK
sdk = harmoneyes_theia.TheiaSDK(license_key="your-license-key-here")
 
# Cognitive load predictions (parallel processing with 4 cores)
# recording.csv is assumed to be a previously recorded session
cog_results = sdk.predict_cog_load_batch("recording.csv", n_jobs=4)
print(f"Cognitive load: {len(cog_results)} predictions")
 
# Drowsiness predictions with timezone (use all available cores)
drowsiness_results = sdk.predict_drowsiness_batch(
    "recording.csv",
    timezone=ZoneInfo("America/New_York"),
    n_jobs=-1
)
print(f"Drowsiness: {len(drowsiness_results)} predictions")

Model Refinement Example

Refine the cognitive load model with ground truth labeled data:

# Define labeled periods (start_timestamp, end_timestamp, label)
refining_data = [
    (1234567890.0, 1234567920.0, "Low"), # 30 seconds of low cognitive load
    (1234567920.0, 1234567950.0, "High"), # 30 seconds of high cognitive load
]
 
# Refine and re-predict
sdk.refine_cog_load_batch("recording.csv", refining_data=refining_data)
cog_results = sdk.predict_cog_load_batch("recording_2.csv", n_jobs=4)
 
# Reset for next independent recording
sdk.reset_models_batch()

Model Persistence

The SDK automatically saves and loads refined cognitive load models:

  • Auto-Save: When you refine the model, it is automatically saved
  • Auto-Load: On SDK initialization, saved refined models are automatically loaded
# Check model status
info = sdk.get_model_info()
print(f"Model refined: {info['is_refined']}")
print(f"Refinements: {info['refinement_count']}")
 
# Reset to base model if needed
sdk.reset_to_base_model()