function present_sequence(trial) {

      // hide elements
      toggle_elements('hide');

      // define epoch time
      const epoch = trial.tile_duration + trial.iti_duration;

      // define presentation event times
      trial.sequence.forEach((j, i) => {

        // highlight tile
        jsPsych.pluginAPI.setTimeout(function() {
          display_element.querySelector('#tile-' + j).setAttribute('status', 'fill');
        }, trial.stimulus_duration + epoch * i);

        // clear tile
        jsPsych.pluginAPI.setTimeout(function() {
          display_element.querySelector('#tile-' + j).setAttribute('status', '');
        }, trial.stimulus_duration + epoch * i + trial.tile_duration);

      });

      // start response phase
      jsPsych.pluginAPI.setTimeout(function() {

        // unhide elements
        toggle_elements('');

        // record start time
        start_time = performance.now();

        // end trial if time limit is set
        if (trial.response_duration !== null) {
          jsPsych.pluginAPI.setTimeout(function() {
            end_trial();
          }, trial.response_duration);
        }

      }, trial.stimulus_duration + epoch * trial.sequence.length);

    }
// function to display sequence to participant

function to display sequence to participant
function to display sequence to participant
function present_sequence(trial) {
      toggle_elements('hide');
      const epoch = trial.tile_duration + trial.iti_duration;
      trial.sequence.forEach((j, i) => {
        jsPsych.pluginAPI.setTimeout(function() {
          display_element.querySelector('#tile-' + j).setAttribute('status', 'fill');
        }, trial.stimulus_duration + epoch * i);
        jsPsych.pluginAPI.setTimeout(function() {
          display_element.querySelector('#tile-' + j).setAttribute('status', '');
        }, trial.stimulus_duration + epoch * i + trial.tile_duration);
      });
      jsPsych.pluginAPI.setTimeout(function() {
        toggle_elements('');
        start_time = performance.now();
        if (trial.response_duration !== null) {
          jsPsych.pluginAPI.setTimeout(function() {
            end_trial();
          }, trial.response_duration);
        }
      }, trial.stimulus_duration + epoch * trial.sequence.length);
    }
function present_sequence ( trial ) { toggle_elements ( 'hide' ) ; const epoch = trial . tile_duration + trial . iti_duration ; trial . sequence . forEach ( ( j , i ) => { jsPsych . pluginAPI . setTimeout ( function ( ) { display_element . querySelector ( '#tile-' + j ) . setAttribute ( 'status' , 'fill' ) ; } , trial . stimulus_duration + epoch * i ) ; jsPsych . pluginAPI . setTimeout ( function ( ) { display_element . querySelector ( '#tile-' + j ) . setAttribute ( 'status' , '' ) ; } , trial . stimulus_duration + epoch * i + trial . tile_duration ) ; } ) ; jsPsych . pluginAPI . setTimeout ( function ( ) { toggle_elements ( '' ) ; start_time = performance . now ( ) ; if ( trial . response_duration !== null ) { jsPsych . pluginAPI . setTimeout ( function ( ) { end_trial ( ) ; } , trial . response_duration ) ; } } , trial . stimulus_duration + epoch * trial . sequence . length ) ; }
function to display sequence to participant
function to display sequence to participant
// hide elements
 // define epoch time
 // define presentation event times
 // highlight tile
 // clear tile
 // start response phase
 // unhide elements
 // record start time
 // end trial if time limit is set
