Randomizing trials within a timeline? #1649
Answered
by
jodeleeuw
chester108
asked this question in
Q&A
-
Hello! I have a series of 4 trials. On half of the trials, the buttons are presented as "YES" or "NO", on the second half I'd like the button order to be "NO" or "YES." I want the order that the trials are presented in to be randomized. I've added the trials to a node. What parameters can I use to achieve this and then push the node to my timeline? Thank you! var timeline = [];
var trial_1 = {
type: 'image-button-response',
stimulus: item1
choices: ['<p style="font-size: 50px;"> YES </p>', '<p style="font-size: 50px;"> NO </p>'],
on_finish: function(data){
var response;
response= data.response;
button_press.push(response);
var rt;
var rt= data.rt;
RTbutton_press.push(rt);
var stimulus= data.stimulus;
item.push(stimulus)
}
var trial_2 = {
type: 'image-button-response',
stimulus: item2
choices: ['<p style="font-size: 50px;"> YES </p>', '<p style="font-size: 50px;"> NO </p>'],
on_finish: function(data){
var response;
response= data.response;
button_press.push(response);
var rt;
var rt= data.rt;
RTbutton_press.push(rt);
var stimulus= data.stimulus;
item.push(stimulus)
}
var trial_3 = {
type: 'image-button-response',
stimulus: item3
choices: ['<p style="font-size: 50px;"> NO </p>', '<p style="font-size: 50px;"> YES </p>'],
on_finish: function(data){
var response;
response= data.response;
button_press.push(response);
var rt;
var rt= data.rt;
RTbutton_press.push(rt);
var stimulus= data.stimulus;
item.push(stimulus)
}
timeline.push(trial_3);
var trial_4 = {
type: 'image-button-response',
stimulus: item4
choices: ['<p style="font-size: 50px;"> NO </p>', '<p style="font-size: 50px;"> YES </p>'],
on_finish: function(data){
var response;
response= data.response;
button_press.push(response);
var rt;
var rt= data.rt;
RTbutton_press.push(rt);
var stimulus= data.stimulus;
item.push(stimulus)
}
timeline.push(trial_4);
var node = {
timeline: [trial_1, trial_2, trial_3, trial_4],
|
Beta Was this translation helpful? Give feedback.
Answered by
jodeleeuw
Mar 18, 2021
Replies: 1 comment 1 reply
-
Hi @chester108, How about shuffling the trials when you add them to the var node = {
timeline: jsPsych.randomization.shuffle([trial_1, trial_2, trial_3, trial_4])
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
chester108
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @chester108,
How about shuffling the trials when you add them to the
node
timeline: