I am presenting two images in one routine: a prime and a target. All primes have a similar size, which I’ve set in the image layout as [0.5,0.5]. All targets have different sizes, so I use a conditions file to set them. I created two variables to set the target size: xdim and ydim (image size is set to [xdim, ydim]). This conditions file seem to be the issue. It looks like this:
Psychopy gives me a reference error: xdim is not defined. If I delete column A, my experiment runs without an issue. But I cannot delete this column, because my primes and targets need to be presented in pairs. Do you have any idea how to solve this?
One solution that might work out for you is changing the size from constant to set every repeat:
Another solution would be to remove the dynamic image sizing (image size is set to [xdim, ydim]).
Then, at the start of each routine, set the image size this way:
image.size = [xdim, ydim]
The error occurs because the moment you start the experiments, the image tries to access the xdim and ydim variables. The problem is that those variables are not yet initialized when you try to access them.
Thanks for your reply!
Stimulus layout is set to “set every repeat”, so this is not the issue.
Adding code component doesn’t help either. As I wrote above, everything works fine as long as I have one image in my routine. Your example also works fine, because you have one image in your routine. In my experiment, I need two images presented in one routine, as I have a prime and a target image. This is the main issue with my error.
Please take a look at the following example: Ta.zip (151.3 KB)
It has two images in the same routine. One of the images (Mario) gets a dynamic xdim and ydim from the spreadsheet, while the second image (Luigi) receives a constant value.
Both images receive a dynamic value as their path from the spreadsheet:
image_1
xdim
ydim
image_2
images/Mario.jpg
0.1
0.1
images/Luigi.png
images/Mario.jpg
0.2
0.2
images/Luigi.png
images/Mario.jpg
0.3
0.3
images/Luigi.png
images/Mario.jpg
0.4
0.4
images/Luigi.png
images/Mario.jpg
0.5
0.5
images/Luigi.png
images/Mario.jpg
0.6
0.6
images/Luigi.png
images/Mario.jpg
0.7
0.7
images/Luigi.png
images/Mario.jpg
0.8
0.8
images/Luigi.png
images/Mario.jpg
0.9
0.9
images/Luigi.png
images/Mario.jpg
1
1
images/Luigi.png
I still don’t know what exactly the issue is in your experiment.
It could be helpful to include your experiment here/include a minimalistic example if you have any sensitive information.
Also, please make sure your image path is set to every repeat:
Thanks again! My experiment is absolutely similar to the one you shared. They both run just fine, I’m not sure why this error persisted. There is a chance the browser did not update the changes.