本文整理汇总了Python中psychopy.core.quit函数的典型用法代码示例。如果您正苦于以下问题:Python quit函数的具体用法?Python quit怎么用?Python quit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setScale
def setScale(self, units, font='dummyFont', prevScale=[1.0,1.0]):
"""This method is called from within the draw routine and sets the
scale of the OpenGL context to map between units. Could potentially be
called by the user in order to draw OpenGl objects manually
in each frame.
The **units** can be 'norm'(normalised),'pix'(pixels),'cm' or
'stroke_font'. The **font** argument is only used if units='stroke_font'
"""
if units is "norm":
thisScale = scipy.array([1.0,1.0])
elif units in ["pix", "pixels"]:
thisScale = 2.0/scipy.array(self.size)
elif units is "cm":
#windowPerCM = windowPerPIX / CMperPIX
# = (window /winPIX) / (scrCm /scrPIX)
if (self.scrWidthCM in [0,None]) or (self.scrWidthPIX in [0, None]):
print 'you didnt give me the width of the screen (pixels and cm)'
core.wait(1.0); core.quit()
thisScale = (scipy.array([2.0,2.0])/self.size)/(float(self.scrWidthCM)/float(self.scrWidthPIX))
elif units in ["deg", "degs"]:
#windowPerDeg = winPerCM*CMperDEG
# = winPerCM * tan(scipy.pi/180) * distance
if (self.scrWidthCM in [0,None]) or (self.scrWidthPIX in [0, None]):
print 'you didnt give me the width of the screen (pixels and cm)'
core.wait(1.0); core.quit()
cmScale = (scipy.array([2.0,2.0])/self.size)/(float(self.scrWidthCM)/float(self.scrWidthPIX))
thisScale = cmScale * 0.017455 * self.scrDistCM
elif units is "stroke_font":
thisScale = scipy.array([2*font.letterWidth,2*font.letterWidth]/self.size/38.0)
#actually set the scale as appropriate
thisScale = thisScale/scipy.asarray(prevScale)#allows undoing of a previous scaling procedure
print 'scale %f %f' %(thisScale[0], thisScale[1])
GL.glScalef(float(thisScale[0]), float(thisScale[1]), 1.0)
return thisScale #just in case the user wants to know?!
开发者ID:RSharman,项目名称:psychopy,代码行数:35,代码来源:openGLTestbed3.py
示例2: start_datafile
def start_datafile(sn):
"""creates datafile (after checking for old one)"""
# determines file name
if sn < 10:
snstr = '0' + str(sn)
else:
snstr = str(sn)
datafileName = "experiment_" + snstr + ".csv"
currentDirectory = os.listdir("." + os.sep + "Data")
for file in currentDirectory:
if file == datafileName:
warningDialog = gui.Dlg(title="Warning!")
warningDialog.addText("A data file with this number already exists.")
warningDialog.addField("Overwrite?", choices=["No", "Yes"])
warningDialog.addField("If not, enter new subject number:",
initial="0")
warningDialog.show()
if gui.OK:
if warningDialog.data[0] == "No":
subjectNumber = int(warningDialog.data[1])
if subjectNumber < 10:
snstr = '0' + str(subjectNumber)
else:
sntstr = str(subjectNumber)
datafileName = "experiment_" + snstr + ".csv"
else:
core.quit()
datafile = open("." + os.sep + "Data" + os.sep + datafileName,
"ab")
datafile.write("subjectnum,runnum,trialnum,trialbegintime,trialduration,trialjitterduration,\
response,responsetime,person,personnum, prefitem, prefnum\n")
return(datafile, sn)
开发者ID:ryanbsong,项目名称:Social-Psych-Research,代码行数:32,代码来源:experiment1.py
示例3: __init__
def __init__(self, settings=None):
super(Pursuit, self).__init__()
self.global_clock = mono_clock
# set up input
if settings['mouse']:
self.device = Mouse(clock=self.global_clock.getTime)
else:
core.quit()
#self.device = ForceHandle(clock=self.global_clock.getTime)
try:
#self.trial_table = pd.read_csv(settings['trial_table'])
pass
except FileNotFoundError:
core.quit()
# set up display
self.win = visual.Window(size=(800, 800),
pos=(0, 0),
fullscr=settings['fullscreen'],
screen=1,
units='height',
allowGUI=False,
colorSpace='rgb',
color=(-1, -1, -1),
waitBlanking=False)
self.win.recordFrameIntervals = True
self.setup_visuals()
# extras
self.data = None
self.total_frames = 0
self.frames_on_target = 0
开发者ID:aforren1,项目名称:isotrack,代码行数:34,代码来源:pursuit_imp.py
示例4: get_subject_info
def get_subject_info(experiment_name, conditions, data_location):
ss_info = []
pc = socket.gethostname()
my_Dlg = gui.Dlg(title=experiment_name)
my_Dlg.addText('Subject Info')
my_Dlg.addField('ID:', tip='or subject code')
my_Dlg.addField('Condition:', rnd.choice(conditions), choices = conditions)
my_Dlg.show()
if not my_Dlg.OK:
print 'User Terminated'
core.quit()
subject_info = [str(i) for i in my_Dlg.data]
if subject_info[0]=='':
core.quit()
else:
id = subject_info[0]
condition = subject_info[1]
subject_file = (data_location + pc + '-' + experiment_name + '-' +
condition + '-' + id + '.csv')
while os.path.exists(subject_file) == True:
subject_file = (data_location + pc + '-' + experiment_name + '-' +
condition + '-' + id + '.csv' + '_dupe')
return [int(id),int(condition),subject_file]
开发者ID:ghonk,项目名称:switchrite,代码行数:25,代码来源:misc.py
示例5: wait_get_response
def wait_get_response(p, clock, oddball, wait_time):
"""Get response info specific to this experiment."""
check_clock = core.Clock()
good_resp = False
corr, response, resp_rt = 0, 0, -1
while not good_resp:
keys = event.getKeys(timeStamped=clock)
for key, stamp in keys:
if key in p.quit_keys:
print "Subject quit execution"
core.quit()
elif key in p.match_keys:
corr = 0 if oddball else 1
response = 1
resp_rt = stamp
good_resp = True
break
elif key in p.nonmatch_keys:
corr = 1 if oddball else 0
response = 2
resp_rt = stamp
good_resp = True
break
event.clearEvents()
# Possibly exit with nothing
if check_clock.getTime() >= wait_time:
return corr, response, resp_rt
# Wait the rest of the time
core.wait(wait_time - resp_rt)
return corr, response, resp_rt
开发者ID:mwaskom,项目名称:GAPE_Experiment,代码行数:30,代码来源:gape.py
示例6: ask
def ask(text='', keyList=[]):
"""
Ask subject something. Shows question and returns answer (keypress)
and reaction time. Defaults to no text and all keys.
"""
# Draw the TextStims to visual buffer, then show it and reset timing immediately (at stimulus onset)
stimText.setText(codecs.decode(text,"utf-8"))
spaceText.setText(codecs.decode(spaceLookup[language],"utf-8"))
# Set the text height
stimText.setHeight(1)
spaceText.setHeight(1)
# set the text color
stimText.setColor('white')
spaceText.setColor('white')
stimText.draw()
spaceText.draw()
win.flip()
event.clearEvents('keyboard')
# Halt everything and wait for (first) responses matching the keys given in the Q object.
response = event.waitKeys(keyList=['space','q','r'])
if response[0] in keysQuit: # Look at first reponse [0]. Quit everything if quit-key was pressed
core.quit()
if response[0] in keysBreak:
event.clearEvents('keyboard')
win.flip()
if event.getKeys(keyList=['escape', 'q']):
core.quit()
if event.getKeys(keyList=['s']):
print "Skipped experiment"
quit()
return response # When answer given, return it.
开发者ID:MaisonLogicielLibre,项目名称:CogSciProject-master,代码行数:32,代码来源:welcomescript.py
示例7: cleanup
def cleanup():
'''
cleanup function to be called if a KeyboardInterrupt is raised
'''
print "control C was pressed. aborting script and cleaning up monitors."
core.quit()
sys.exit(10)
开发者ID:lukereding,项目名称:displaying_videos,代码行数:7,代码来源:screen.py
示例8: runRT
def runRT(window,ask,test,language,preferred_hand,exp):
try:
while True:
ask(lookup[test][language][preferred_hand])
response = ask(practiceLookup[language])
if event.getKeys(keyList=['escape', 'q']):
core.quit()
if 'r' in response:
print 'r pressed'
continue
if 'space' in response:
break
if event.getKeys(keyList=['s']):
print "Skipped experiment"
return
getReady = lookupGetReady[language]
error = lookupError[language]
wrongkey = lookupwrongKey[language]
score=1
while score != 0:
score = run(window,clock, ask, error,getReady,wrongkey,language, exp,practice=True)
print score
#Run experiment
run(window,clock, ask, error,getReady,wrongkey,language,exp)
except KeyboardInterrupt:
raise
core.quit()
开发者ID:MaisonLogicielLibre,项目名称:CogSciProject-master,代码行数:29,代码来源:RT_experiment.py
示例9: text_and_stim_keypress
def text_and_stim_keypress(self, text, stim=None):
if stim is not None:
if type(stim) == list:
map(lambda x: x.draw(), stim)
else:
stim.draw()
display_text = visual.TextStim(self.win, text=text,
font='Helvetica', alignHoriz='center',
alignVert='center', units='norm',
pos=(0, 0), height=0.1,
color=[255, 255, 255], colorSpace='rgb255',
wrapWidth=2)
display_text.draw()
self.win.flip()
key = event.waitKeys()
if key[0] == 'escape':
self.trigger.flicker_block(0)
# Save end data
t = datetime.now()
day_time = '%d:%d:%d:%d' % (t.hour, t.minute, t.second, t.microsecond)
end_time = globalTimer.getTime()
save_data(day_time, end_time, self.subjnum)
core.quit()
self.win.flip()
self.win.flip()
开发者ID:pearsonlab,项目名称:ToM_task_2010,代码行数:27,代码来源:task_2010.py
示例10: WaitForKeyInput
def WaitForKeyInput():
text='...'
#until return pressed, listen for letter keys & add to text string
while event.getKeys(keyList=['return'])==[]:
letterlist=event.getKeys(keyList=['0', '1', '2', '3', '4', '5' , '6', '7', '8', '9','backspace','q'])
for l in letterlist:
if l == 'q':
core.quit()
#if key isn't backspace, add key pressed to the string
if l !='backspace':
if text =="...":
text=l
pressedkeys=l
else:
text+=l
pressedkeys+=(";" + l)
#otherwise, take the last letter off the string
elif len(text)>0:
text=text[:-1]
pressedkeys+=(";backspace")
#continually redraw text onscreen until return pressed
text = unicode(text)
print "UNICODE"
print text
response = visual.TextStim(mywin, height=36,text=text,color="white",pos=(0,-100))
betAsk.draw()
response.draw()
mywin.flip()
core.wait(0.1)
RT = trialClock.getTime()
event.clearEvents()
return text,RT
开发者ID:WMPLab,项目名称:MetaMemory,代码行数:32,代码来源:metamemory.py
示例11: cleanup
def cleanup(self):
""" Destructor """
#STOP CLOCKS
self.window.setRecordFrameIntervals(False) #stop recording frame intervals
self.stoptime = time.clock() #TIME SENSITIVE STUFF ENDS HERE
#FLIP FOR SYNC SQUARE CLEAR
for i in range(30):
self.window.flip()
timestr = str(datetime.timedelta(seconds = (self.stoptime-self.starttime)))
print "Actual experiment duration:", timestr
self.stopdatetime = datetime.datetime.now()
#DISPLAY SOME STUFF
print "Actual sweeps completed:", str(self.sweepsdisplayed)
self.printFrameInfo()
#LOG INFORMATION (If not in replay mode)
if not self.replay: self.logMeta()
#CLOSE EVERYTHING
if self.ni:
self.dOut.WriteBit(self.sweepBit, 0) #ensure sweep bit is low
self.dOut.WriteBit(self.frameBit, 0) #ensure frame bit is low
self.dOut.ClearTask() #clear NIDAQ
self.window.close()
core.quit()
开发者ID:neuromind81,项目名称:aibs,代码行数:25,代码来源:SweepStim.py
示例12: wait_check_pause_quit
def wait_check_pause_quit(win, wait_time, quit_keys=["q", "escape"],
pause_keys=["space"], check_every=1):
"""Wait while checking for pause or quit input."""
raise NotImplementedError("This isn't quite finished yet")
checks = int(floor(wait_time / check_every))
for _ in range(checks):
core.wait(check_every)
if event.getKeys(keyList=quit_keys):
print "Subject quit execution"
core.quit()
if event.getKeys(keyList=pause_keys):
pause_start = time.time()
visual.TextStim(win, text="Experiment paused").draw()
win.flip()
paused = True
while paused:
if event.getKeys(keyList=pause_keys):
paused = False
core.sleep(check_every)
pause_end = time.time()
pause_duration = pause_end - pause_start
remaining = wait_time - checks * check_every
if remaining:
core.wait(remaining)
return pause_duration
开发者ID:mwaskom,项目名称:cregg,代码行数:31,代码来源:main.py
示例13: trial
def trial(city_left, city_right):
"""
City-size paired comparison task
"""
leftTS.text = city_left
rightTS.text = city_right
questionTS.draw()
fixpoint.draw()
leftTS.draw()
rightTS.draw()
win.flip()
timer.reset()
response = None
while response not in [city_left, city_right]:
pressed_key = event.waitKeys(timeStamped=timer)
if pressed_key[0][0] in ['q', 'escape']:
core.quit()
if pressed_key[0][0] == 'less':
response = city_left
if pressed_key[0][0] == 'minus':
response = city_right
questionTS.draw()
fixpoint.draw()
win.flip()
core.wait(0.4)
## Save data
datfile.write('%s;%s;%s;%1.4f\n' %
(city_left, city_right, response, pressed_key[0][1]))
开发者ID:Trybnetic,项目名称:recognition,代码行数:32,代码来源:runexp.py
示例14: setCup
def setCup(pp):
global button
global cupBuffer
sN = pp
rtClock = core.Clock()
while True:
key = event.getKeys(keyList = ['q','escape'])
if len(key) > 0:
core.quit()
mX, mY = mouse.getPos()
if mX > buttonX[0] and mX < buttonX[1] and mY > buttonY[0] and mY < buttonY[1]: #Checks to see if "Next" button was pressed
set_mouse_position(win,0,0)
break
if mY < (slotY-(slotHeight/2)) and mY > -(screenY*.2):
sN1 = getSlot(mX,mY,slotSpread)
if sN1 !=None:
sN = sN1
if sN == 0:
sN = 1
elif sN == 40:
sN = 39
plinkoTable.draw()
button.draw()
buttonText.draw()
ball.draw()
drawCup(slotPos[sN][0])
drawPbar(totalPoints,maxScore)
win.flip()
rt = rtClock.getTime()
plinkoTable.draw()
drawCup(slotPos[sN][0])
drawPbar(totalPoints,maxScore)
cupBuffer = visual.BufferImageStim(win)
return sN,rt
开发者ID:alsfilip,项目名称:PlinkoBored,代码行数:34,代码来源:plinkoBored.py
示例15: run_calibration
def run_calibration():
# display instructions
set_msg('SET SOUND LEVEL','TITLE')
set_msg('press up and down to increase/decrease sound level and press enter when level is confortable','MAIN')
set_msg('Press return to continue','KEY')
win.flip()
# prepare calibration sound
s = sound_build.make_lp_noise(100000,3000,Exp.rate)
vol = 0.5
playsound(s,vol,200)
pressEnter = False
while pressEnter==False:
allKeys=event.waitKeys()
for thisKey in allKeys:
if thisKey=='up':
pygame.mixer.music.set_volume(pygame.mixer.music.get_volume()+0.03)
print(pygame.mixer.music.get_volume())
elif thisKey=='down':
pygame.mixer.music.set_volume(pygame.mixer.music.get_volume()-0.03)
print(pygame.mixer.music.get_volume())
elif thisKey in ['return']:
pressEnter = True
elif thisKey in ['q', 'escape']:
core.quit() #abort experiment
event.clearEvents() #must clear other (eg mouse) events - they clog the buffer
vol = pygame.mixer.music.get_volume()
pygame.mixer.music.stop()
return vol
开发者ID:vincentadam87,项目名称:pitch_experiment,代码行数:30,代码来源:run_experimentAXB.py
示例16: close
def close(self):
if not TESTING and self.mark_mode == "Plexon":
self.plexon.CloseClient()
if self.input_mode == "RTBox":
self.RTBox.close()
self.mark_task("end")
core.quit()
开发者ID:pearsonlab,项目名称:wm_visual_search,代码行数:7,代码来源:wm_search.py
示例17: on_key_release
def on_key_release(k,m):
if k == key.SPACE:
print 'space up'
global writeData
global space_down
global space_time
global famStim
global data
global click_stim
global look_onset
global mode
global counting
global look_away_time
if mode == "test" and counting == 0:
counting = 1
look_away_time = clock.getTime()
elif mode == "get":
pass
else:
space_time = (clock.getTime() - space_down) * 1000 #return time in milliseconds
print click_stim, famStim
data.append( ( click_stim+"~~"+famStim, str(space_time), "lookingFam" ) ) #data to be written to the output file is added to the data array above on each key release, and some globals are updated, i.e. 'stimuli' are updated as the experiment executes
if k == key.ESCAPE:
if mode == 'test':
escStim = stimuli
elif mode == 'famil':
escStim = famStim
data.append( ( escStim, str( (clock.getTime() - famStart) * 1000), "totalPlaying-Escape" ) )
writeData()
win.close()
core.quit()
开发者ID:skagit,项目名称:bvar_famil_nonadj,代码行数:32,代码来源:bvarGomez.py
示例18: CoolDown
def CoolDown():
# display cool-down message
message1.setText("That's the end! ")
message2.setText("Press 'q' or 'escape' to end the session.")
win.logOnFlip(level=logging.EXP, msg='Display TheEnd')
win.callOnFlip(SendMessage,'DisplayTheEnd')
message1.draw()
message2.draw()
win.flip()
thisKey = event.waitKeys(keyList=['q','escape'])
"""
# stop recording SMI via serial port
myTracker.stop_recording()
# save result
myTracker.save_data(path=(filename+'.idf'))
# close serial port
myTracker.cleanup()
"""
#"""
# End EyeLink recording: add 100 msec of data to catch final events
pylink.endRealTimeMode()
pumpDelay(100)
getEYELINK().stopRecording()
while getEYELINK().getkey(): # not sure what this is for
pass
# File transfer and cleanup!
getEYELINK().setOfflineMode()
msecDelay(500)
message1.setText("Sending EyeLink File...")
message2.setText("Please Wait.")
win.logOnFlip(level=logging.EXP, msg='Display SendingFile')
message1.draw()
message2.draw()
win.flip()
#Close the file and transfer it to Display PC
getEYELINK().closeDataFile()
getEYELINK().receiveDataFile(edfHostFileName, edfFileName)
getEYELINK().close();
#Close the experiment graphicss
pylink.closeGraphics()
#"""
# stop sound
# fullSound.stop()
whiteNoiseSound.stop()
pageSound.stop()
# save experimental info (if we reached here, we didn't have an error)
expInfo['tSound'] = tSound
toFile(expInfoFilename, expInfo) # save params to file for next time
# exit
core.quit()
开发者ID:djangraw,项目名称:PsychoPyParadigms,代码行数:60,代码来源:DistractionTask_eyelink_d6.py
示例19: _show_screen
def _show_screen(self, text):
visual.TextStim(text=text, **self.screen_text_kwargs).draw()
self.win.flip()
response = event.waitKeys(keyList=['space', 'q'])[0]
if response == 'q':
core.quit()
开发者ID:lupyanlab,项目名称:motivated-arrows,代码行数:7,代码来源:run.py
示例20: GetResponse
def GetResponse():
global currentRule, currentTgt, ruleCount, rightAnswers, gameScore
event.clearEvents()
retVal = 0 #if not modified, breaks the task
answerPressed = -1 # which card was selected?
keylist = { 'down': ['down', '2'], 'left': ['left', '4'], 'up': ['up', '8'], 'right': ['right', '6']}
keys = event.waitKeys(keyList=['f10', 'escape', 'up', 'right', 'down', 'left', '2', '4', '6', '8'])
if keys[0] == 'f10':
triggerAndLog(portCodes['stop'], "STP", 0, 0, "STOP: aborted by F10")
win.close()
core.quit()
if keys[0] == 'escape':
retVal = 0
#elif keys[0] == 'up':
elif keys[0] in keylist['up']:
if CheckCard( 0, currentRule, currentTgt ):
rightAnswers += 1
retVal = 1
else:
retVal = -1
#elif keys[0] == 'right':
elif keys[0] in keylist['right']:
if CheckCard( 1, currentRule, currentTgt ):
rightAnswers += 1
retVal = 2
else:
retVal = -2
#elif keys[0] == 'down':
elif keys[0] in keylist['down']:
if CheckCard( 2, currentRule, currentTgt ):
rightAnswers += 1
retVal = 3
else:
retVal = -3
#elif keys[0] == 'left':
elif keys[0] in keylist['left']:
if CheckCard( 3, currentRule, currentTgt ):
rightAnswers += 1
retVal = 4
else:
retVal = -4
idx=str(rules.index(currentRule)+1)
if retVal > 0:
gameScore += 1
triggerAndLog( portCodes['respRight'] + portCodes['rule'+idx],\
"RSP", currentBlock, currentTrial, 'RESPONSE 1 ' + currentRule + ' ANSWER ' + str(retVal) )
elif retVal < 0:
gameScore -= 1
triggerAndLog( portCodes['respWrong'] + portCodes['rule'+idx],\
"RSP", currentBlock, currentTrial, 'RESPONSE 0 ' + currentRule + ' ANSWER ' + str(retVal) )
return retVal
开发者ID:bwrc,项目名称:WishGLD,代码行数:60,代码来源:WCST_faces_tasktypes_matchingstim_configfile_xpltfrm.py
注:本文中的psychopy.core.quit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论