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, while PsychoPy typically uses centered coordinates with various unit systems.

This function is critical for correctly positioning gaze data within PsychoPy stimuli and for accurate visualization of eye tracking results.

Parameters

Name Type Description Default
win psychopy.visual.Window The PsychoPy window which provides information about units and size. Window properties determine the target coordinate system. required
p tuple or array - like The Tobii ADCS coordinates to convert. Can be: - 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 and (1, 1) is bottom-right. required
units str The target units for the PsychoPy coordinates. If None, uses the window’s default units. Supported: ‘norm’, ‘height’, ‘pix’, ‘cm’, ‘deg’, ‘degFlat’, ‘degFlatPos’. None

Returns

Name Type Description
tuple or ndarray The converted PsychoPy coordinates in the 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

Name Type Description
ValueError If the provided units are not supported by PsychoPy.

Examples

>>> # Single coordinate
>>> pos = get_psychopy_pos(win, (0.5, 0.5))  # Returns (0, 0) in most units
>>> # Multiple coordinates (vectorized)
>>> coords = np.array([[0.5, 0.5], [0.0, 0.0], [1.0, 1.0]])
>>> positions = get_psychopy_pos(win, coords)  # Returns (N, 2) array
Back to top