将值从预定义列表链接到数据参数的问题

时间:2019-02-14 17:16:30

标签: javascript arrays jspsych

我正在使用jsPsych库(jsPsych 6.0.5)在javascript中编写任务切换实验。我使用具有刺激属性的预定义列表,但似乎无法将特定值链接到data参数中的变量(数据输出未定义)。

我正在使用for循环将这些值链接到data参数,但这似乎不起作用。在下面的示例中,第一个for循环读取预定义列表的不同列,每行代表一个试验。在第二个for循环中,我尝试将每个试验(行)的这些值输入到test_stimuli的data参数中。

for(this_trial = 0; this_trial < blocks[0].length; this_trial ++){
    curr_trial = blocks[0][this_trial];
    modality[this_trial] = curr_trial[6];
    cresp[this_trial] = curr_trial[10];
    perc_stim[this_trial] = [];
    for(j = 0; j < 4; j++){perc_stim[this_trial][j] = curr_trial[11 + j];};
    probe[this_trial] = curr_trial[15];
    condition[this_trial] = curr_trial[16];
  }

  for (i = 0; i < blocks[0].length; i++) {
    test_stimuli[i] = [{
        image: `<img src="images_a/${perc_stim[i][0]}.bmp" class = "training1"/>`,
        data: {
            correct_response: [cresp[i]],
            modality: modality[i],
            trial_id: 'stim'
        }
    }];
  }

当我将数据参数记录到控制台时,我会得到“未定义”(即使在查看例如cresp数组时它记录了正确的值)。

0 个答案:

没有答案