def present_trial(imagepath): """ This is the main function used to run this demo. It is fed an imagepath and uses this to create a CommandableImageSprite offscreen. This Sprite is later moved onto the screen, where it hangs out until it is clicked. """ #create a tobii simulator tobii_sim = TobiiSimController(screen) #create a tobii sprite img = TobiiSprite( screen, spot.center, imagepath, tobii_sim, scale=IMAGE_SCALE) # this sets this sprite to follow eye gaze once it's first looked at img.enable_follow(); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Set up the updates, etc. # A queue of animation operations Q = DisplayQueue() # Draw a single animation in if you want! # What order do we draw sprites and things in? dos = OrderedUpdates(img) # Draw and update in this order ## Note the start time... start_time = time() # start recording the "eye gaze" data tobii_sim.start_tracking() ## The standard event loop in kelpy -- this loops infinitely to process interactions ## and throws events depending on what the user does trial_time = 5.0 for event in kelpy_standard_event_loop(screen, Q, dos, throw_null_events=True): #stay in the event loop until the trial time has passed if (time() - start_time > trial_time): print "trial end" break #can check if the image is being looked at #img.is_following = img.is_looked_at() #have the sprite follow the "eye gaze" img.process_follow(event) #stop collecting "eye gaze" data tobii_sim.stop_tracking()
if val == 2: chosen_images_and_quadrants.append([the_data[2][0],quadrant2[the_data[2][1]],val]) if val == 3: chosen_images_and_quadrants.append([the_data[3][0],quadrant3[the_data[3][1]],val]) window_positions = [quadrant0[the_data[0][1]],quadrant1[the_data[1][1]],quadrant2[the_data[2][1]],quadrant3[the_data[3][1]]] images = [the_data[0][0],the_data[1][0],the_data[2][0],the_data[3][0]] #present the trial! Yay! #present the trial by grabbing the quadrant positions from the big matrix present_trial(chosen_images_and_quadrants,window_positions,images, chosen_blob) #when trial is done (either by running out of time, or by lookaway), do attention_getter #MAY USE DIFFERENT ATTENTION GETTER BECAUSE BORING attention_circle() #when all done, shut off the eyetracker and quit if not use_tobii_sim: tobii_controller.stop_tracking() tobii_controller.close_data_file() tobii_controller.destroy() quit() quit()