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() )