Adding to the timeline dynamically

509 views
Skip to first unread message

ruthsh...@gmail.com

unread,
Jul 14, 2016, 11:54:50 AM7/14/16
to jsPsych
Hello,

I'm trying to set up an experiment where a participant responds to several trials in a block. Any trials in which the participant answers incorrectly should be repeated in a following block. This continues until all trials have been answered correctly. The portion that I am having trouble implementing concerns adding extra blocks to the timeline while the participant is completing the experiment (because it is impossible to predict ahead of time how many blocks a given participant will need in order to answer all trials correctly). Is this possible to do once the experiment has started? How might one go about adding new blocks dynamically to the timeline?

Thank you in advance for any help on this you can give me!

Best wishes,

Ruth

Josh de Leeuw

unread,
Jul 14, 2016, 12:02:26 PM7/14/16
to ruthsh...@gmail.com, jsPsych
Hi, Ruth.

This is possible. But it's going to be complicated. Adding better methods for this kind of thing is on my list of future improvements. In version 6 you can add trials to the end of the experiment dynamically, but not yet to the middle.

With the current version of jsPsych, your best bet is to implement this as a single trial that loops until the conditions have been satisfied. The parameters for the trial need to be generated dynamically, using functions. Then you can have those functions figure out which trials need to be shown. It would look something like this (I haven't tested this code, so beware of syntax bugs)

var trial = {
 timeline: [{
  type: 'single-stim',
  stimulus: function() { 
   // run any code you need here to figure out what stimulus to display on this trial
   return my_image;
  },
  // same general strategy for other plugin values
 }],
 loop_function: function(){
  // return true to run another trial, return false to move on
 }
}

Hope that helps!
Josh
  

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/20971147-9d71-49c1-a54b-c16f30723ed1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ruthsh...@gmail.com

unread,
Jul 14, 2016, 12:11:27 PM7/14/16
to jsPsych, ruthsh...@gmail.com
Hi Josh,

Thank you so much for your quick response! I'll give this a try now.

Best wishes,

Ruth
Reply all
Reply to author
Forward
0 new messages