View Single Post
  #5  
Old 08-22-2014, 08:55 AM
bobbin_93 bobbin_93 is offline
Member
 
Join Date: Jul 2014
Posts: 4
Hi,

That's absolutely brilliant, thank you so much for your help it's really helped me to put the experiment together!

I have one more question however.

Within my 15 insects there are 5 'models' and 10 mimics'. Models sting, whereas mimics don't and therefore I need to display different answers for each - which I am having trouble with.

Here's the code that I've put. In the images the models are labelled 1 to 5 and the mimics are labelled 6 to fifteen. I've also tried seperating them into 2 seperate lists 'stinging' and 'non-stinging' however, the problem with this is I then can't get them to shuffle randomly between the two. Any ideas?




viz.go()

#Store images in list
images = [one,two,three,four,five,six,seven,eight,nine,ten,e leven,twelve,thirteen,fourteen,fifteen]


def testPhase():

#Repeat trial 3 times
for i in range (3):
#Make background visible
background.visible(viz.ON)
#Add focus point
focus.visible(viz.ON)
#Use random.shuffle to put images in a random order
random.shuffle(images)

#Cycle through images
for image in images:
#Wait 3 seconds for participant to look at focus point
yield viztask.waitTime(3)
#Remove focus point
focus.visible(viz.OFF)
#display image
image.visible(viz.ON)
#Mark the time the programme started
start_time = viz.tick()
question_data = open('experiment_data.txt','a')

#Wait for 'y' or 'n' key to be pressed
d = yield viztask.waitKeyDown(['y','n'])
elapsed_time = viz.tick() - start_time

#remove image and let user know if response is correct
#write data to file
if image == one or two or three or four or five:
if d.key == 'y':
image.visible(viz.OFF)
data = 'Participant' + ' Thinks the insect would sting.\t'
correct.visible(viz.ON)
correctPoints.visible(viz.ON)
info.visible(viz.ON)
if d.key == 'n':
image.visible(viz.OFF)
data = 'Participant' + ' Does not think the insect would sting.\t'
wrong.visible(viz.ON)
wrongPoints.visible(viz.ON)
info.visible(viz.ON)

if image == six or seven or eight or nine or ten or eleven or twelve or thirteen or fourteen or fifteen:
if data == 'n':
image.visible(viz.OFF)
data = 'Participant' + ' Does not think the insect would sting.\t'
correct.visible(viz.ON)
correctPoints.visible(viz.ON)
info.visible(viz.ON)
if data == 'y':
image.visible(viz.OFF)
data = 'Participant' + ' Thinks the insect would sting.\t'
wrong.visible(viz.ON)
wrongPoints.visible(viz.ON)
info.visible(viz.ON)
#add elapsed time to data
data = str(image) + data + ' Elapsed time was: ' + str(round(elapsed_time,2)) + ' seconds\n'
#Write the data to our file.
question_data.write(data)

#Press space bar to start the game
yield viztask.waitKeyDown(' ')
#Remove score
correct.visible(viz.OFF)
correctPoints.visible(viz.OFF)
wrong.visible(viz.OFF)
wrongPoints.visible(viz.OFF)
info.visible(viz.OFF)
focus.visible(viz.ON)

viz.quit()
Reply With Quote