Skip to content

Instantly share code, notes, and snippets.

@fladd
Created February 20, 2020 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fladd/e5424453c3ac298dc8674d574a194acd to your computer and use it in GitHub Desktop.
Save fladd/e5424453c3ac298dc8674d574a194acd to your computer and use it in GitHub Desktop.
def stimulus_size_as_visual_angles(stim_size, screen_size, screen_angles):
"""Convert stimulus size (in pixels) to visual viewing angle (in degree).
Parameters
----------
stim_size : (int, int)
the size of the stimulus in pixels (width, height)
screen_dims : (int, int)
the pixel dimensions of the screen (width, height)
screen_angles : (float, float)
the visual viewing angles of the screen (width, height)
Returns
-------
angles : (float, float)
the visual viewing angle of the distance (width, height)
"""
return ((stim_size[0] / screen_size[0] * 100) / 100 * screen_angles[0],
(stim_size[1] / screen_size[1] * 100) / 100 * screen_angles[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment