def pix2deg(pixels, monitor, correctFlat=False):
 scrWidthCm = monitor.getWidth()
 scrSizePix = monitor.getSizePix()
 if (scrSizePix is None):
  msg = 'Monitor %s has no known size in pixels (SEE MONITOR CENTER)'
  raise ValueError((msg % monitor.name))
 if (scrWidthCm is None):
  msg = 'Monitor %s has no known width in cm (SEE MONITOR CENTER)'
  raise ValueError((msg % monitor.name))
 cmSize = ((pixels * float(scrWidthCm)) / scrSizePix[0])
 return cm2deg(cmSize, monitor, correctFlat)

def pix2deg ( pixels , monitor , correctFlat = False ) : scrWidthCm = monitor . getWidth ( ) scrSizePix = monitor . getSizePix ( ) if ( scrSizePix is None ) : msg = 'Monitor %s has no known size in pixels (SEE MONITOR CENTER)' raise ValueError ( ( msg % monitor . name ) ) if ( scrWidthCm is None ) : msg = 'Monitor %s has no known width in cm (SEE MONITOR CENTER)' raise ValueError ( ( msg % monitor . name ) ) cmSize = ( ( pixels * float ( scrWidthCm ) ) / scrSizePix [ 0 ] ) return cm2deg ( cmSize , monitor , correctFlat )
convert size in pixels to size in degrees for a given monitor object .