当前位置: 首页>>代码示例>>Python>>正文


Python visual.getMsPerFrame函数代码示例

本文整理汇总了Python中psychopy.visual.getMsPerFrame函数的典型用法代码示例。如果您正苦于以下问题:Python getMsPerFrame函数的具体用法?Python getMsPerFrame怎么用?Python getMsPerFrame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getMsPerFrame函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_refresh_rate

 def test_refresh_rate(self):
     if self.win.winType=='pygame':
         pytest.skip("getMsPerFrame seems to crash the testing of pygame")
     #make sure that we're successfully syncing to the frame rate
     msPFavg, msPFstd, msPFmed = visual.getMsPerFrame(self.win,nFrames=60, showVisual=True)
     assert (1000/150.0 < msPFavg < 1000/40.0), \
         "Your frame period is %.1fms which suggests you aren't syncing to the frame" %msPFavg
开发者ID:DiogoamCoutinho,项目名称:stimulus.py,代码行数:7,代码来源:test_all_stimuli.py

示例2: launch_window

def launch_window(params, test_refresh=True, test_tol=.5):
    """Open up a presentation window and measure the refresh rate."""
    # Get the monitor parameters
    m = WindowInfo(params)
    stated_refresh_hz = getattr(m, "refresh_hz", None)

    # Initialize the Psychopy window object
    win = visual.Window(**m.window_kwargs)

    # Record the refresh rate we are currently achieving
    if test_refresh or stated_refresh_hz is None:
        win.setRecordFrameIntervals(True)
        logging.console.setLevel(logging.CRITICAL)
        flip_time, _, _ = visual.getMsPerFrame(win)
        observed_refresh_hz = 1000 / flip_time

    # Possibly test the refresh rate against what we expect
    if test_refresh and stated_refresh_hz is not None:
        refresh_error = np.abs(stated_refresh_hz - observed_refresh_hz)
        if refresh_error > test_tol:
            msg = ("Observed refresh rate differs from expected by {:.3f} Hz"
                   .format(refresh_error))
            raise RuntimeError(msg)

    # Set the refresh rate to use in the experiment
    if stated_refresh_hz is None:
        msg = "Monitor configuration does not have refresh rate information"
        warnings.warn(msg)
        win.refresh_hz = observed_refresh_hz
    else:
        win.refresh_hz = stated_refresh_hz

    return win
开发者ID:mwaskom,项目名称:cregg,代码行数:33,代码来源:main.py

示例3: testRefreshRate

 def testRefreshRate(self):
     if self.win.winType == "pygame":
         raise nose.plugins.skip.SkipTest("getMsPerFrame seems to crash the testing of pygame")
     # make sure that we're successfully syncing to the frame rate
     msPFavg, msPFstd, msPFmed = visual.getMsPerFrame(self.win, nFrames=60, showVisual=True)
     nose.tools.ok_(
         1000 / 150.0 < msPFavg < 1000 / 40.0,
         "Your frame period is %.1fms which suggests you aren't syncing to the frame" % msPFavg,
     )
开发者ID:chrox,项目名称:psychopy,代码行数:9,代码来源:testMany.py

