Add choice position to data #2278
-
Hi! I am working on an experiment where participants are asked to click on one of three images (the odd one out). In the timeline variables for my trials I randomize the order of the images as they appear on the screen, as shown below. For each set of images, there will be an expected odd one out (in this case, "money_01b.jpg"). {
stimulus: '',
choices: jsPsych.randomization.shuffle([
'<img src=img/images/meat/meat_01b.jpg style="width:30vw; border:2px solid #000000;" onclick=badading.play()></img>',
'<img src=img/images/money/money_01b.jpg style="width:30vw; border:2px solid #000000;" onclick=badading.play()></img>',
'<img src=img/images/punch1/punch1_01s.jpg style="width:30vw; border:2px solid #000000;" onclick=badading.play()></img>',
]),
button_html: '%choice%',
data: {
binnumber: '0-0.1',
pairnumber: '',
tripletindex: '1288613',
test_part: 'test',
odd_one_out: 'money',
confounding_direction: 'taxonomic',
affirming_taxonomic: 'construction-related / physical work-related',
confusing_taxonomic: 'paper-related / thin / flat / text-related',
affirming_thematic: 'arms/legs/skin-related',
confusing_thematic: 'feminine (stereotypically) / decorative',
},
}, I'm looking for a way to evaluate whether "button_pressed" matches the image I expected to be the odd one out (money). In a previous version of the study, I had hard-coded the order of the images and added the position of the odd one out to my data, so that I could just compare button_pressed to that position. However, since I'm now randomizing the order of the images, I'm not sure how to approach this. My first thought was that I could add the whole choices array to the output, i.e. by adding choices: '%choice%', to my output, but that seems a bit messy and I'd probably have to edit the resulting string in my output to clean it up. Does anyone have any thoughts? Also, feel free to ask clarifying questions if needed. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @kburkin, what version of jsPsych are you using? Starting in v6.3.0, we added the And if you want to make the And BTW I think you're missing some double quotes around the image file path in I haven't tested this, but I think something like this would work: {
type: 'html-button-response',
stimulus: '',
choices: jsPsych.randomization.shuffle([
'meat/meat_01b',
'money/money_01b',
'punch1/punch1_01s',
]),
button_html: '<img src="img/images/%choice%.jpg" style="width:30vw; border:2px solid #000000;" onclick=badading.play() />',
data: {
// ...
},
save_trial_parameters: {
// save the randomly-selected button order to the trial data
choices: true
}
} I hope this helps! Let us know if this works for you, and if you have more issues/questions. |
Beta Was this translation helpful? Give feedback.
-
Hi @kburkin, yes I think the problem is the use of trial definition: var test = {
// ...
choices: function() {
return jsPsych.randomization.shuffle(jsPsych.timelineVariable('choices'));
},
// ...
}; trial info: {
// ...
choices: ['meat/meat_01b','money/money_01b','punch1/punch1_01s'],
// ...
} And WRT this error:
I think this might be a related problem. I'm guessing your trial information is stored in the "test_stimuli_List1.js" file, which is loaded in the var jsPsych = initJsPsych(...); In your case, moving the |
Beta Was this translation helpful? Give feedback.
Hi @kburkin, yes I think the problem is the use of
jsPsych.randomization.shuffle
in your trial information. Instead of doing it that way, could you try making yourchoices
parameter into a function that accesses the trial'schoices
array from timeline variables, and then calls the randomization function, like this?trial definition:
trial info:
And WRT this error:
I think this migh…