My .csv file does not seem to load in my loop (component does not recognise variable with "$variable")

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 1.84.x):
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:

I have a decently complex study that has been working fine. This study will frequently call upon .csv files, which house filepaths to images that I want displayed in my study.

I have just added a routine now that will display 6 images (6 different image-routines) at the same time (organised on their screen). When I specify specific filepaths for the images this works fine (“folder/folder2/stimulus.png”).

Here’s where I encounter my problem
Now, however, I put a loop around this routine, set repeats to “1”, Loop type = sequential, and include a .csv file with a variable called “blueprint_im”. This variable has 6 filepaths (one in each row), that link to 6 different images that are all in the same folder. When I go to my image components, I change each component’s “Image” to $blueprint_im[0], $blueprint_im[1], and so on…

However, when I try and run it I get this error:
Unfortunately we encountered the following error:

  • ReferenceError: blueprint_im is not defined

Try to run the experiment again. If the error persists, contact the experiment designer.

What did you try to make it work?:

What specifically went wrong when you tried that?:

  • I have tried calling the .csv file with a javascript code component (did not work)
  • I have tried making them all the same image ($blueprint_im[1])
  • I have tried running this on other computers
  • I have tried clearing my cache
  • I have had 2 other people check the spelling of my variable names
  • I have made sure that all my resources are loaded
  • If I set my Image from “Constant” to “Set every repeat” my error is:

Unfortunately we encountered the following error:

  • when setting the image of ImageStim: image_A1
  • when getting the value of resource: l
  • unknown resource

Try to run the experiment again. If the error persists, contact the experiment designer.

… and many other things but I’m forgetting them.

If it makes a difference, since starting this up, I am having trouble with running the experiment on my desktop. But if I synchronise and run it on pavlovia it works perfectly. So I have just been synchronising and running on pavlovia (i.e., I do not know if it works on desktop).

** Ultimately**
How do I get each of my image components to display a different image, which is prescribed by my pre-loaded .csv file

If your CSV file has a column called blueprint_im then you should address it as $blueprint_im in a component. You can only access the value of the current row if you are using a loop. If you want 6 images simultaneously then you could use 6 columns.

Alternatively, you could preload the values into a list.

1 Like

Great thank you! This is helpful.