示例4: _setWindowInfo

    def _setWindowInfo(self, win, verbose=False, refreshTest='grating', usingTempWin=True):
        """find and store info about the window: refresh rate, configuration info
        """

        if refreshTest in ['grating', True]:
            msPFavg, msPFstd, msPFmd6 = visual.getMsPerFrame(win, nFrames=120,
                                                             showVisual=bool(refreshTest == 'grating'))
            self['windowRefreshTimeAvg_ms'] = msPFavg
            self['windowRefreshTimeMedian_ms'] = msPFmd6
            self['windowRefreshTimeSD_ms'] = msPFstd
        if usingTempWin:
            return

        # These 'configuration lists' control what attributes are reported.
        # All desired attributes/properties need a legal internal name, e.g., win.winType.
        # If an attr is callable, its gets called with no arguments, e.g., win.monitor.getWidth()
        winAttrList = ['winType', '_isFullScr', 'units', 'monitor', 'pos', 'screen', 'rgb', 'size']
        winAttrListVerbose = ['allowGUI', 'useNativeGamma', 'recordFrameIntervals',
                              'waitBlanking', '_haveShaders', '_refreshThreshold']
        if verbose: winAttrList += winAttrListVerbose

        monAttrList = ['name', 'getDistance', 'getWidth', 'currentCalibName']
        monAttrListVerbose = ['getGammaGrid','getLinearizeMethod','_gammaInterpolator', '_gammaInterpolator2']
        if verbose:
            monAttrList += monAttrListVerbose
        if 'monitor' in winAttrList:  # replace 'monitor' with all desired monitor.<attribute>
            i = winAttrList.index('monitor')  # retain list-position info, put monitor stuff there
            del winAttrList[i]
            for monAttr in monAttrList:
                winAttrList.insert(i, 'monitor.' + monAttr)
                i += 1
        for winAttr in winAttrList:
            try:
                attrValue = eval('win.' + winAttr)
            except AttributeError:
                logging.warning('AttributeError in RuntimeInfo._setWindowInfo(): Window instance has no attribute', winAttr)
                continue
            if hasattr(attrValue, '__call__'):
                try:
                    a = attrValue()
                    attrValue = a
                except:
                    print 'Warning: could not get a value from win.' + winAttr + '()  (expects arguments?)'
                    continue
            while winAttr[0] == '_':
                winAttr = winAttr[1:]
            winAttr = winAttr[0].capitalize() + winAttr[1:]
            winAttr = winAttr.replace('Monitor._', 'Monitor.')
            if winAttr in ['Pos', 'Size']:
                winAttr += '_pix'
            if winAttr in ['Monitor.getWidth', 'Monitor.getDistance']:
                winAttr += '_cm'
            if winAttr in ['RefreshThreshold']:
                winAttr += '_sec'
            self['window' + winAttr] = attrValue
开发者ID:alexholcombe,项目名称:psychopy,代码行数:55,代码来源:info.py

示例5: testRefreshRate

 def testRefreshRate(self):
     #make sure that we're successfully syncing to the frame rate
     msPFavg, msPFstd, msPFmed = visual.getMsPerFrame(self.win,nFrames=60, showVisual=True)
     nose.tools.ok_(1000/150.0 < msPFavg < 1000/40.0, "Your frame period is %.1fms which suggests you aren't syncing to the frame" %msPFavg)
开发者ID:richarddavis,项目名称:psychopy,代码行数:4,代码来源:testMany.py

