Hello all,
I’m using PsychoPy 1.84.4 on a Mac. I’m using the builder. I’m making an experiment where for each trial, there is a cue followed by a target. The participant has to respond to both the cue and the target so I created a variable using the code component to check whether the response to both the cue and the target were correct. I am doing this for all trials and also for a subset of trials (for BX trials only). The code I’ve used is:
if cue_resp.corr==1 and target_resp.corr==1:
all_accuracy=1
trials_practice.addData('all_accuracy',all_accuracy)
else:
all_accuracy=0
trials_practice.addData('all_accuracy',all_accuracy)
if trialtype=='BX' and cue_resp.corr==1 and target_resp.corr==1:
bx_accuracy=1
trials_practice.addData('bx_accuracy',bx_accuracy)
elif trialtype=='BX' and (cue_resp.corr==0 or target_resp.corr==0):
bx_accuracy=0
trials_practice.addData('bx_accuracy',bx_accuracy)
else:
bx_accuracy=None
trials_practice.addData('bx_accuracy',bx_accuracy)
This code works perfectly for all trials but for the BX subset of trials, the output is getting turned into a string variable, but only if the BX trials appear before the non-BX trials (trial presentation is randomized). I have tried manually converting the bx_accuracy variable into an integer (bx_accuracy=int(1)) but I believe the bx_accuracy variable is being turned into a string with the trials_practice.addData command. I have checked the datatype of the bx_accuracy variable and it is an integer just before the trials_practice.addData command. Does anyone have any idea why this is happening and how I can get it to output an integer?