Skip to contents

This function converts either:

  • stimulus size in pixels (stim_px) to visual angle in degrees, or

  • visual angle in degrees (stim_angle_deg) to stimulus size in pixels,

given the viewing distance and the monitor's physical and pixel dimensions.

Usage

visualangle(
  distance_cm,
  monitor_cm,
  monitor_px,
  stim_px = NULL,
  stim_angle_deg = NULL
)

Arguments

distance_cm

Viewing distance from the screen in centimeters.

monitor_cm

Physical width of the monitor (cm) that corresponds to monitor_px.

monitor_px

Horizontal pixel resolution corresponding to monitor_cm.

stim_px

Stimulus size in pixels. Provide this to compute visual angle.

stim_angle_deg

Stimulus size in degrees of visual angle. Provide this to compute stimulus size in pixels.

Value

A data frame with three columns:

stim_px

Stimulus size in pixels.

stim_angle_deg

Stimulus visual angle in degrees.

stim_cm

Stimulus size in centimeters.

Details

Exactly one of stim_px or stim_angle_deg must be supplied. The function returns a data frame containing stimulus size in pixels, visual angle in degrees, and the corresponding physical size in centimeters.

Examples

# Convert 100 px to degrees at 60 cm viewing distance
visualangle(
  distance_cm = 60,
  monitor_cm = 53,
  monitor_px = 1920,
  stim_px = 100
)
#>   stim_px stim_angle_deg  stim_cm
#> 1     100       2.635539 2.760417

# Convert 5 degrees to pixels
visualangle(
  distance_cm = 60,
  monitor_cm = 53,
  monitor_px = 1920,
  stim_angle_deg = 5
)
#>    stim_px stim_angle_deg  stim_cm
#> 1 189.8015              5 5.239313