View Single Post
  #4  
Old 08-21-2014, 12:14 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
The following is a short example script that loops through 3 trials in a task function. Each trial loops for the number of images in the images list. For each image loop the program waits for either the 'y' or 'n' key to be pressed:

Code:
import viz
import viztask
import random

viz.go()

#Store images in list
images = []

def experiment():
	
	#Repeat trial 3 times
	for i in range(3):
	
		#Use random.shuffle to put images in random order
		random.shuffle(images)
		
		#Cycle through images
		for image in images:

			#display image
			
			#wait for 'y' or 'n' key to be pressed
			data = yield viztask.waitKeyDown(('y','n'))
			print data.key
			
			#remove image and let user know if response is correct
			
viztask.schedule( experiment() )
Reply With Quote