Experiment inconsistently finds/uses images randomly assigned

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): PsychoPy3
Error message: “20.6814 ERROR Couldn’t find image OLFive; check path? (tried: C:\Users\Documents\KahntPilot\OLFive)”

I am trying to replicate Kahnt, et al. (2014)’s paradigm to pilot 3 different delay conditions, which I am currently creating a block/loop for each delay condition. The task is a cued task, where participants are shown a cue (in this case, an image) and that 100% predicts the outcome (of which there are only 4). For each block, I want to use 4 different images, so I need to randomly assign 12 out of 52 image stimuli to represent each cue-outcome set. I have been testing all of my coding elements in a Python IDE, so I believe the random assignment portion is working. However, from the error message, I know that the program is looking for the image in a folder that does not exist (C:\Users\Documents\KahntPilot\OLFive) once in the experiment phase (correct directory is C:\Users\Documents\KahntPilot). OLFive is the first cue variable I am trying to set to one specific image and I have this element “set every repeat”. In the practice phase, I test if PsychoPy can pull the assigned image stimulus for OLFive if I set it to be static (only this cue, not any of the other three), and it works.

I am not sure if I am adding an extra step, since I have my condition file with the cues (such as OLFive) and their outcome to have the correct number of trials. Should all of this be set in code elements? At some point I will also need for it to check if the participant selected the correct outcome, but I cannot test this in PsychoPy while it cannot find the images.

I have read through posts that seemed related, but am still stuck.

Kahnt, T., Park, S. Q., Haynes, J.-D., & Tobler, P. N. (2014). Disentangling neural representations of value and salience in the human brain. Proceedings of the National Academy of Sciences, 111(13), 5000-5005.

There may not have been enough detail in the original post, but essentially the solution came down to using a code element and making sure to use the correct syntax. In case this post is useful to anyone in the future, this is how I fixed it:

At the very beginning of the experiment, I use a code block to create a list of the image stimuli, and a second list that randomly samples all possible images to select the image stimuli used for the current run. Within the practice or trial phase, I added code in Begin Routine to set the image depending on the Condition noted in the Excel Condition file.

Where I had trouble: when referring to an entire column from your conditions Excel, you simply use the name. However, if you refer to a specific instance within that column, you need quotation marks around it. So, ColumnName vs “specific instance” is what I needed to correct the code syntax.

Note: Since I used the random.sample() to randomly select 12 images out of 52, this code would need modification before it could be moved from the builder to Pavlovia.