I’ve looked at this post, which seems to outline how to do this in Builder, but I’m uncertain how to implement it with code (i.e. precisely what to write in my csv file and how to call it properly).
I have a loop which reads in the names of images (stored in a csv previously), and would like the images to randomly animate (i.e move up and down, side to side, rotate, etc). I know how to implement the animations each time, for example with the code below:
imgL.ori += 1.5 imgR.size += numpy.sin((globalClock.getTime()-onset)/40)
but am not sure how to have these properties change on each trial. My plan was to have a set of 10 or so ways of moving plugged into a csv and then pull them randomly, but I do not know how to implement this within the loop.
Here is my loop:
tidx = 0 for tidx, trial in enumerate(trials): #do some stuff logging.log(level=logging.INFO, msg="Trial %i - Stimuli1 %s - Stimuli2 %s" % (tidx+1, trial['path1'], trial['path2'])) #Set values for trial onset = globalClock.getTime() trials.data.add('onset', onset) rt=None Pressed=False #while not mouseclick.getPressed(): #while globalClock.getTime() < (tidx+1)*trialDur: while not Pressed: background_image.draw() imgL.draw() imgR.draw() win.flip() mouseclick=mymouse.getPressed() #key=event.getKeys(keyList=('escape')) if sum(mouseclick)>0: rt=globalClock.getTime()-onset core.wait(.1) Pressed= True event.clearEvents() trials.data.add('rt',rt)