def METHOD_NAME(experiment):
    if not py3:
        from json_tricks import utils
        utils.get_arg_names = _get_arg_names
    global _experiment, _old_gamma
    _experiment = experiment
    # Set the PsychoPy monitor, default to testMonitor
    monitor = experiment.var.get(u'psychopy_monitor', u'testMonitor')
    waitblanking = experiment.var.get(u'psychopy_waitblanking', u'yes',
                                      [u'yes', u'no']) == u'yes'
    screen = experiment.var.get(u'psychopy_screen', 0)
    # Print some information to the debug window
    oslogger.info(u'waitblanking = %s' % waitblanking)
    oslogger.info(u'monitor = %s' % monitor)
    oslogger.info(u'screen = %s' % screen)
    # Initialize the PsychoPy window and set various functions
    experiment.window = visual.Window(
        experiment.resolution(),
        screen=screen,
        waitBlanking=waitblanking,
        fullscr=experiment.var.fullscreen == u'yes',
        monitor=monitor,
        units=u'pix',
        color=Color(experiment, experiment.var.background).backend_color,
        winType=u'pyglet',
        allowStencil=True
    )
    event.Mouse(visible=False, win=experiment.window)
    experiment.window.winHandle.set_caption(
        u'OpenSesame (PsychoPy backend)')
    # Set Gamma value if specified
    gamma = experiment.var.get(u'psychopy_gamma', u'unchanged')
    if type(gamma) in (int, float) and gamma > 0:
        _old_gamma = experiment.window.gamma
        experiment.window.setGamma(gamma)
    elif gamma != u'unchanged':
        raise InvalidValue(
            u'Gamma should be a positive numeric value or "unchanged"')
    core.quit = _psychopy_clean_quit
    # Optionally change the logging level to avoid a lot of warnings in the
    # debug window
    if experiment.var.get(u'psychopy_suppress_warnings', u'yes'):
        logging.console.setLevel(logging.CRITICAL)