Retrieving Variable Value and Inputting into Experiment Later
In my experiment I have 8 variables, which I am setting to have a random number (1-8) assigned to it through ordering (see Step 1 below). Then, I am using form_base to create image buttons and creating paths to .jpg's. (see Step 2 below). Then, participants click one of the images and I want to know the value of the variable attached to that button so I know which .jpg they picked since they are appearing in a random order (see Step 3 below). Up until here, everything works exactly as I need it to. For instance, if 'Face_1_Step1' has the value '8' attached to it and the participant selects the image attached to this variable 'Face_Selected_Step1' gives the value 8. I have verified this numerous times.
Now, later in the experiment, what I want to do is show them the image that they selected earlier next to a new image. 'Face_Selected_Step1' retrieves the value that I need (e.g., 8) in order to show the right .jpg (e.g., F8.jpg). Since I am showing photos, I am using form_base again but the code results in an error that always says 'variable Face_Selected_Step1 does not exist' (See Step 4 below). However, I know it exists because when I remove this step I can see it in my logged data (and it is correct). Also, when I do variable inspector it shows up.
Basically, I want to know which picture someone clicked (F1.jpg, F2.jpg, F3.jpg, etc), but these are appearing in a random order. Then, have that picture appear later next to a new picture.
Thank you so much in advance for the assistance and sorry if this is super confusing.
STEP 1:
var.set('Face_1_Step1',x1)
var.set('Face_2_Step1',x2)
var.set('Face_3_Step1',x3)
var.set('Face_4_Step1',x4)
var.set('Face_5_Step1',x6)
var.set('Face_6_Step1',x7)
var.set('Face_7_Step1',x8)
var.set('Face_8_Step1',x9)
STEP 2:
set timeout infinite
set spacing 10
set rows "1;1;1"
set only_render no
set margins "10;10;10;10"
set description "A generic form plug-in"
set cols "1;1;1"
set _theme gray
widget 0 0 1 1 image_button path="F[Face_1_Step1].jpg" var=F_Location1_Step1
widget 1 0 1 1 image_button path="F[Face_2_Step1].jpg" var=F_Location2_Step1
widget 2 0 1 1 image_button path="F[Face_3_Step1].jpg" var=F_Location3_Step1
widget 0 1 1 1 image_button path="F[Face_4_Step1].jpg" var=F_Location4_Step1
widget 2 1 1 1 image_button path="F[Face_5_Step1].jpg" var=F_Location5_Step1
widget 0 2 1 1 image_button path="F[Face_6_Step1].jpg" var=F_Location6_Step1
widget 1 2 1 1 image_button path="F[Face_7_Step1].jpg" var=F_Location7_Step1
widget 2 2 1 1 image_button path="F[Face_8_Step1].jpg" var=F_Location8_Step1
- Note .jpgs are saved as (F1.jpg, F2.jpg, F3.jpg, etc) in file pool
STEP 3:
if(var.F_Location1_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_1_Step1'))
elif(var.F_Location2_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_2_Step1'))
elif(var.F_Location3_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_3_Step1'))
elif(var.F_Location4_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_4_Step1'))
elif(var.F_Location5_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_5_Step1'))
elif(var.F_Location6_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_6_Step1'))
elif(var.F_Location7_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_7_Step1'))
elif(var.F_Location8_Step1 == "yes"):
var.set("Face_Selected_Step1", var.get('Face_8_Step1'))
STEP 4:
set timeout infinite
set spacing 10
set rows "1"
set only_render no
set margins "10;10;10;10"
set description "A generic form plug-in"
set cols "1;1"
set _theme gray
widget 0 0 1 1 image_button path="F[Face_Selected_Step1].jpg" var=F_Location1_Step2
widget 1 0 1 1 image_button path="WildCard.jpg" var=F_Location2_Step2
Comments
Hi,
Not sure, but could this be due to a prepare/run failure? If all the forms are in the same sequence, then the variables needed to prepare later forms, will not exist yet if they are generated in the run phase of earlier forms. See here for details. I think the solution would be to separate the sequences, but also I am not sure about that.
Eduard