pythonpygletpsychopy

Does anyone know how to fix random green lines appearing on PsychoPy stimuli?


I've just started using PsychoPy and I've tried to flip text and a grating, both of which appear broken up with green lines. Anyone know how to fix this?

I'm using PyCharm with Python 3.8 and I get these error messages, not sure if related:

C:\Users\USERID\AppData\Local\Programs\Python\Python38\lib\site-packages\pyglet\media\codecs\wmf.py:838: UserWarning: [WinError -2147417850] Cannot change thread mode after it is set
  warnings.warn(str(err))
C:\Users\USERID\AppData\Local\Programs\Python\Python38\lib\site-packages\pyglet\image\codecs\wic.py:292: UserWarning: [WinError -2147417850] Cannot change thread mode after it is set
  warnings.warn(str(err))

Here is the code and image for the grating:

    import psychopy.visual
    import psychopy.event
    
    
    win = psychopy.visual.Window(
        size=[400,400],
        fullscr=False,
        units="pix")
    
    grating = psychopy.visual.GratingStim(
        win = win,
        units="pix",
        size=[150,150])
    
    grating.draw()
    win.flip()
    psychopy.event.waitKeys()
    win.close()

grating_image

EDIT: I rolled back pyglet to version 1.4.10 and the error messages disappear but the green lines remain.


Solution

  • Here the solution:

    Try to add the argument multiSample and numSamples when you create your window, as in the example below:

    w = visual.Window([wstim, hstim], color = [0, 0, 0], units = "pix", fullscr=False, multiSample=True, numSamples = 16)
    

    In my script this worked fine.