The [0] means take the first value of Images.
So if I need to access the Image that is active at any given trial, I just delete [0]?
Hi what if I need to access the whole column? I have the following code in my feedback routine in a code snippet:
nCatch = 0
for x in trials.trialList[:]['corr_ans']:
if x == 'space':
nCatch += 1
if nCatch != 0:
nCorr = (trials.data['key_resp_3.corr'].sum()/nCatch) * 100 #.std(), .mean() also available
else:
nCorr = 0.00
msg = "End of block!\nYou got %.1f %% trials correct. Take a break.\nPress Space when you want to continue." %nCorr
And I get this error: for x in trials.trialList[:][‘corr_ans’]:
TypeError: list indices must be integers or slices, not str
################ Experiment ended with exit code 1 [pid:10500] #################
Try
nCatch = 0
for Idx in range(len(trials.trialList)):
if trials.trialList[Idx]['corr_ans'] == 'space':
nCatch += 1
if nCatch != 0:
nCorr = (trials.data['key_resp_3.corr'].sum()/nCatch) * 100 #.std(), .mean() also available
else:
nCorr = 0.00
msg = "End of block!\nYou got %.1f %% trials correct. Take a break.\nPress Space when you want to continue." %nCorr
However, personally I would consider incrementing nCatch after every trial rather than going back through the data at the end.