Javascript 如何使用JsPsych在nback任务中提供一次又一次的试用反馈
我正在建立一个nback任务,除了在实践测试期间的反馈之外,我已经完成了所有工作。目前,我只得到“不正确”弹出,但它总是发生,无论审判条件。 我希望时间线看起来像这样: 试用->反馈->试用->反馈等 细分:参与者看到刺激,如果有匹配,要么反应,要么不反应。如果当前形状与他们刚才看到的形状匹配,那么他们按空格键,如果不匹配,他们什么也不做。因此有4种可能的结果:正确的回答1)形状匹配+按键,2)形状不匹配+无按键,错误的回答3)形状匹配+无按键,4)形状不匹配+按键 任何建议都将受到极大欢迎Javascript 如何使用JsPsych在nback任务中提供一次又一次的试用反馈,javascript,experimental-design,jspsych,Javascript,Experimental Design,Jspsych,我正在建立一个nback任务,除了在实践测试期间的反馈之外,我已经完成了所有工作。目前,我只得到“不正确”弹出,但它总是发生,无论审判条件。 我希望时间线看起来像这样: 试用->反馈->试用->反馈等 细分:参与者看到刺激,如果有匹配,要么反应,要么不反应。如果当前形状与他们刚才看到的形状匹配,那么他们按空格键,如果不匹配,他们什么也不做。因此有4种可能的结果:正确的回答1)形状匹配+按键,2)形状不匹配+无按键,错误的回答3)形状匹配+无按键,4)形状不匹配+按键 任何建议都将受到极大欢迎 v
var timeline = [];
var sequence = [];
var feedback = {
type:'html-keyboard-response',
stimulus: function(){
var trial_accuracy = jsPsych.data.get().last(1).values()[0];
if(jsPsych.key_press== 32 & jsPsych.timelineVariable('match', true)){
return "Correct!"
}if(jsPsych.key_press== -1 & jsPsych.timelineVariable('match', false)) {
return "Correct!"
}else {
return "Incorrect"
}
},
choices:jsPsych.NO_KEYS,
trial_duration:500
};
var practice_1 = {
stimulus: "<p>For this practice block, you will need to respond whether the shape you currently see the same shape as the <strong>1</strong> before.</p>"+
"If the shape matches the previous shape, press the <strong>spacebar</strong>, and if it doesn't match, do nothing until the next shape appears.</p>"+
"<p> Press the <strong>spacebar</strong> to practice.",
type: "html-keyboard-response",
post_trial_gap: 750,
response_ends_trial: true,
choices: [32]
}
timeline.push(practice_1);
var practice_n1 = {
type: 'image-keyboard-response',
stimulus_height: 300,
stimulus_width: 300,
stimulus: function(){
if(sequence.length < 1){
var shape = jsPsych.randomization.sampleWithoutReplacement(n_back_set, 1)[0]
} else{
if(jsPsych.timelineVariable('match', true)==true){
var shape = sequence[sequence.length - 1]
} else {
var possible_shape = jsPsych.randomization.sampleWithoutReplacement(n_back_set, 1);
if(possible_shape[0] != sequence[sequence.length-1]){ /*This is to disreguard the first two trails*/
var shape = possible_shape[0];
} else {
var shape = possible_shape[1];
}
}
}
sequence.push(shape);
return shape
},
choices:[32],
trial_duration: 500,
response_ends_trial: false,
post_trial_gap: 2500,
data: {block: 'practice'}
}
practice_n1_variables = [
{match: true},
{match:false}
]
practice_n1_sequence = {
timeline: [practice_n1,feedback],
timeline_variables: practice_n1_variables,
sample:{
type:'with-replacement',
size: 10,/*this changes depending on N of block*/
weights: [7,3]
}
}
timeline.push(practice_n1_sequence);
var timeline=[];
var序列=[];
var反馈={
类型:'html-keyboard-response',
刺激:功能(){
var try_accurity=jsPsych.data.get().last(1.values()[0];
if(jsPsych.key_press==32&jsPsych.timelineVariable('match',true)){
返回“正确!”
}if(jsPsych.key_press==-1&jsPsych.timelineVariable('match',false)){
返回“正确!”
}否则{
返回“不正确”
}
},
选项:jsPsych.NO_key,
审讯时间:500
};
var实践_1={
刺激:对于此练习块,您需要回答当前看到的形状是否与之前的1相同。“+
如果形状与上一个形状匹配,请按空格键,如果不匹配,请在下一个形状出现之前不要执行任何操作。+
“按空格键进行练习。”,
键入:“html键盘响应”,
审判后差距:750,
回答(结束)(审判):对,,
选择:[32]
}
时间线。推送(练习1);
var实践_n1={
键入:“图像键盘响应”,
高度:300,
宽度:300,
刺激:功能(){
if(sequence.length<1){
var shape=jsPsych.随机化.无替换的样本(n\u back\u set,1)[0]
}否则{
if(jsPsych.timelineVariable('match',true)=true){
变量形状=序列[sequence.length-1]
}否则{
变量可能形状=jsPsych.随机化。无替换的样本(n\u back\u set,1);
如果(可能的_-shape[0]!=sequence[sequence.length-1]){/*这将取消前两条轨迹的保护*/
var shape=可能的_形[0];
}否则{
var形状=可能的_形状[1];
}
}
}
顺序。推(形);
返回形状
},
选择:[32],
审讯时间:500,,
回答(结束)(审判):错,,
审判后差距:2500,
数据:{block:'practice'}
}
实践1\u变量=[
{match:true},
{match:false}
]
实践1\u顺序={
时间线:[练习,反馈],
时间线变量:实践变量,
样本:{
类型:'with-replacement',
大小:10,/*这取决于块的N*/
权重:[7,3]
}
}
时间线推送(练习顺序);