get_psychopy_pos

get_psychopy_pos(win, p, units=None)

Convert Tobii ADCS coordinates to PsychoPy coordinates.

Transforms eye tracker coordinates from Tobii’s Active Display Coordinate System (ADCS) to PsychoPy’s coordinate system. ADCS uses normalized coordinates where (0,0) is top-left and (1,1) is bottom-right. This function is critical for correctly positioning gaze data within PsychoPy stimuli.

Supports both single coordinate conversion and vectorized batch conversion for efficient processing of recorded gaze data.

Parameters

Name Type Description Default
win psychopy.visual.Window The PsychoPy window providing unit and size information. required
p tuple or array - like Tobii ADCS coordinates to convert: - Single coordinate: (x, y) tuple - Multiple coordinates: (N, 2) array where N is number of samples Values should be in range [0, 1] where (0,0) is top-left. required
units str Target PsychoPy units. If None, uses window’s default units. Supported: ‘norm’, ‘height’, ‘pix’, ‘cm’, ‘deg’, ‘degFlat’, ‘degFlatPos’. None

Returns

Name Type Description
tuple or ndarray Converted PsychoPy coordinates in specified unit system: - Single input: returns (x, y) tuple - Array input: returns (N, 2) array Origin is at screen center for most unit systems.

Raises

Type Description
ValueError If the provided units are not supported.

Examples

from DeToX import Coords
import numpy as np

# Single coordinate conversion
tobii_gaze = (0.5, 0.5)  # Center of screen in ADCS
psychopy_gaze = Coords.get_psychopy_pos(win, tobii_gaze)
# Returns (0.0, 0.0) in most units - screen center

# Vectorized conversion for recorded data (efficient!)
recorded_gaze = np.array([
    [0.5, 0.5],   # Center
    [0.0, 0.0],   # Top-left
    [1.0, 1.0]    # Bottom-right
])
psychopy_positions = Coords.get_psychopy_pos(win, recorded_gaze)
# Returns (3, 2) array with all positions converted

# Specify target units explicitly
gaze_in_pixels = Coords.get_psychopy_pos(win, (0.5, 0.3), units='pix')
Back to top