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
# ETracker.get_gaze_position { #DeToX.ETracker.get_gaze_position }```pythonETracker.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 {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||--------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|| fallback_offscreen | [bool](`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](`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 {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------|| | [tuple](`tuple`) or None | Gaze position (x, y) in PsychoPy coordinates (current window units), or None if no valid data and fallback_offscreen=False. |## Raises {.doc-section .doc-section-raises}| Name | Type | Description ||--------|--------------------------------|---------------------------------------------------------------|| | [RuntimeError](`RuntimeError`) | If gaze_contingent() was not called to initialize the buffer. |## Examples {.doc-section .doc-section-examples}```python# Basic usage (median aggregation)pos = ET_controller.get_gaze_position()if pos isnotNone: circle.pos = pos# Use mean for smoother trackingpos = 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 positionpos = ET_controller.get_gaze_position(fallback_offscreen=False)if pos isNone:print("No valid gaze data")```