psychopy.org | Reference | Downloads | Github

Define monitor without "monitor center" (no standalone psychopy)

Hi everyone,

I have installed psychopy manually using a conda environment and then getting all required packages and modules via conda install or pip install.

How can I define my monitor like I would from the “monitor center” gui as included in the standalone version? I have already seen the instructions in the manual but from what I read this seems to be something that should be used after one has already defined a monitor through the gui.

I still went ahead and tried defining my monitor. When running the code however, I got this error message:

Traceback (most recent call last):
  File "basic_psychopy.py", line 50, in <module>
    mywin.flip()
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/visual/window.py", line 638, in flip
    thisStim.draw()
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/visual/shape.py", line 289, in draw
    vertsPix = self.verticesPix
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/visual/basevisual.py", line 467, in verticesPix
    self._updateVertices()
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/visual/basevisual.py", line 506, in _updateVertices
    win=self.win, units=self.units)
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/tools/monitorunittools.py", line 82, in convertToPix
    return unit2pixFunc(vertices, pos, win)
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/tools/monitorunittools.py", line 33, in _deg2pix
    return deg2pix(pos + vertices, win.monitor)
  File "//anaconda/envs/psychopy_env/lib/python2.7/site-packages/psychopy/tools/monitorunittools.py", line 236, in deg2pix
    raise ValueError(msg % monitor.name)
ValueError: Monitor mbp has no known size in pixels (SEE MONITOR CENTER)

I’d be grateful for either:

  • An example of an exhaustive monitor definition using only code
  • A way how to access the monitor gui so that I can:
    • define my monitor exhaustively there once
    • … and then use the code as described in the manual, to make smaller adjustments

After reading the above linked instruction manual more carfully and until the end, I found the solution:

# Define a monitor
my_monitor = monitors.Monitor(name='my_monitor_name')
my_monitor.setSizePix((1280, 800))
my_monitor.setWidth(20)
my_monitor.setDistance(100)
my_monitor.saveMon()

After that, you will be able to load “my_monitor_name” when opening a visual.window

2 Likes

Thanks, Stefan. I just ran into this problem today and was hoping to find a solution in the forum.

:slight_smile: