Trying to replicate the Gabor patch from the book "Python for experimental psychologist"
Hi !
I bought the book "Python for experimental psychologists" and I am at the Gabor patch section. I am using the package WinPyhton-PyGaze-0.6.0
My "constants.py" code has the following parameters :
DISPSIZE = (1920, 1080)
DISPTYPE = 'psychopy'
My "experiment.py" code for the gabor patch replicates the book code with the Pygaze version
import pygaze
from psychopy.visual import GratingStim
from pygaze.display import Display
from pygaze.screen import Screen
import pygaze.libtime as timer
disp = Display()
gabor = GratingStim(pygaze.expdisplay, tex='sin', mask='gauss', sf=0.05, size=200)
gaborscreen = Screen()
gaborscreen.screen.append(gabor)
disp.fill(gaborscreen)
disp.show()
timer.pause(1000)
disp.close()
But I got the following error message and I don't get it, so if you help me, it would be great, thanks a lot !
FreeType import Failed: expected string or Unicode object, NoneType found
Traceback (most recent call last):
File "experiment.py", line 21, in <module>
disp = Display()
File "C:\Users\JEANR\Documents\WinPython-PyGaze-0.6.0\WinPython-PyGaze-0.6.0\python-2.7.3\lib\site-packages\pygaze\display.py", line 45, in __init__
self.__class__.__init__(self, **args)
File "C:\Users\JEANR\Documents\WinPython-PyGaze-0.6.0\WinPython-PyGaze-0.6.0\python-2.7.3\lib\site-packages\pygaze\_display\psychopydisplay.py", line 70, in __init__
screen=self.screennr, units='pix')
File "C:\Users\JEANR\Documents\WinPython-PyGaze-0.6.0\WinPython-PyGaze-0.6.0\python-2.7.3\lib\site-packages\psychopy\visual\window.py", line 237, in __init__
self.scrWidthCM = self.monitor.getWidth()
AttributeError: 'NoneType' object has no attribute 'getWidth'
0.8789 ERROR avbin.dll failed to load.
Try importing psychopy.visual as the first library
(before anything that uses scipy)
and make sure that avbin is installed.
0.8931 ERROR avbin.dll failed to load.
Try importing psychopy.visual as the first library
(before anything that uses scipy)
and make sure that avbin is installed.
0.9754 WARNING Creating new monitor...
Comments
Looks like PsychoPy didn't set up a default monitor. You could pass your own one to the Display when creating it, e.g. by doing the following:
P.S. We're working on an update of this book; should be out later this year. Given the changes to Python, PyGaze, and PsychoPy, it's quite necessary!
Thank you for the reply ! I am looking forward reading the new version of the book .
I did the following :
# "JR" is the name of my laptop
# 39 and 21 are the actual size of the screen in cm
my "constants.py" file has the following parameter :
DISPSIZE = (1920, 1080)
DISPTYPE = 'psychopy'
And I got the following error message, but, again, I can't resolve it
Oh, sorry, looks like it assumes height! You can just drop that parameter.
While we're on the topic, you could opt to set the distance between you and the screen (also in cm):
BTW, this is PsychoPy's API documentation on the Monitor class: https://psychopy.org/api/monitors.html
I wrote the line as such : my_monitor = Monitor("JR", width=39.0, distance = 67.0). I got the following. I won't bother you too much with this, I can try the "Psychopy" version of the code that is also in the book
Just for information, with the pure Psychopy version of the code, the stim is displayed but still got message error
Looks like the actual error no longer appears. The other messages aren't relevant unless you actually use avbin.