Example #1
0
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()
Example #2
0
    os.makedirs(data_folder)
except OSError:
    if not os.path.isdir(data_folder):
        raise

data_file = data_folder + subject + '_' + session + '_' + session_time + '.csv'
##############################################
## Set up eye tracker

##############################################
## Set up pygame

screen, spot = initialize_kelpy(dimensions=(1920,1200))
if use_tobii_sim:
	#create a tobii simulator
	tobii_controller = TobiiSimController(screen)

else:
	#create an actual tobii controller
	tobii_controller = TobiiController(screen)

	# code for when it's actually hooked up to the eye tracker
	tobii_controller.wait_for_find_eyetracker(3)

	#store tobii data in this file
	tobii_controller.set_data_file(data_folder + subject + '_' + session + '_' + session_time + '.tsv')

	#activate the first tobii eyetracker that was found
	tobii_controller.activate(tobii_controller.eyetrackers.keys()[0])

Example #3
0
MAX_DISPLAY_TIME = 5.0

##############################################
## Set up pygame

screen, spot = initialize_kelpy( dimensions=(800,600) )


OFF_LEFT = (spot.west)

##############################################
## setup and activate tobii

# this creates a TobiiController that calls the actual Tobii SDK code
#tobii_controller = TobiiController(screen)
tobii_controller = TobiiSimController(screen)

# this searches for the tobii eyetracker that is connected.
# It times out based on the given amount of seconds (the default is 1,000 seconds) and exits this program
#tobii_controller.wait_for_find_eyetracker(3)

#set the name of the data file that will output all of the Tobii data
tobii_controller.set_data_file('testdata.tsv')
#activate the first tobii eyetracker that was found
#tobii_controller.activate(tobii_controller.eyetrackers.keys()[0])

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run a single trial
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	

def present_trial(imagepath):