Psychopy V. 2024.1.4
I’ve been running into this constant error that I can’t manage to figure out. I’ve used this exact same logic in a different part of my study that worked fine.
I have four regular stimuli and one catch stimuli. In the beginning of my study, I take all of my regular stimuli and pair them together. Here is how I define these stimuli:
fairy = 'stimuli/fairy.png'
mermaid = 'stimuli/mermaid.png'
witch = 'stimuli/witch.png'
elf = 'stimuli/elf.png'
catchStim = 'catch/grem-catch.png'
Now, I introduce a new variable that determines if the trial will be a catch trial dependent on the block we are in. Here is how I redefine those variables indexing through the trials and blocks:
conditions_list = {
"scenes": conditions["all_scenes"][scene_order[cur_trial]],
"leftStim": conditions["leftStim"][scene_order[cur_trial]],
"rightStim": conditions["rightStim"][scene_order[cur_trial]],
"targetPos": conditions["targetPos"][scene_order[cur_trial]][block_counter],
"targetStim": conditions["targetStim"][scene_order[cur_trial]][block_counter],
"catch": conditions["catchTrials"][scene_order[cur_trial]][block_counter],
"type": conditions["trialType"][scene_order[cur_trial]]
}
After, I introduce a piece of code that defines two new variables leftStim_new and rightStim_new (which I use in my image components within the actual task). Depending on whether the trial is a catch trial or not, the target stimuli may be replaced by the catch stimuli (0 = catch, 1 = no catch):
leftStim_new = ''
rightStim_new = ''
if conditions_list["catch"] == 0: # if it's a catch trial
print("Entered catch trial block")
if conditions_list["targetStim"].strip() == conditions_list["leftStim"].strip(): # and the target is on the left
print("Target is on the left")
leftStim_new = catchStim
rightStim_new = conditions_list["rightStim"]
elif conditions_list["targetStim"].strip() == conditions_list["rightStim"].strip(): # and the target is on the right
print("Target is on the right")
leftStim_new = conditions_list["leftStim"]
rightStim_new = catchStim
elif conditions_list["catch"] == 1: # if it's a no catch trial
print("Entered no catch trial block")
leftStim_new = conditions_list["leftStim"]
rightStim_new = conditions_list["rightStim"]
The problem is, no matter what I do, leftStim_new and rightStim_new end up completely BLANK. Because of this, Psychopy cannot make sense of the requested image simply because there is no requested image!
When I print all of the values within the conditions_list list, everything prints totally normally (including the variables defined as fairy, elf, witch, etc.) EXCEPT those two variables:
print('catch', conditions_list["catch"])
print('targetStim', conditions_list["targetStim"])
print('leftStim', conditions_list["leftStim"])
print('rightStim', conditions_list["rightStim"])
print("leftStim_new:", repr(leftStim_new))
print("rightStim_new:", repr(rightStim_new))
print(conditions_list["scenes"])
Also as seen in the code above, I try printing basically every “if” statement and nothing actually prints meaning it never meets those conditions.
Please help, I don’t know what else to try!!