示例6: runDiagnostics

    def runDiagnostics(self, win, verbose=False):
        """Return list of (key, val, msg) tuple, set self.warnings

        All tuple elements will be of <type str>.

        msg can depend on val; msg starts with 'Warning:' to indicate a concern.
        Plain text is returned, expected to be used in html <table>.
        Hyperlinks can be embedded as <a href="...">
        """

        report = []  # add item tuples in display order

        # get lots of info and do quick-to-render visual (want no frames drop):
        #     for me, grating draw times are: mean 0.53 ms, SD 0.77 ms
        items = info.RunTimeInfo(win=win, refreshTest='grating', verbose=True, userProcsDetailed=True)

        totalRAM, freeRAM = items['systemMemTotalRAM'], items['systemMemFreeRAM']
        if freeRAM == 'unknown':
            if totalRAM != 'unknown':
                totalRAM = "%.1fG" % (totalRAM / 1024.)
            msg = 'could not assess available physical RAM; total %s' % totalRAM
            report.append(('available memory', 'unknown', msg))
        else:
            msg = 'physical RAM available for configuration test (of %.1fG total)' % (totalRAM / 1024.)
            if freeRAM < 300:  # in M
                msg = 'Warning: low available physical RAM for configuration test (of %.1fG total)' % (totalRAM / 1024.)
            report.append(('available memory', str(freeRAM)+'M', msg))

        # ----- PSYCHOPY: -----
        report.append(('PsychoPy', '', ''))
        report.append(('psychopy', __version__, 'avoid upgrading during an experiment'))
        report.append(('locale', items['systemLocale'], 'can be set in <a href="http://www.psychopy.org/general/prefs.html#application-settings">Preferences -> App</a>'))
        msg = ''
        if items['pythonVersion'] < '2.5' or items['pythonVersion'] >= '3':
            msg = 'Warning: python 2.5, 2.6, or 2.7 required; 2.5 is iffy'
        if 'EPD' in items['pythonFullVersion']:
            msg += ' Enthought Python Distribution'
        elif 'PsychoPy2.app' in items['pythonExecutable']:
            msg += ' (PsychoPy StandAlone)'
        bits, linkage = platform.architecture()
        if not bits.startswith('32'):
            msg = 'Warning: 32-bit python required; ' + msg
        report.append(('python version', items['pythonVersion'] + ' &nbsp;(%s)' % bits, msg))
        if verbose:
            msg = ''
            if items['pythonWxVersion'] < '2.8.10':
                msg = 'Warning: wx 2.8.10 or higher required'
            report.append(('wx', items['pythonWxVersion'], ''))
            report.append(('pyglet', items['pythonPygletVersion'][:32], ''))
            report.append(('rush', str(items['psychopyHaveExtRush']), 'for high-priority threads'))

        # ----- VISUAL: -----
        report.append(('Visual', '', ''))
        # openGL settings:
        msg = ''
        if items['openGLVersion'] < '2.':
            msg = 'Warning: <a href="http://www.psychopy.org/general/timing/reducingFrameDrops.html?highlight=OpenGL+2.0">OpenGL 2.0 or higher is ideal</a>.'
        report.append(('openGL version', items['openGLVersion'], msg))
        report.append(('openGL vendor', items['openGLVendor'], ''))
        report.append(('screen size', ' x '.join(map(str, items['windowSize_pix'])), ''))
        #report.append(('wait blanking', str(items['windowWaitBlanking']), ''))

        msg = ''
        if not items['windowHaveShaders']:
            msg = 'Warning: <a href="http://www.psychopy.org/general/timing/reducingFrameDrops.html?highlight=shader">Rendering of complex stimuli will be slow</a>.'
        report.append(('have shaders', str(items['windowHaveShaders']), msg))

        msg = 'during the drifting <a href="http://www.psychopy.org/api/visual/gratingstim.html">GratingStim</a>'
        if items['windowRefreshTimeMedian_ms'] < 3.3333333:
            msg = """Warning: too fast? visual sync'ing with the monitor seems unlikely at 300+ Hz"""
        report.append(('visual sync (refresh)', "%.2f ms/frame" % items['windowRefreshTimeMedian_ms'], msg))
        msg = 'SD < 0.5 ms is ideal (want low variability)'
        if items['windowRefreshTimeSD_ms'] > .5:
            msg = 'Warning: the refresh rate has high frame-to-frame variability (SD > 0.5 ms)'
        report.append(('refresh stability (SD)', "%.2f ms" % items['windowRefreshTimeSD_ms'], msg))

        # draw 100 dots as a minimally demanding visual test:
        # first get baseline frame-rate (safe as possible, no drawing):
        avg, sd, median = visual.getMsPerFrame(win)
        dots100 = visual.DotStim(win, nDots=100, speed=0.005, dotLife=12, dir=90,
            coherence=0.2, dotSize=8, fieldShape='circle')
        win.setRecordFrameIntervals(True)
        win.frameIntervals = []
        win.flip()
        for i in xrange(180):
            dots100.draw()
            win.flip()
        msg = 'during <a href="http://www.psychopy.org/api/visual/dotstim.html">DotStim</a> with 100 random dots'
        intervalsMS = np.array(win.frameIntervals) * 1000
        nTotal = len(intervalsMS)
        nDropped = sum(intervalsMS > (1.5 * median))
        if nDropped:
            msg = 'Warning: could not keep up during <a href="http://www.psychopy.org/api/visual/dotstim.html">DotStim</a> with 100 random dots.'
        report.append(('no dropped frames', '%i / %i' % (nDropped, nTotal), msg))
        win.setRecordFrameIntervals(False)
        try:
            from pyglet.media import avbin
            ver = avbin.get_version()
            if ver < 5 or ver >= 6:
                msg = 'Warning: version 5 recommended (for movies); Visit <a href="http://code.google.com/p/avbin">download page</a> [google.com]'
