"We're now going to test the eyetracker module. Press Space to start!") disp.fill(scr) t1 = disp.show() log.write(["EyeTracker", t1]) kb.get_key() # tracker.calibrate tracker.calibrate() # tracker.sample() scr.clear() scr.draw_text("The dot should follow your eye movements") disp.fill(scr) disp.show() tracker.log("now testing sample function") tracker.status_msg("now testing sample function") tracker.start_recording() key = None while not key == 'space': # get new key key, presstime = kb.get_key(timeout=1) # new states gazepos = tracker.sample() # draw to screen scr.clear() scr.draw_text("The dot should follow your eye movements") scr.draw_fixation(fixtype='dot', pos=gazepos, pw=3, diameter=15) disp.fill(scr) disp.show() tracker.stop_recording() scr.clear()
disp.fill(textscr) disp.show() kb.get_key(keylist=None, timeout=None, flush=True) # Log the start of the trial. log.write([time.strftime("%y-%m-%d"), time.strftime("%H-%M-%S"), \ trialnr, vidname, timer.get_time()]) # Start eye tracking. tracker.start_recording() timer.pause(5) tracker.log("TRIALSTART") # Show a status message on the EyeLink. if TRACKERTYPE == 'eyelink': tracker.status_msg("Trial %d/%d (%s)" % (trialnr, len(VIDEOS), vidname)) # Log trial specifics to gaze data file. timer.pause(5) tracker.log("TRIALNR %d; VIDNAME %s; EXPTIME %d; PCTIME %s" % \ (trialnr, vidname, timer.get_time(), \ datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S.%f'))) # Loop until the video ends. for framenr in range(nframes): # Get a timestamp for the start of the loading time. loadstart = timer.get_time() # Load the next frame, and convert it to a format that PsychoPy's # ImageStim can actually recognise.
log.write(["trialnr", "trialstart", "trialend", "duration", "image"]) # run trials tracker.calibrate() for trialnr in range(0, len(IMAGES)): # blank display disp.fill() disp.show() libtime.pause(1000) # prepare stimulus scr.clear() scr.draw_image(IMAGES[trialnr]) # start recording eye movements tracker.drift_correction() tracker.start_recording() tracker.status_msg("trial %d" % trialnr) tracker.log("start trial %d" % trialnr) # present stimulus response = None trialstart = libtime.get_time() while not response: gazepos = tracker.sample() frl.update(disp, scr, gazepos) response, presstime = kb.get_key(timeout=1) # stop tracking and process input tracker.stop_recording() tracker.log("stop trial %d" % trialnr) log.write([ trialnr, trialstart, presstime, presstime - trialstart, IMAGES[trialnr] ])
t0 = fmri_clock.reset() else: event.waitKeys(keyList=['space']) timer.expstart() fmri_clock.reset() t0 = fmri_clock.reset() if withTracker: tracker.start_recording() tracker.log("start trial %d" % 1) # In[Tracker - Start]: if withTracker: tracker.start_recording() tracker.status_msg("Pulse Received; Recording...") #timer.pause(waitTime) why the pause here? # In[Initiate Trial Stimuli]: #draw fixate point, will not change throughout experiment fixate.size = 5 scr.clear() scr.screen.append(fixate) disp.fill(screen=scr) disp.show() #wait half a second before starting while fmri_clock.getTime() < 0.5: pass
image_size[0]) / 2 # centre minus half of the image width y = (DISPSIZE[1] - image_size[1]) / 2 # centre minus half of the image height aoi = AOI('rectangle', (x, y), image_size) disp.fill(scr) # perform a drift check tracker.drift_correction() # RUN TRIAL # start tracking key = None tracker.start_recording() tracker.log("TRIALSTART %d" % trialnr) tracker.log("IMAGENAME %s" % images[trialnr]) tracker.status_msg("trial %d/%d" % (trialnr + 1, ntrials)) # present image disp.fill(scr) t0 = disp.show() tracker.log("image online at %d" % t0) is_found = 1 # wait for a bit for participant viewing image while key != 'space': # check for key input key, presstime = kb.get_key(keylist=['space'], timeout=1) gaze_pos = tracker.sample() gaze_time = timer.get_time() - t0 if aoi.contains(gaze_pos): print(gaze_pos)
print(pressed) if sum(pressed) > 0: event.clearEvents(eventType='mouse') wait = False print(wait) dsp = Display(dispsize=DISPSIZE, screennr=2) tracker = EyeTracker(dsp, trackertype='eyelink') tracker.calibrate() tracker.close() dsp.close() tracker.start_recording() ######### Trials for r in range(rounds): tracker.status_msg('Trial with matrix {}'.format(r)) tracker.log('TRIALSTART') disp.fill(fixscr) disp.show() timer.pause(1000) tracker.log('fixation_onset') gamescreen.clear() ycor = cy - (side / 2) count = 0 for i in range(p2): xcor = cx - (side / 2) gamescreen.draw_text("You", pos=(cx, cy - (side / 2) - ((yax * (1 - margin)) / 6)),
scr.draw_text("We're now going to test the eyetracker module. Press Space to start!") disp.fill(scr) t1 = disp.show() log.write(["EyeTracker", t1]) kb.get_key() # tracker.calibrate tracker.calibrate() # tracker.sample() scr.clear() scr.draw_text("The dot should follow your eye movements") disp.fill(scr) disp.show() tracker.log("now testing sample function") tracker.status_msg("now testing sample function") tracker.start_recording() key = None while not key == 'space': # get new key key, presstime = kb.get_key(timeout=1) # new states gazepos = tracker.sample() # draw to screen scr.clear() scr.draw_text("The dot should follow your eye movements") scr.draw_fixation(fixtype='dot', pos=gazepos, pw=3, diameter=15) disp.fill(scr) disp.show() tracker.stop_recording() scr.clear()
for trialnr in range(ntrials): # PREPARE TRIAL # draw the image scr.clear() scr.draw_image(os.path.join(IMGDIR,images[trialnr])) # perform a drift check tracker.drift_correction() # RUN TRIAL # start tracking tracker.start_recording() tracker.log("TRIALSTART %d" % trialnr) tracker.log("IMAGENAME %s" % images[trialnr]) tracker.status_msg("trial %d/%d" % (trialnr+1, ntrials)) # present image disp.fill(scr) t0 = disp.show() tracker.log("image online at %d" % t0) # wait for a bit timer.pause(TRIALTIME) # reset screen disp.fill() t1 = disp.show() tracker.log("image offline at %d" % t1) # stop recording