Creating Trial- and Block-indices when using Timeline Variables #2928
-
Hi everyone, As a short disclaimer: I'm relatively new to jsPsych (and javascript) and have only just been trying out a couple of things these past few months!
Now to my question: In the final data, I want to have one continuous Trial-Id that only changes when a new trial begins (i.e., all steps within the timeline above have the same value until a repetition starts). I've seen some code online that used the loop_function, but I wasn't 100% sure if that'd work here, since I'm basically looping using Timeline Variables above. I also tried to create some variable that'd change with each "first_fixation_of_a_trial" but that didn't work either. If somebody could refer me to a similar discussion, or knows an easy fix, that'd be great! Thanks so much and take care |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Raphael-Merz,
I think this is the approach that I would take. It is a bit tricky to implement because you have to use a dynamic parameter. Here's a simplified example: var block_index = -1; // starting this at -1 so the first block is 0 after incrementing.
var first_trial = {
// whatever parameters you need here
on_start: function(){
block_index++;
}
}
var block_timeline = {
timeline: [ first_trial, second_trial, third_trial ],
data: {
block_id: function() { return block_index; }
}
} This should add |
Beta Was this translation helpful? Give feedback.
Hi @Raphael-Merz,
I think this is the approach that I would take. It is a bit tricky to implement because you have to use a dynamic parameter.
Here's a simplified example:
This should add
block_id
to every trial in theblock_timeline
, and use t…