#.........这里部分代码省略.........
开发者ID:9173860,项目名称:psychopy,代码行数:101,代码来源:wizard.py

示例7: runDiagnostics


#.........这里部分代码省略.........
        msg = ''
        if not items['windowHaveShaders']:
            msg = _translate(
                'Warning: <a href="http://www.psychopy.org/general/timing'
                '/reducingFrameDrops.html?highlight=shader">Rendering of'
                ' complex stimuli will be slow</a>.')
            warn = True
        report.append(('have shaders', str(
            items['windowHaveShaders']), msg, warn))

        warn = False
        msg = _translate(
            'during the drifting <a href="http://www.psychopy.org/api/'
            'visual/gratingstim.html">GratingStim</a>')
        if items['windowRefreshTimeMedian_ms'] < 3.3333333:
            msg = _translate(
                "Warning: too fast? visual sync'ing with the monitor"
                " seems unlikely at 300+ Hz")
            warn = True
        report.append(('visual sync (refresh)', "%.2f ms/frame" %
                       items['windowRefreshTimeMedian_ms'], msg, warn))
        msg = _translate('SD &lt; 0.5 ms is ideal (want low variability)')
        warn = False
        if items['windowRefreshTimeSD_ms'] > .5:
            msg = _translate(
                'Warning: the refresh rate has high frame-to-frame '
                'variability (SD &gt; 0.5 ms)')
            warn = True
        report.append(('refresh stability (SD)', "%.2f ms" %
                       items['windowRefreshTimeSD_ms'], msg, warn))

        # draw 100 dots as a minimally demanding visual test:
        # first get baseline frame-rate (safe as possible, no drawing):
        avg, sd, median = visual.getMsPerFrame(win)
        dots100 = visual.DotStim(
            win, nDots=100, speed=0.005, dotLife=12, dir=90,
            coherence=0.2, dotSize=8, fieldShape='circle', autoLog=False)
        win.recordFrameIntervals = True
        win.frameIntervals = []
        win.flip()
        for i in range(180):
            dots100.draw()
            win.flip()
        msg = _translate(
            'during <a href="http://www.psychopy.org/api/visual/'
            'dotstim.html">DotStim</a> with 100 random dots')
        warn = False
        intervalsMS = np.array(win.frameIntervals) * 1000
        nTotal = len(intervalsMS)
        nDropped = sum(intervalsMS > (1.5 * median))
        if nDropped:
            msg = _translate(
                'Warning: could not keep up during <a href="http://'
                'www.psychopy.org/api/visual/dotstim.html">DotStim</a>'
                ' with 100 random dots.')
            warn = True
        report.append(('no dropped frames', '%i / %i' % (nDropped, nTotal),
                       msg, warn))
        win.recordFrameIntervals = False

        if verbose:
            report.append(('openGL max vertices',
                           str(items['openGLmaxVerticesInVertexArray']),
                           '', False))
            keyList = ('GL_ARB_multitexture', 'GL_EXT_framebuffer_object',
                       'GL_ARB_fragment_program', 'GL_ARB_shader_objects',
开发者ID:dgfitch,项目名称:psychopy,代码行数:67,代码来源:wizard.py

示例8: runDiagnostics


#.........这里部分代码省略.........
            )
            warn = True
        report.append(("openGL version", items["openGLVersion"], msg, warn))
        report.append(("openGL vendor", items["openGLVendor"], "", False))
        report.append(("screen size", " x ".join(map(str, items["windowSize_pix"])), "", False))
        # report.append(('wait blanking', str(items['windowWaitBlanking']), '', False))

        warn = False
        msg = ""
        if not items["windowHaveShaders"]:
            msg = _translate(
                'Warning: <a href="http://www.psychopy.org/general/timing/reducingFrameDrops.html?highlight=shader">Rendering of complex stimuli will be slow</a>.'
            )
            warn = True
        report.append(("have shaders", str(items["windowHaveShaders"]), msg, warn))

        warn = False
        msg = _translate(
            'during the drifting <a href="http://www.psychopy.org/api/visual/gratingstim.html">GratingStim</a>'
        )
        if items["windowRefreshTimeMedian_ms"] < 3.3333333:
            msg = _translate("""Warning: too fast? visual sync'ing with the monitor seems unlikely at 300+ Hz""")
            warn = True
        report.append(("visual sync (refresh)", "%.2f ms/frame" % items["windowRefreshTimeMedian_ms"], msg, warn))
        msg = _translate("SD < 0.5 ms is ideal (want low variability)")
        warn = False
        if items["windowRefreshTimeSD_ms"] > 0.5:
            msg = _translate("Warning: the refresh rate has high frame-to-frame variability (SD > 0.5 ms)")
            warn = True
        report.append(("refresh stability (SD)", "%.2f ms" % items["windowRefreshTimeSD_ms"], msg, warn))

        # draw 100 dots as a minimally demanding visual test:
        # first get baseline frame-rate (safe as possible, no drawing):
        avg, sd, median = visual.getMsPerFrame(win)
        dots100 = visual.DotStim(
            win,
            nDots=100,
            speed=0.005,
            dotLife=12,
            dir=90,
            coherence=0.2,
            dotSize=8,
            fieldShape="circle",
            autoLog=False,
        )
        win.recordFrameIntervals = True
        win.frameIntervals = []
        win.flip()
        for i in xrange(180):
            dots100.draw()
            win.flip()
        msg = _translate(
            'during <a href="http://www.psychopy.org/api/visual/dotstim.html">DotStim</a> with 100 random dots'
        )
        warn = False
        intervalsMS = np.array(win.frameIntervals) * 1000
        nTotal = len(intervalsMS)
        nDropped = sum(intervalsMS > (1.5 * median))
        if nDropped:
            msg = _translate(
                'Warning: could not keep up during <a href="http://www.psychopy.org/api/visual/dotstim.html">DotStim</a> with 100 random dots.'
            )
            warn = True
        report.append(("no dropped frames", "%i / %i" % (nDropped, nTotal), msg, warn))
        win.recordFrameIntervals = False
