AssertionError: SetDeviceGammaRamp failed when creating MovieStim3

Hi psychopy community,

Getting my feet wet with psychopy and have run into an error when trying to create a visual.MovieStim3 object.

Potentially useful information about my setup:

  • Using psychopy standalone version 1.90.2, python 3
  • Running on Windows 10 laptop
  • Dual monitor setup, second monitor UHD

The problem:
I am unable to create a movie object. I’ve tried with all 3 MovieStim classes and they all produce the same error of the SetDeviceGammaRamp failing. This is regardless of which monitor I display to. It seems to be a problem of windll.gdi32.SetDeviceGammaRamp(…) in visual.backends.gamma failing.

Since the comments say this doesn’t always work the first time on Windows machines, I tried increasing the number of time setGammaRamp tries this function with same results.

I’m not sure if it’s relevant, but psychopy also warns me about the full screen size I request being different from the monitor’s size, although this value is taken directly from the monitor display and matches in the windows control panel. And complains about not being able to measure a consistent frame rate.

Minimal (Non)Working Example that generates error:

import psychopy
psychopy.useVersion('latest')

from psychopy import monitors, visual

expMonitor = monitors.Monitor('subjectMonitor')
SCREEN_SIZE = (3840,2160)

window2use = visual.Window(
    SCREEN_SIZE, fullscr=True, screen=0,
    allowGUI=False, allowStencil=False,
    monitor=expMonitor, color=[0,0,0], colorSpace='rgb')


movieFullPath = r'C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\videos\negative_female_05_05_05.mp4'

thisMovie = visual.MovieStim3(win=window2use, name='testmovie', 
                noAudio = False, filename = movieFullPath)

win.close()
core.quit()

Warnings and Stack Trace:

##### Running: C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\MWE3.py #####
1.3201     WARNING     Monitor specification not found. Creating a temporary one...
1.3218     WARNING     User requested fullscreen with size [3840 2160], but screen is actually [2560, 1440]. Using actual size
5.0339     WARNING     Couldn't measure a consistent frame rate.
  - Is your graphics card set to sync to vertical blank?
  - Are you running other processes on your computer?

5.0387     WARNING     avbin.dll failed to load. Try importing psychopy.visual as the first library (before anything that uses scipy) or use a differentmovie backend (e.g. moviepy).
Traceback (most recent call last):
  File "C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\MWE3.py", line 20, in <module>
    opacity=1, depth=-1.0)
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\contrib\lazy_import.py", line 120, in __call__
    return obj(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'noAudio'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\visual\window.py", line 472, in close_on_exit
    self.close()
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\visual\window.py", line 1124, in close
    self.backend.close()  # moved here, dereferencing the window prevents
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\visual\backends\pygletbackend.py", line 361, in close
    self.gammaRamp = self._origGammaRamp
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\tools\attributetools.py", line 32, in __set__
    newValue = self.func(obj, value)
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\visual\backends\pygletbackend.py", line 323, in gammaRamp
    xDisplay=self.xDisplay)
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\psychopy\visual\backends\gamma.py", line 91, in setGammaRamp
    assert success, 'SetDeviceGammaRamp failed'
AssertionError: SetDeviceGammaRamp failed

Any ideas of what could be causing this?

~Meg

It’s possible the gamma message is a side-effect of a previous problem.

The logs mention:

TypeError: __init__() got an unexpected keyword argument 'noAudio'

which suggests that there is an error in creating the MovieStim3.

Could you post the messages you get when you run the example code that you have above?

Also, try running it without creating a movie (just opening and closing the window), and see if the error still appears.

Ah, I must apologize for my sloppiness, I forgot to import visual.core and that seems to resolve the SetDeviceGamaRamp error. But I’m still getting strange errors. Now movie.py seems to be the source. See *fixed* code:

import psychopy
psychopy.useVersion('latest')

from psychopy import monitors, visual, core

expMonitor = monitors.Monitor('subjectMonitor')
SCREEN_SIZE = (3840,2160)

window2use = visual.Window(
    SCREEN_SIZE, fullscr=True, screen=1,
    monitor=expMonitor, color=[0,0,0], colorSpace='rgb')


movieFullPath = r'C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\videos\negative_female_05_05_05.mp4'

thisMovie = visual.MovieStim3(win=window2use, name='testmovie', 
                noAudio = False, filename = movieFullPath)

window2use.close()
core.quit()

Warnings and Stack:

##### Running: C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\MWE.py #####
1.3307     WARNING     User requested fullscreen with size [3840 2160], but screen is actually [2560, 1440]. Using actual size
3.5717     WARNING     Couldn't measure a consistent frame rate.
  - Is your graphics card set to sync to vertical blank?
  - Are you running other processes on your computer?

3.8324     WARNING     t of last frame was 27.49ms (=1/36)
3.8686     WARNING     t of last frame was 30.46ms (=1/32)
3.8994     WARNING     t of last frame was 24.98ms (=1/40)
3.9323     WARNING     t of last frame was 26.91ms (=1/37)
3.9662     WARNING     Multiple dropped frames have occurred - I'll stop bothering you about them!
5.4659     WARNING     Couldn't measure a consistent frame rate.
  - Is your graphics card set to sync to vertical blank?
  - Are you running other processes on your computer?

5.4659     WARNING     FrameRate could not be supplied by psychopy; defaulting to 60.0
5.7387     INFO     Loaded SoundDevice with PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4
5.7388     INFO     sound is using audioLib: sounddevice
7.1885     EXP     Created testmovie = MovieStim3(__class__=<class 'psychopy.visual.movie3.MovieStim3'>, autoLog=True, color=UNKNOWN, colorSpace=UNKNOWN, depth=0.0, filename=str(...), flipHoriz=False, flipVert=False, fps=UNKNOWN, interpolate=True, loop=False, name='testmovie', noAudio=False, opacity=1.0, ori=0.0, pos=array([0., 0.]), size=array([1600., 1000.]), units='pix', vframe_callback=UNKNOWN, volume=UNKNOWN, win=Window(...))
7.2368     EXP     window1: mouseVisible = True
Fatal Python error: PyImport_GetModuleDict: no module dictionary!

Current thread 0x00004634 (most recent call first):
  File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 116 in __del__

Removing the call to MovieStim3 appears to get rid of the error

Warnings:

##### Running: C:\Users\Megan\Documents\socEvalTask\socialEvaluationTask\psychopyPilot\MWE.py #####
1.3436     WARNING     User requested fullscreen with size [3840 2160], but screen is actually [2560, 1440]. Using actual size
3.6058     WARNING     Couldn't measure a consistent frame rate.
  - Is your graphics card set to sync to vertical blank?
  - Are you running other processes on your computer?

So the problem still seems localized to MovieStim3.

Is there something that should be printed/written other than the warnings shared in the previous post? These are only things that were printed are what is displayed in the Warnings and Stack Trace

P.S. Should I start a new thread at this point to make the error consistent with the thread title?

No, those are great. It was just that the error message referred to the code opacity=1, depth=-1.0) which wasn’t in the posted code example.

I haven’t used MovieStim3 before, so you might be better able to bring it to the attention of others that are familiar with it in a new thread.

Cool. I’ll restart this in a new thread shortly.

Thank you for taking a look at this.