Progress bar / trial counter for nested timeline?

432 views
Skip to first unread message

jcrd...@gmail.com

unread,
Jul 30, 2016, 6:48:38 PM7/30/16
to jsPsych
Hi,

I'm very new to jsPsych, but from what I see already I want to congratulate you for a very easy to use, great piece of software that works.

I have a super simple experiment, consisting of an instruction screen, a short movie, another instruction screen, then 80 trials of a memory task (as a nested timeline), and finally a thank you screen.

I would like to display a progress bar during the memory experiment. It seems that the automatic progress bar will not work, given the structure of my experiment with the nested timeline.

Is there any quick and easy thing I could do, for instance displaying "Trial ??/80" in the prompt of each trial during the memory experiment? I.e., is there any way to access the current state of the nested timeline and somehow display this in the prompt for each trial? This would give the subjects an idea of how much longer they have to go, should they get bored...

Another question: would it be detrimental to save the data to a file after each trial, to ensure that no work gets lost should the subject accidentally close their browser or something?

Let me know if you need me to send code so as to be better able to respond.

Thank you so much for any advice!
- Julien

Josh de Leeuw

unread,
Jul 31, 2016, 2:21:53 PM7/31/16
to jcrd...@gmail.com, jsPsych
For the trial ? / 80, you can just use the prompt parameter. For example, if you are building the timeline in a loop:

for(var i=0;i<80;i++){
  timeline.push({
    prompt: "Trial "+i+"/80",
    // other params
  })
}

Saving data after each trial is a good idea. You can use the on_data_update callback in jsPsych.init to specify a function to run after every data write. http://docs.jspsych.org/core_library/jspsych-core/#jspsychinit

jsPsych.init({
  timeline: timeline,
  on_data_update: function(data){ console.log(JSON.stringify(data)); }
});

--
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/3b1ce840-06b9-4c11-b459-da5ff7e1a6de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Garret O'Connell

unread,
Dec 8, 2016, 3:56:13 AM12/8/16
to jsPsych, jcrd...@gmail.com
Hi Josh,

I think I'm having a related problem with the progress bar and nested timelines. The progress bar only shows once for the first block of looped trials in my timeline. Is there anyway to get it to show at beginning of each new timeline component? I believe from description it should, as they are all at the same root level. Below is my script, where it would show only in the first of any of the loop chunks, and never again after. 

Thanks! 
Garret

/* counterbalance */
var blocks = [[instructions,soc_loop_chunk],[more_instructions,temp_loop_chunk]];
var random_order = jsPsych.randomization.shuffle(blocks);
var experiment = [];
experiment = experiment.concat(random_order[0],random_order[1]);
var timeline = [];
/* timeline */
timeline.push(welcome_loop_chunk);
for (i = 0; i < experiment.length; i++){
timeline.push(experiment[i]);
}
timeline.push(debrief);
/* start the experiment */    
jsPsych.init({
experiment_structure: timeline,
show_progress_bar: true,
});



Josh de Leeuw

unread,
Dec 8, 2016, 3:15:56 PM12/8/16
to Garret O'Connell, jsPsych, jcrd...@gmail.com
The progress bar is kind of messy. I originally built it before there were any nested, looping, or conditional structures. It was easy to make it automated in those cases. Now it's substantially more difficult. The intended behavior right now is that the progress bar updates after each root-level component is completed. In your example, it looks like you have the welcome_loop_chunk plus each item in experiment and the debrief. The progress bar should update after each of those. If it's not, then there's a bug.

I am thinking about redesigning the progress bar so that it is manually updated and that you could do something like this:

jsPsych.init({
  progress_bar: 70, // 70 ticks in the progress bar
});

var trial = {
  on_finish: function(){
     jsPsych.incrementProgressBar(3); // fills up 3/70ths of the progress bar.
  }
}

I am guessing that the additional control will be worth the cost of manually setting the increments. But I'd love to hear what anyone thinks about this idea and any suggested approaches.

--
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.

pavlo.ba...@gmail.com

unread,
Jan 23, 2017, 7:50:27 AM1/23/17
to jsPsych, gar...@hotmail.com, jcrd...@gmail.com
I would very much appreciate such functionality. I lack the ability to move progress bar with each stimulus. Thank you!
Reply all
Reply to author
Forward
0 new messages