-
I am creating an experiment in analogy of https://groups.google.com/forum/#!topic/jspsych/fCKiH-HRvGM. I want the trials to keep going for a limited amount of time, after which the block is ended. Because I am using function init_pool() {
var conditions = [
{cue: 'A', probe: 'X', trial_type: 'AX'},
{cue: 'A', probe: 'X', trial_type: 'AX'},
{cue: randomLetter, probe: 'X', trial_type: 'BX'},
{cue: 'A', probe: randomLetter, trial_type: 'AY'},
{cue: randomLetter, probe: randomLetter, trial_type: 'BY'},
];
return jsPsych.randomization.repeat(conditions, 3);
}
var distractors = ['B','C','D','E','F','G','H','I','J','L','M','N','O','P','Q','R',
'S','T','U','V','W','Y','Z'];
function randomLetter() {
return distractors[Math.floor(Math.random()*distractors.length)];
}
var trials = {
timeline: [fixation, first_letter, blank, second_letter, feedback],
loop_function: function(){
return block_duration - Date.now() + block_start_time >= 0;
},
on_start: function(trial) {
if (condition_pool.length === 0){
condition_pool = init_pool();
}
var currentTrial = condition_pool.pop();
// The below obviously doesn't work, but it would be nice ;)
// I just created global variables for the properties I want to be 'active' for the current trial
trial.timeline_variables = currentTrial;
}
} The main problem is that the Is it also possible to specify a function that only fires at the start of the current element, and not at the start of each of its child components? I tried on_load too, but it has the same behavior. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Oh wait. You can use |
Beta Was this translation helpful? Give feedback.
-
Alright, I have to revisit this again. I found out that the loop_function is only called after all timeline_variables have been processed, while I hoped it would evaluate after every trial. It seems you cannot use timeline_variables after all in a situation which you want to evaluate after each trial if the block should be stopped or continue depending on the time passed. |
Beta Was this translation helpful? Give feedback.
Oh wait. You can use
timeline_variables
... 🤦 . I thought it would only repeat the current trial (and its values) and not sample new ones. But I guess in a different context my question still stands. Is it possible to execute a function only at the start of its timeline, and not propagate it to all of its child components?