mercredi 13 janvier 2016

Duplicating random visual stimuli in Python/Psychopy

Using Python/Psychopy. I am presenting 3 random visual stimuli to the center of the screen for 1 second (imgList1). I am then presenting 3 other random visual stimuli to the upper right of the screen (imgList). On 50% of occasions I need the second group of stimuli (imgList) to be the same as the first (imgList1). How do i access which stimuli were randomly selected at part 1 so i can then use that information to display those same ones thereafter? I am not sure how to keep track of what results from my initial randomly selected images.

Here is my code:

#make initial stimuli
imgList1 = glob.glob(os.path.join('stim','*.png'))
random.shuffle(imgList1)
targetset = [visual.ImageStim(window, img) for img in imgList1]

setlocation = [(-2,0),(0,0),(2,0)]
random.shuffle(setlocation)

#make second group of stimuli
imgList = glob.glob(os.path.join('stim', '*.png'))
random.shuffle(imgList)
pics = [visual.ImageStim(window, img) for img in imgList[:3]]

location = [(1,2),(3,3),(5,5)]
random.shuffle(location)

#display initial stimuli set
for i in range(3):
    targetset[i].pos = setlocation[i]
    targetset[i].draw()

window.flip()
core.wait(1)

#display secondary stimuli
for i in range(3):
    pics[i].pos = location[i]
    pics[i].draw()
    window.flip()
    core.wait(.25)

core.wait(3)
window.close()
quit()




Aucun commentaire:

Enregistrer un commentaire