def put_image_dual(t_abs): global phase global start global bus global talked global fixCross if not phase: start = t_abs phase = "dots" talked = False fixText, fixCross = experiments.printWord(screen, '+', crossSize, (0, 0, 0)) t = t_abs - start if t >= dot_duration and phase == "dots": texture_object1.put_sub_image(mask_img) texture_object2.put_sub_image(mask_img) phase = "mask" elif t >= (dot_duration + mask_dur) and phase == "mask": p.parameters.viewports = [fixCross] phase = "cross" elif t >= (dot_duration + mask_dur + cross_duration): p.parameters.go_duration = (0, 'frames') if response == "voice": message = bus.poll('GST_MESSAGE_ANY', 1) # read peak if message: if message.src is level: if message.structure.has_key('peak'): peak = message.structure['peak'][0] print peak if peak > volumeThresh and peak < 0 and not talked: sub.inputData(trial, "RT", t) print t talked = True fixText, fixCross = experiments.printWord(screen, '&', crossSize, (0, 0, 0))
def showStimulus(screen, text, colour): word, viewport = printWord(screen, text, 200, colour) p = Presentation(go_duration=(0.5,'seconds'),viewports=[viewport]) p.go() start = time.clock() exit = 0 while not exit: data = raw_lpt_module.inp(0x379) & 0x20 if not data: RT = time.clock() p.parameters.go_duration = (0.032, 'seconds') #dataList.append ([text, colour, start, RT]) exit = 1 else: pass
def showStimulus(screen, text, colour): word, viewport = printWord(screen, text, 200, colour) p = Presentation(go_duration=(0.5, 'seconds'), viewports=[viewport]) p.go() start = time.clock() exit = 0 while not exit: data = raw_lpt_module.inp(0x379) & 0x20 if not data: RT = time.clock() p.parameters.go_duration = (0.032, 'seconds') #dataList.append ([text, colour, start, RT]) exit = 1 else: pass
memTemp = [] calcTemp = [] #these will be the list of CONFIRMED problems by strategy memProblems = [] calcProblems = [] #default strategy strategy = None #default empty problem ns = [] lastns = [] lastlastns = [] fixText, fixCross = printWord(screen, '', 120, (255, 255, 255)) print "PRESS SPACE TO START" pause = Presentation(go_duration=('forever', ), viewports=[fixCross]) pause.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, pause_handler)] pause.go() while len(memProblems) < trials or len(calcProblems) < trials: #generate problem based on last round random.shuffle(add) random.shuffle(subtract) random.shuffle(memAdd) badProblem = True
###UNCHANGING STIMULI #strat selection fixText, fixCross = printText(screen, '', 60, (255, 255, 255)) #generate texts strat2 = "\n\nDescribe your strategy" stratText, stratPort = printText(screen, strat2, 60, (255, 255, 255)) pauseText, pausePort = printText(screen, "paused", 60, (255, 255, 255)) p4 = Presentation(go_duration=(problemTime, 'seconds')) p = Presentation(go_duration=('forever', )) #strat selection startText, startCross = printWord(screen, 'Press the SPACEBAR to start', 60, (255, 255, 255)) pause = Presentation(go_duration=('forever', ), viewports=[startCross]) pause.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, pause_handler)] pause.go() p3 = Presentation(go_duration=(0.5, 'seconds'), viewports=[fixCross]) p2 = Presentation(go_duration=(diffTime, 'seconds'), viewports=[stratPort]) p2.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, diff_handler)] ###DB STUFF db = "mri_test" problems = Problems(db, sid, "addition")
memTemp = [] calcTemp = [] #these will be the list of CONFIRMED problems by strategy memProblems = [] calcProblems = [] #default strategy strategy = None #default empty problem ns = [] lastns = [] lastlastns = [] fixText, fixCross = printWord(screen, '', 120, (255, 255, 255)) print "PRESS SPACE TO START" pause = Presentation(go_duration=('forever', ), viewports=[fixCross]) pause.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, pause_handler)] pause.go() while len(memProblems) < trials or len(calcProblems) < trials: #generate problem based on last round random.shuffle(add) random.shuffle(subtract) random.shuffle(memAdd) badProblem = True
p2.parameters.go_duration = (0, 'frames') def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, 'frames') #default strategy strategy = None trial = 1 #STIMULI #Fixation Cross fixText, fixCross = printWord(screen, '*', 120, (255, 255, 255)) errorText, errorPort = printWord(screen, 'X', 120, (1., .1, .1)) print "PRESS SPACE TO START" pause = Presentation(go_duration=('forever', ), viewports=[fixCross]) pause.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, pause_handler)] pause.go() problemQ = [] while len(stimList): if problemQ: stim = problemQ[2] n1 = problemQ[0]
screen.parameters.bgcolor = (0, 0, 0) pygame.font.init() pygame.mixer.init() sound = pygame.mixer.Sound("beep.wav") sound.play() for s in stimList: trial += 1 print s RT = 0 acc = 0 w, v = printWord(screen, str(s), 48, [255, 255, 255]) p = Presentation(go_duration=[0.675, 'seconds'], viewports=[v]) p.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, key_handler) ] p.go() sub.inputData(trial, "RT", RT) sub.inputData(trial, "acc", acc) sub.inputData(trial, "s", s) sub.inputData(trial, "target", target) sub.printData() sound.play() sub.printData()
def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, 'frames') #initial variables trial = 1 #default strat strat = None ###UNCHANGING STIMULI #strat selection fixText, fixCross = printWord(screen, '', 60, (255, 255, 255)) #generate texts strat2 = "\n\nPlease describe your strategy" stratText, stratPort = printText(screen, strat2, 60, (255, 255, 255)) pre_problems = Problems(DB, sid, clear=False) post_problems = Problems(DB, sid, exp="post", clear=False) query = {'kind' : 'verified'} ver_pre = pre_problems.query(query) ns_list = [] for row in ver_pre:
subject.inputData(trial, "orig_strat", strategy) subject.inputData(trial, "distractor", distractor) subject.inputData(trial, "dist_side", side) subject.inputData(trial, "dist_offset", dist) subject.inputData(trial, "trained", trained) if side == "l": correct = "left" L = solution R = distractor elif side == "r": correct = "right" L = distractor R = solution probText, probPort = printWord(screen, problem, 60, (255, 255, 255)) vp, vr = printText(screen, "%s %s" % (L, R), 60, (255, 255, 255)) fixText, fixCross = printText(screen, '', 60, (255, 255, 255)) #BLOCK 1 - PROBLEM, BLANK & POSSIBLE SOLUTIONS problem = Presentation(go_duration=(problemTime, 'seconds'), viewports=[probPort]) problem.go() p3 = Presentation(go_duration=(blankTime, 'seconds'), viewports=[fixCross]) p3.go() p = Presentation(go_duration=('forever', ), viewports=[vr]) p.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, key_handler)] p.go()
blockOrder = cb.advance() f = open("cb.pck", "w") pickle.dump(cb, f) f.close() stimLib = "stimuli" screen = get_default_screen() screen.parameters.bgcolor = (.52, .51, .52) pygame.init() fixText, fixCross = experiments.printWord(screen, '+', crossSize, (0, 0, 0)) trial = 1 #HANDLERS def put_image_sequential(t_abs): global phase global start if not phase: start = t_abs phase = "dots1" t = t_abs - start
def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, 'frames') #initial variables trial = 1 #default strat strat = None ###UNCHANGING STIMULI #strat selection fixText, fixCross = printWord(screen, '', 60, (255, 255, 255)) #generate texts strat2 = "\n\nPlease describe your strategy" stratText, stratPort = printText(screen, strat2, 60, (255, 255, 255)) pre_problems = Problems(DB, sid, clear=False) post_problems = Problems(DB, sid, exp="post", clear=False) query = {'kind': 'verified'} ver_pre = pre_problems.query(query) ns_list = [] for row in ver_pre:
ACC += 1 acc = 1 pressed = 1 else: acc = 0 pressed = 1 ACC = 0 RT = p.time_sec_since_go ###SET SCREEN screen = get_default_screen() screen.parameters.bgcolor = (0, 0, 0) pygame.font.init() c, cv = printWord(screen, 'O', 48, [0, 255, 0]) ic, icv = printWord(screen, '+', 48, [255, 0, 0]) f, fv = printWord(screen, '', 48, [0, 0, 0]) cp = Presentation(go_duration=[0.1, 'seconds'], viewports=[cv]) icp = Presentation(go_duration=[0.1, 'seconds'], viewports=[icv]) fix = Presentation(go_duration=[0.05, 'seconds'], viewports=[fv]) trial = 0 for block in blockorder: for gowords in ([block, 'neutral'], ['neutral', block]): ACC = 0 while ACC <= maxACC: trial+=1 RT = 0
screen.parameters.bgcolor = (0, 0, 0) pygame.font.init() pygame.mixer.init() sound = pygame.mixer.Sound("beep.wav") sound.play() for s in stimList: trial += 1 print s RT = 0 acc = 0 w, v = printWord(screen, str(s), 48, [255, 255, 255]) p = Presentation(go_duration=[0.675, 'seconds'], viewports=[v]) p.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, key_handler)] p.go() sub.inputData(trial, "RT", RT) sub.inputData(trial, "acc", acc) sub.inputData(trial, "s", s) sub.inputData(trial, "target", target) sub.printData() sound.play() sub.printData()
def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, "frames") # default strategy strategy = None trial = 1 # STIMULI # Fixation Cross fixText, fixCross = printWord(screen, "*", 120, (255, 255, 255)) errorText, errorPort = printWord(screen, "X", 120, (1.0, 0.1, 0.1)) print "PRESS SPACE TO START" pause = Presentation(go_duration=("forever",), viewports=[fixCross]) pause.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, pause_handler)] pause.go() problemQ = [] while len(mag_problems): if problemQ: stim = problemQ[2] n1 = problemQ[0]
def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, 'frames') #default strategy strategy = None trial = 1 #STIMULI #Fixation Cross fixText, fixCross = printWord(screen, '*', 120, (255, 255, 255)) errorText, errorPort = printWord(screen, 'X', 120, (1., .1, .1)) print "PRESS SPACE TO START" pause = Presentation(go_duration=('forever', ), viewports=[fixCross]) pause.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, pause_handler)] pause.go() problemQ = [] while len(mag_problems): if problemQ: stim = problemQ[2]
cross_duration = .750 bgcolor = (0, 0, 0) color = (1, 1, 1) ###END SETTINGS stimLib = "stimuli" screen = get_default_screen() screen.parameters.bgcolor = bgcolor pygame.init() fixText, fixCross = experiments.printWord(screen, '+', crossSize, color) trial = 1 #HANDLERS def put_image_dual(t_abs): global phase global start if not phase: start = t_abs phase = "dots" t = t_abs - start