convert_height_to_units

convert_height_to_units(win, height_value)

Convert a size from height units to the current window units.

Provides unit-agnostic size conversion for consistent visual appearance across different PsychoPy coordinate systems. Essential for maintaining proper stimulus sizing when window units differ from the standard height units used in configuration files.

Parameters

Name Type Description Default
win psychopy.visual.Window The PsychoPy window providing unit and size information. required
height_value float Size in height units (fraction of screen height). For example, 0.1 represents 10% of the screen height. required

Returns

Name Type Description
float Size converted to current window units, maintaining the same visual size on screen.

Notes

Height units are PsychoPy’s recommended unit system for maintaining consistent appearance across different screen sizes and aspect ratios.

Supported conversions: height, norm, pix, cm, deg, degFlat, degFlatPos

Examples

from DeToX import Coords
from DeToX import ETSettings as cfg

# Convert border thickness from config to current window units
border_size = Coords.convert_height_to_units(win, cfg.ui_sizes.border)

# Convert text height (works regardless of window units)
text_height = Coords.convert_height_to_units(win, 0.03)  # 3% of screen height

# Use in stimulus creation
circle = visual.Circle(win, radius=border_size)
Back to top