Skip to content

Trial duration conditioning on the type of image #785

Discussion options

You must be logged in to vote

Try something like this. The second parameter of timelineVariable() should be true when used in a function.

// display image
var pic_scr = {
  type: "image-keyboard-response",
  stimulus: jsPsych.timelineVariable("face"),
  data: { screen: "picture" },
  trial_duration: function() {
    const imagePath = jsPsych.timelineVariable('face', true)
    if (imagePath.includes('Cat')) {
      return 200
    } else {
      return 700;
    }
  },
  response_ends_trial: false
};

// determine the trial sequence
var VMRT_task = {
  timeline: [focus_pt, pic_scr, blank1_scr],
  timeline_variables: [
    { face: "img/Cat_1.jpg" },
    { face: "img/Cat_2.jpg" },
    { face: "img/Cat_3.jpg" },
    { face: "…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wangzhuoranivy
Comment options

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