I’m programming a RT task in Psychopy Coder, where I show different images within one trial.
A trial looks like this:
- the trial lasts 15 s or until spacebar is pressed;
- within those 15 s, 25 different images are shown, with blips in between to distract the participant.
- RT is the time of the spacebar press
My question is: how do I save to my datafile, what picture was shown at the time of the spacebar press? The relevant part of my code looks like this:
pict1 = []
img1 = u'Stimuli/vormstimuli/vorm%s.png' % str(i)
pict1.append(visual.ImageStim(win, image=img1, units = 'pix', size = (wi,he))) # folder containing the 25 pictures
nrimages = 25
nr2 = nrimages - 1
i = i +1
j = math.ceil(i/2)
if i%2 == 0:
msg.draw() # this is the blip
else:
if j <= nrimages: # here the 25 different images are shown
pict_index = j-1
else:
pict_index = nr2
pict1[pict_index].draw()
msg.draw()
win.flip()
#check response
timeold = trialClock.getTime() # to get the initial time
key_resp.keys = []
_key_resp_allKeys = []
stoppen = 0
while stoppen == 0:
theseKeys = key_resp.getKeys(keyList=['space'], waitRelease=False)
_key_resp_allKeys.extend(theseKeys)
timenow = trialClock.getTime()
timediff = timenow - timeold
if timediff>duurBlip :
stoppen = 1
if theseKeys:
key_resp.keys = _key_resp_allKeys[-1].name # just the last key pressed
gereageerd = 1
stoppen = 1
...
fp.write('%d %d \n' % (nrimages, gereageerd)
So, pict1.[pict_index] contains a string of 25 images. So, I want to store what pict1_index was shown at the time of the spacebar press.
I would be forever grateful for your help!