Putting breaks in a timeline, how? #1757
-
So i have another issue: i would like to add breaks in my experiment. I have 384 repetitions of the timeline, and i'd like to put in four breaks, so after every 96 trials. Seems simple, yet i wouldn't know how to let some trial sometimes appear, and sometimes not. This is my break trial:
Other people make blocks, and then put a break trial in between, but i'd rather just make the break trial i have conditional on the timeline repetition number. Maybe i could use js.Psych.progress() for that, which returns current_trial_global. That sounds good, but i have no idea how to use that count. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @DanielBruijn, yes, you can put your break trial inside of a conditional timeline, and then put that conditional timeline inside the trial procedure that uses timeline variables. When I want to add a break every N trials, what I do is create a global variable to count the trials. In the conditional function, I check if there's a remainder when dividing the current trial count by N - if not then run the break trial, otherwise don't. So altogether it might look something like this: var trial_count = 0;
var break_trial = {
type: 'html-keyboard-response',
stimulus: "<p style='font-size: 25px'>Time to take a break!</p>" +
"<p style='font-size: 25px'>Take a rest for about a minute. Then, Continue by pressing 'C'</p>",
choices: "c"
};
var break_conditional = {
timeline: [break_trial],
conditional_function: function() {
// increment trial count - in first run through the timeline variables procedure, trial_count will be equal to 1
trial_count++;
if (trial_count % 96 == 0) {
// if the trial count is divisible by 96, then run the break trial
return true;
} else {
// otherwise skip the break trial
return false;
}
}
];
var real_trials = {
timeline: [break_conditional, ... other trials ...],
timeline_variables: full_design
};
timeline.push(real_trials); You could also do this using |
Beta Was this translation helpful? Give feedback.
Hi @DanielBruijn, yes, you can put your break trial inside of a conditional timeline, and then put that conditional timeline inside the trial procedure that uses timeline variables.
When I want to add a break every N trials, what I do is create a global variable to count the trials. In the conditional function, I check if there's a remainder when dividing the current trial count by N - if not then run the break trial, otherwise don't.
So altogether it might look something like this: