本文整理汇总了Python中psychopy.core.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:vincentadam87,项目名称:pitch_experiment,代码行数:7,代码来源:run_experimentAXB.py
示例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
开发者ID:jonathanoroberts,项目名称:psychopy,代码行数:30,代码来源:microphone.py
示例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")
开发者ID:bergwiesel,项目名称:psychopy,代码行数:31,代码来源:test_core.py
示例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
开发者ID:9173860,项目名称:psychopy,代码行数:29,代码来源:iolab.py
示例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)
开发者ID:claire-braboszcz,项目名称:Visemi,代码行数:33,代码来源:visemi.py
示例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))
开发者ID:rpbaxter,项目名称:psychopy,代码行数:33,代码来源:microphone.py
示例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
开发者ID:CMParlett,项目名称:Meta,代码行数:25,代码来源:mm.py
示例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)
开发者ID:mmagnuski,项目名称:exp_CircStim,代码行数:7,代码来源:gabcon.py
示例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)
开发者ID:Pulvinar,项目名称:psychopy_ext,代码行数:34,代码来源:test_svg.py
示例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
开发者ID:flipphillips,项目名称:psychopy,代码行数:26,代码来源:emulator.py
示例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
开发者ID:DiogoamCoutinho,项目名称:stimulus.py,代码行数:29,代码来源:microphone.py
示例12: showForXSec
def showForXSec(self, text, sec):
"""
Show text for a given amount of seconds.
"""
self._display(text)
core.wait(sec)
开发者ID:Beskhue,项目名称:SequenceRetentionExperiment,代码行数:7,代码来源:showText.py
示例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()
开发者ID:simkovic,项目名称:GazeContingentChaseBaby,代码行数:29,代码来源:Experiment.py
示例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
开发者ID:htwangtw,项目名称:mindwanderinglabYork,代码行数:7,代码来源:NART_TrialDisplay.py
示例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
示例16: record
def record(self, sec, file='', block=True):
"""Capture sound input for duration <sec>, save to a file.
Return the path/name to the new file. Uses onset time (epoch) as
a meaningful identifier for filename and log.
"""
while self.recorder.running:
pass
self.duration = float(sec)
self.onset = core.getTime() # note: report onset time in log, and use in filename
logging.data('%s: Record: onset %.3f, capture %.3fs' %
(self.loggingId, self.onset, self.duration) )
if not file:
onsettime = '-%.3f' % self.onset
self.savedFile = onsettime.join(os.path.splitext(self.wavOutFilename))
else:
self.savedFile = os.path.abspath(file).strip('.wav') + '.wav'
t0 = core.getTime()
self.recorder.run(self.savedFile, self.duration, self.sampletype)
self.rate = sound.pyoSndServer.getSamplingRate()
if block:
core.wait(self.duration - .0008) # .0008 fudge factor for better reporting
# actual timing is done by Clean_objects
logging.exp('%s: Record: stop. %.3f, capture %.3fs (est)' %
(self.loggingId, core.getTime(), core.getTime() - t0) )
else:
logging.exp('%s: Record: return immediately, no blocking' %
(self.loggingId) )
return self.savedFile
开发者ID:RainyJupiter,项目名称:psychopy,代码行数:32,代码来源:microphone.py
示例17: _record
def _record(self, sec, filename="", block=True, log=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
ms = "%.3f" % (core.getTime() - int(core.getTime()))
if log and self.autoLog:
logging.data("%s: Record: onset %d, capture %.3fs" % (self.loggingId, self.fileOnset, self.duration))
if not filename:
onsettime = "-%d" % self.fileOnset + ms[1:]
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)
if log and self.autoLog:
logging.exp(
"%s: Record: stop. %.3f, capture %.3fs (est)"
% (self.loggingId, core.getTime(), core.getTime() - t0)
)
while self.recorder.running:
core.wait(0.001, 0)
else:
if log and self.autoLog:
logging.exp("%s: Record: return immediately, no blocking" % (self.loggingId))
return self.savedFile
开发者ID:rpbaxter,项目名称:psychopy,代码行数:33,代码来源:microphone.py
示例18: test_Speech2Text
def test_Speech2Text(self):
pytest.skip() # google speech API gives Error 400: Bad request
try:
web.requireInternetAccess()
except web.NoInternetAccessError:
pytest.skip()
# load a known sound file
testFile = join(self.tmp, 'red_16000.wav')
gs = Speech2Text(filename=testFile)
resp = gs.getResponse()
assert resp.word == 'red'
# test batch-discover files in a directory
tmp = join(self.tmp, 'tmp')
os.mkdir(tmp)
shutil.copy(testFile, tmp)
bs = BatchSpeech2Text(files=tmp)
bs = BatchSpeech2Text(files=glob.glob(join(self.tmp, 'red_*.wav')))
while bs._activeCount():
core.wait(.1, 0)
resp = bs[0][1]
assert 0.6 < resp.confidence < 0.75 # 0.68801856
assert resp.word == 'red'
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:27,代码来源:test_microphone.py
示例19: pst
def pst(controller, outfile):
duration = pstSettings(controller)
if duration == -1:
print 'PST Cancelled'
return
display.text(controller.experWin, 'Running PST')
testWin = controller.testWin
display.countdown(controller)
display.fill_screen(testWin, [-1, -1, -1])
if not controller.testing:
controller.tobii_cont.setDataFile(outfile)
controller.tobii_cont.startTracking()
controller.tobii_cont.setEventsAndParams(['task','duration'])
controller.tobii_cont.setParam('task', 'pst')
controller.tobii_cont.setParam('duration', duration)
core.wait(duration)
if not controller.testing:
controller.tobii_cont.stopTracking()
controller.tobii_cont.closeDataFile()
开发者ID:greatproduct,项目名称:pupil,代码行数:26,代码来源:pst.py
示例20: tapping_exp
def tapping_exp(win, randid ,hand='r'):
if hand == 'l':
keylist = LH_TAPPING_KEYLIST
else:
keylist = RH_TAPPING_KEYLIST
#create some stimuli
circle = visual.ImageStim(win=win, image=circle_image_path, pos=SA_circle_pos)
#draw the stimuli and update the window
stim_times = []
for i in range(int(ST_repetition_times)):
#Escribimos el circulo
circle.draw()
#Enviamos la pantalla con el circulo
win.flip()
#Tomamos el tiempo en el que fue enviado
stim_times.append(core.getTime())
#Lo mostramos por "ST_duration_time" segundos
core.wait(ST_duration_time)
#Mandamos pantalla en blanco
win.flip()
#Mostramos pantalla en blanco por "ST_interval_time" segundos.
core.wait(ST_interval_time)
#Vemos cuando fueron apretadas las teclas
user_times = event.getKeys(keyList=keylist, timeStamped = True)
return stim_times, user_times
开发者ID:partu18,项目名称:INCC,代码行数:28,代码来源:experiments.py
注:本文中的psychopy.core.wait函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论