本文整理汇总了Python中psychopy.core.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_instructions
def display_instructions():
set_msg('INTRODUCTION','TITLE')
set_msg('AXB control','MAIN')
set_msg('Press any key to continue','KEY')
win.flip()
core.wait(0.5)
event.waitKeys()
示例2: getResponse
def getResponse(self):
"""Calls `getThread()`, and then polls the thread until there's a response.
Will time-out if no response comes within `timeout` seconds. Returns an
object having the speech data in its namespace. If there's no match,
generally the values will be equivalent to `None` (e.g., an empty string).
If you do `resp = getResponse()`, you'll be able to access the data
in several ways:
`resp.word` :
the best match, i.e., the most probably word, or `None`
`resp.confidence` :
Google's confidence about `.word`, ranging 0 to 1
`resp.words` :
tuple of up to 5 guesses; so `.word` == `.words[0]`
`resp.raw` :
the raw response from Google (just a string)
`resp.json` :
a parsed version of raw, from `json.load(raw)`
"""
gsqthread = self.getThread()
while gsqthread.elapsed() < self.timeout:
# don't need precise timing to poll an http connection
core.wait(0.05, 0)
if not gsqthread.running:
break
if gsqthread.running: # timed out
gsqthread.status = 408 # same as http code
return gsqthread # word and time data are already in the namespace
示例3: testWait
def testWait(duration=1.55):
try:
t1=getTime()
wait(duration)
t2=getTime()
# Check that the actual duration of the wait was close to the requested delay.
#
# Note that I have had to set this to a relatively high value of
# 50 msec because on my Win7, i7, 16GB machine I would get delta's of up to
# 35 msec when I was testing this.
#
# This is 'way high', and I think is because the current wait()
# implementation polls pyglet for events during the CPUhog period.
# IMO, during the hog period, which should only need to be only 1 - 2 msec
# , not the 200 msec default now, nothing should be done but tight looping
# waiting for the wait() to expire. This is what I do in ioHub and on this same
# PC I get actual vs. requested duration delta's of < 100 usec consitently.
#
# I have not changed the wait in psychopy until feedback is given, as I
# may be missing a reason why the current wait() implementation is required.
#
assert np.fabs((t2-t1)-duration) < 0.05
printf(">> core.wait(%.2f) Test: PASSED"%(duration))
except Exception:
printf(">> core.wait(%.2f) Test: FAILED. Actual Duration was %.3f"%(duration,(t2-t1)))
printExceptionDetails()
printf("-------------------------------------\n")
示例4: waitEvents
def waitEvents(self, downOnly=True,
timeout=0, escape='escape', wait=0.002):
'''Wait for and return the first button press event.
Always calls `clearEvents()` first (like PsychoPy keyboard waitKeys).
Use `downOnly=False` to include button-release events.
`escape` is a list/tuple of keyboard events that, if pressed, will
interrupt the bbox wait; `waitKeys` will return `None` in that case.
`timeout` is the max time to wait in seconds before returning `None`.
`timeout` of 0 means no time-out (= default).
'''
self.clearEvents() # e.g., removes UP from previous DOWN
if timeout > 0:
c = core.Clock()
if escape and not type(escape) in [list, tuple]:
escape = [escape]
while True:
if wait:
core.wait(wait, 0) # throttle CPU; event RTs come from bbox
evt = self.getEvents(downOnly=downOnly)
if evt:
evt = evt[0]
break
if escape and event.getKeys(escape) or 0 < timeout < c.getTime():
return
return evt
示例5: playclip
def playclip(stimpath, stim):
fixation()
core.wait(0.3)
#pparallel.setData(0) # sets all pin lo
clip = visual.MovieStim(win=win,
name= 'clip',
filename= stimpath + stim,
size = [800, 450],
ori =0,
pos=[0,0],
opacity =1,
depth = -1.0
)
pparallel.setData(trigger_stim) # sets all pin lo
core.wait(0.005)
pparallel.setData(0)
stimOnset= trialClock.getTime()
while clip.status != visual.FINISHED:
clip.draw()
win.flip()
fixation()
# get key press at the end of clip
event.waitKeys(keyList=keyStop)
respTime= trialClock.getTime()
#mouse.clickReset()
#button, time = mouse.getPressed(getTime=True)
#print('mouse: ', button)
#event.waitKeys(keyList= button)
trials.addData('stimOnset', stimOnset)
trials.addData('respTime',respTime)
示例6: playback
def playback(self, block=True, loops=0, stop=False, log=True):
"""Plays the saved .wav file, as just recorded or resampled. Execution
blocks by default, but can return immediately with `block=False`.
`loops` : number of extra repetitions; 0 = play once
`stop` : True = immediately stop ongoing playback (if there is one), and return
"""
if not self.savedFile or not os.path.isfile(self.savedFile):
msg = "%s: Playback requested but no saved file" % self.loggingId
logging.error(msg)
raise ValueError(msg)
if stop:
if hasattr(self, "current_recording") and self.current_recording.status == PLAYING:
self.current_recording.stop()
return
# play this file:
name = self.name + ".current_recording"
self.current_recording = sound.Sound(self.savedFile, name=name, loops=loops)
self.current_recording.play()
if block:
core.wait(self.duration * (loops + 1)) # set during record()
if log and self.autoLog:
if loops:
logging.exp(
"%s: Playback: play %.3fs x %d (est) %s"
% (self.loggingId, self.duration, loops + 1, self.savedFile)
)
else:
logging.exp("%s: Playback: play %.3fs (est) %s" % (self.loggingId, self.duration, self.savedFile))
示例7: fScore
def fScore():
global score
roundscore = 0
wordsToScore = wordsTheyRecalled
wordList = './words/%s/words%s.txt' %(version, round-1)
throwAwayWords = list(cor for cor in open(wordList).read().split("\n") if cor)
for w in wordsToScore:
instructions2[2].draw()
core.wait(0.1)
if w in throwAwayWords:
risk = int(findBet(w))
throwAwayWords.remove(w)
score += risk
roundscore += risk
acc = 1
writeToDataFile(scorefileName,w,risk,score,acc)
print score
for w in throwAwayWords:
risk = int(findBet(w))
score -= risk
roundscore -= risk
acc = 0
writeToDataFile(scorefileName,w,risk,score, acc)
print score
return score,roundscore
示例8: general_trigger
def general_trigger(port, code):
if exp['use trigger']:
core.wait(0.05)
onflip_work(port, code=code)
stim['window'].flip()
core.wait(0.05)
clear_port(port)
示例9: test_write
def test_write(self):
win = visual.Window([600,400], units='height')
svg = exp.SVG(win, filename='stims')
circle = visual.Circle(win, pos=(-.5,0), fillColor='yellow', lineColor=None)
circle.draw()
svg.write(circle)
line = visual.Line(win, pos=(0,0), lineColor='black', lineWidth=5)
line.draw()
svg.write(line)
rect = visual.Rect(win, height=.8, pos=(.5,0))
rect.draw()
svg.write(rect)
shape = visual.ShapeStim(win, fillColor='blue', opacity=.5)
shape.draw()
svg.write(shape)
text = visual.TextStim(win, pos=(.5,0.25))
text.draw()
svg.write(text)
thick = exp.ThickShapeStim(win, vertices=[(-.5,.5),(.5,-.5)], lineWidth=.01)
thick.draw()
svg.write(thick)
win.flip()
#win.getMovieFrame()
#win.saveMovieFrames('stims.png')
#svg.save()
core.wait(5)
示例10: run
def run(self):
self.running = True
if self.skip:
for i in range(int(self.skip)):
if self.playSound: # pragma: no cover
self.sound1.play()
self.sound2.play()
# emulate T1 stabilization without data collection
core.wait(self.TR, hogCPUperiod=0)
self.clock.reset()
for vol in range(1, self.volumes + 1):
if self.playSound: # pragma: no cover
self.sound1.play()
self.sound2.play()
if self.stopflag:
break
# "emit" a sync pulse by placing a key in the buffer:
event._onPygletKey(symbol=self.sync, modifiers=0,
emulated=True)
# wait for start of next volume, doing our own hogCPU for
# tighter sync:
core.wait(self.timesleep - self.hogCPU, hogCPUperiod=0)
while self.clock.getTime() < vol * self.TR:
pass # hogs the CPU for tighter sync
self.running = False
return self
示例11: _record
def _record(self, sec, filename='', block=True):
while self.recorder.running:
pass
self.duration = float(sec)
self.onset = core.getTime() # for duration estimation, high precision
self.fileOnset = core.getAbsTime() # for log and filename, 1 sec precision
logging.data('%s: Record: onset %d, capture %.3fs' %
(self.loggingId, self.fileOnset, self.duration) )
if not file:
onsettime = '-%d' % self.fileOnset
self.savedFile = onsettime.join(os.path.splitext(self.wavOutFilename))
else:
self.savedFile = os.path.abspath(filename).strip('.wav') + '.wav'
t0 = core.getTime()
self.recorder.run(self.savedFile, self.duration, **self.options)
self.rate = sound.pyoSndServer.getSamplingRate()
if block:
core.wait(self.duration, 0)
logging.exp('%s: Record: stop. %.3f, capture %.3fs (est)' %
(self.loggingId, core.getTime(), core.getTime() - t0) )
while self.recorder.running:
core.wait(.001, 0)
else:
logging.exp('%s: Record: return immediately, no blocking' %
(self.loggingId) )
return self.savedFile
示例12: showForXSec
def showForXSec(self, text, sec):
"""
Show text for a given amount of seconds.
"""
self._display(text)
core.wait(sec)
示例13: run
def run(self):
self.repmom= 0
self.chradius=0.65/2.0
if self.block==0:
NT= 3; temp=[]
for n in range(NT): temp.append(np.ones(self.nrtrials/NT)*n)
self.trialType=np.concatenate(temp)
self.trialType=self.trialType[np.random.permutation(self.nrtrials)]
elif self.block==1:
self.trialType=np.zeros(self.nrtrials)
else:
self.trialType=np.ones(self.nrtrials)
self.chaser=HeatSeekingChaser(Q.nrframes,[18,18],(0,0),Q.pDirChange[1],Q.aSpeed,Q.phiRange[1],True)
self.chaser.vis=visual.Circle(self.wind,radius=self.chradius,fillColor='red',lineColor='red',interpolate=False)
self.pnt1=visual.Circle(self.wind,radius=self.chradius,fillColor='green',lineColor='green',interpolate=False)
#stuff=[visual.Line(self.wind,start=[-0.2,0],end=[0.2,0],units='deg'),visual.Line(self.wind,start=[0,-0.2],end=[0,0.2],units='deg')]
self.pnt2=visual.ShapeStim(self.wind,
vertices=[(-0.5,0),(-0,0),(0,0.5),(0,0),(0.5,0),(0,-0),(0,-0.5),(-0,0), (-0.5,0)],
closeShape=False,lineColor='white',interpolate=False)
self.mouse=visual.CustomMouse(self.wind, leftLimit=-9,rightLimit=9,showLimitBox=True,
topLimit=9,bottomLimit=-9,pointer=self.pnt2)
Experiment.run(self,prefix='')
self.text1.setText(u'Der Block ist nun zu Ende.')
self.text1.draw()
self.wind.flip()
core.wait(10)
self.output.close()
self.wind.close()
示例14: fixation_screen
def fixation_screen(myClock, waittime=1):
fixation.draw()
win.logOnFlip(level=logging.EXP, msg='fixation cross on screen') #new log haoting
win.flip()
fixStart = myClock.getTime() #fixation cross onset
core.wait(waittime)
return fixStart
示例15: triggerAndLog
def triggerAndLog( trigCode, id_str, major_inc, minor_inc, payload, trigDuration=10 ):
''' Parallel port code, LSL and test logging. '''
global paraport
global lsl_outlet_marker
global USE_LSL
global startTime
id_str = str(id_str)
major_inc = "{:02d}".format(major_inc)
minor_inc = "{:02d}".format(minor_inc)
payload = string.replace( payload, '\t', '_' )
outstr = '\t'.join([str((datetime.utcnow() - startTime).total_seconds()), str(trigCode), id_str, major_inc, minor_inc, payload])
# outstr = str( (datetime.utcnow() - startTime).total_seconds() ) + '\t' + str(trigCode) + '\t' + id_str + '\t' + major_inc + '\t' + minor_inc + '\t' + payload
# Write string to log and also send to LSL outlet
logThis(outstr)
if triggers:
windll.inpout32.Out32(paraport, trigCode)
core.wait( trigDuration/1000.0, hogCPUperiod = trigDuration/1000.0 ) # <-- add this for parallel triggering
windll.inpout32.Out32(paraport, portCodes['clear'] ) # <-- add this for parallel triggering
if USE_LSL:
lsl_outlet_marker.push_sample([trigCode])
开发者ID:bwrc,项目名称:WishGLD,代码行数:25,代码来源:WCST_faces_tasktypes_matchingstim_configfile_xpltfrm_andreas.py