esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
671 stars 211 forks source link

Add monitor as a parameter for PsychoPyDisplay.__init__() #79

Closed cherepaha closed 7 years ago

cherepaha commented 7 years ago

This problem arises when I create a PsychoPy stimulus with parameters expressed in visual degrees rather than pixels. For instance, dot_stim = visual.DotStim(win=pygaze.expdisplay, dotSize=3, units='deg') throws

...
  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\contrib\lazy_import.py", line 120, in __call__
    return obj(*args, **kwargs)

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\visual\dot.py", line 143, in __init__
    self._update_dotsXY()

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\visual\dot.py", line 466, in _update_dotsXY
    self._updateVertices()

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\visual\basevisual.py", line 502, in _updateVertices
    win=self.win, units=self.units)

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\tools\monitorunittools.py", line 82, in convertToPix
    return unit2pixFunc(vertices, pos, win)

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\tools\monitorunittools.py", line 33, in _deg2pix
    return deg2pix(pos + vertices, win.monitor)

  File "C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\tools\monitorunittools.py", line 236, in deg2pix
    raise ValueError(msg % monitor.name)

ValueError: Monitor __blank__ has no known size in pixels (SEE MONITOR CENTER)

Probably, adding the monitor parameter to PsychoPyDisplay.__init__() and passing it down to psychopy.visual.Window() would solve this

esdalmaijer commented 7 years ago

Although this feature only really benefits users with knowledge of the PsychoPy Monitor Centre, I agree that it's a nice addition to allow those users to choose a specific monitor. Merged the pull request, and will close this issue. Please do feel free to re-open it if you run into any issues.