开发者ID:kammf,项目名称:psychopy,代码行数:66,代码来源:wizard.py

示例9: __init__

    def __init__(self, fixation_duration, max_dot_duration, min_iti_duration, break_duration):
        '''
        RDMD task
        hemifield = hemifield to show dot stim in (right or left)
        fixation_duration = duration of fixation (ms)
        max_dot_duration = max duration of dot stimuli (ms)
        min_iti_duration = min inter-trial-interval (ms)
        break_duration = duration of break (ms)
        '''
        #create window and stimuli
        # Window to use
        self.wintype='pyglet' # use pyglet if possible, it's faster at event handling
        self.win = visual.Window(
            [1280,1024],
            monitor=MONITOR,
            screen=SCREEN,
            units="deg",
            fullscr=True,
            color=[-1,-1,-1],
            winType=self.wintype)
        self.win.setMouseVisible(False)
        event.clearEvents()

        # Measure frame rate
        self.mean_ms_per_frame, std_ms_per_frame, median_ms_per_frame=visual.getMsPerFrame(self.win, nFrames=60,
            showVisual=True)

        # Compute number of frames for fixation
        self.fixation_duration=fixation_duration
        self.fixation_frames=int(fixation_duration/self.mean_ms_per_frame)

        # Compute max number of frames for dot stimuli
        self.max_dot_duration=max_dot_duration
        self.max_dot_frames=int(max_dot_duration/self.mean_ms_per_frame)

        # Compute minimum inter-trial-interval frames (will be adjusted based on time of other stimuli)
        self.min_iti_duration=min_iti_duration
        self.min_iti_frames=int(min_iti_duration/self.mean_ms_per_frame)

        self.break_duration=break_duration
        self.break_duration_frames=int(break_duration/self.mean_ms_per_frame)

        # fixation stimulus
        self.fixation = visual.PatchStim(
            self.win,
            units='deg',
            tex=None,
            mask='circle',
            sf=0,
            size=0.5,
            name='fixation',
            autoLog=False,
            color=[1,1,1]
        )

        # dot stimulus
        self.dots = visual.DotStim(
            win=self.win,
            name='dots',
            nDots=200, # number of dots
            dotSize=2, # dot size in degrees
            speed=0.4, # 60Hz refresh - 16.7ms/frame, 4deg/s=.0668deg/frame
            dir=0.0, # 0=right, 180=left
            coherence=12.5, # percentage of dots moving in the same direction
            fieldPos=[0.0, 0.0], # centered on the screen
            fieldSize=10.0, # field is 10 deg wide
            fieldShape='circle', # circle shaped field
            signalDots='different', # are the signal and noise dots 'different' or 'same' popns (see Scase et al)
            noiseDots='direction', # do the noise dots follow random- 'walk', 'direction', or 'position'
            dotLife=3, # number of frames for each dot to be drawn
            color=[1.0,1.0,1.0], # white dots
            colorSpace='rgb',
            opacity=1, # fully opaque
            depth=-1.0
        )

        self.training_message = visual.TextStim(self.win, wrapWidth=30, pos=[0,3])

        # Clock for computing response time
        self.rt_clock = core.Clock()
