Skip to content

Conditional trial after every Nth item in timeline #716

Answered by jodeleeuw
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

One solution is to somehow get the conditional function to count how many iterations through the timeline have happened so far, and if it is divisible by 8 then we should show the conditional trial.

To do this, I needed to add some kind of marker to the data that would exist once for each loop. You might already have such a marker in jsPsych.timelineVariable('data'). Since I couldn't see what was in those variables I added one to the fixation trial: data: {phase: 'fixation'}.

In the conditional function, I used jsPsych.data.get().filter({phase: 'fixation'}).count() to count the number of fixation trials so far. I just return this value % 8, which should be true after every 8 trials.

timeline

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ghost
Comment options

@jodeleeuw
Comment options

Answer selected by jodeleeuw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant