ETracker.get_gaze_position

ETracker.get_gaze_position(fallback_offscreen=True, method='median')

Get current gaze position from rolling buffer.

Aggregates recent gaze samples from both eyes to provide a stable, real-time gaze estimate. Handles missing or invalid data gracefully.

Parameters

Name Type Description Default
fallback_offscreen bool If True (default), returns an offscreen position (3x screen dimensions) when no valid gaze data is available. If False, returns None. True
method str Aggregation method for combining samples and eyes. - “median” (default): Robust to outliers, good for noisy data - “mean”: Smoother but sensitive to outliers - “last”: Lowest latency, uses only most recent sample 'median'

Returns

Name Type Description
tuple or None Gaze position (x, y) in PsychoPy coordinates (current window units), or None if no valid data and fallback_offscreen=False.

Raises

Name Type Description
RuntimeError If gaze_contingent() was not called to initialize the buffer.

Examples

# Basic usage (median aggregation)
pos = ET_controller.get_gaze_position()
if pos is not None:
     circle.pos = pos

# Use mean for smoother tracking
pos = ET_controller.get_gaze_position(method="mean")

# Lowest latency (last sample only)
pos = ET_controller.get_gaze_position(method="last")

# Return None instead of offscreen position
pos = ET_controller.get_gaze_position(fallback_offscreen=False)
if pos is None:
     print("No valid gaze data")
Back to top