开发者ID:jbonaiuto,项目名称:rdmd,代码行数:80,代码来源:task.py

示例10: __init__

    def __init__(self, exp_info, file_name):
        """
        Initialize experiment - read XML file, setup window, connect to netstation and tobii
        exp_info - experiment information
        file_name - name of XML file containing experiment definition
        """
        self.exp_info = exp_info
        self.name = None
        self.type = None
        self.num_blocks = 0
        self.blocks = {}
        self.block_order = []

        # Window to use
        wintype = 'pyglet'  # use pyglet if possible, it's faster at event handling
        # Add 14cm to distance - this is distance from eyetracker to monitor
        mon = monitors.Monitor(exp_info['monitor'], distance=float(exp_info['monitor distance']))
        self.win = Window(
            [1280, 1024],
            monitor=mon,
            screen=SCREEN,
            units="deg",
            fullscr=True,
            #fullscr=False,
            color=[-1, -1, -1],
            winType=wintype)
        self.win.setMouseVisible(False)
        event.clearEvents()

        # Measure frame rate
        self.mean_ms_per_frame, std_ms_per_frame, median_ms_per_frame = visual.getMsPerFrame(self.win, nFrames=60,
                                                                                             showVisual=True)

        self.debug_sq=None
        if exp_info['monitor']=='tobii':
            self.debug_sq=psychopy.visual.Rect(self.win, width=30, height=30, units='pix')
            self.debug_sq.setFillColor((1,1,1))
            self.debug_sq.setPos((630,-500))

        # Compute distractor duration in frames based on frame rate
        distractor_duration_frames = int(2000.0/self.mean_ms_per_frame)

        # Initialize set of distractors
        self.distractor_set = DistractorSet(os.path.join(DATA_DIR, 'images', 'distractors', 'space'),
                                            os.path.join(DATA_DIR, 'sounds', 'distractors'),
                                            os.path.join(DATA_DIR, 'movies', 'distractors'),
                                            os.path.join(DATA_DIR, 'images', 'distractors', 'star-cartoon.jpg'),
                                            distractor_duration_frames, self.win)

        # Connect to nestation
        self.ns = None
        if exp_info['eeg']:
            # connect to netstation
            self.ns = egi.Netstation()
            ms_localtime = egi.ms_localtime

        self.eye_tracker = None
        mouse_visible = False
        if exp_info['eyetracking source'] == 'tobii':
            # Initialize eyetracker
            self.eye_tracker = TobiiController(self.win)
            self.eye_tracker.waitForFindEyeTracker()
            self.eye_tracker.activate(EYETRACKER_NAME)
        elif exp_info['eyetracking source'] == 'mouse':
            mouse_visible = True

        # Initialize mouse
        self.mouse = event.Mouse(visible=mouse_visible, win=self.win)

        self.gaze_debug=None
        if self.exp_info['debug mode']:
            self.gaze_debug=psychopy.visual.Circle(self.win, radius=1, fillColor=(1.0,-1.0,-1.0))

        self.read_xml(file_name)

        # Initialize netstation and eyetracker
        self.initialize()
开发者ID:jbonaiuto,项目名称:infant_eeg,代码行数:77,代码来源:experiment.py


注:本文中的psychopy.visual.getMsPerFrame函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。