Last active
September 25, 2022 07:06
-
-
Save kishiyamat/0e53281b3e335ada094f9ef0b3ae6928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axb_instructions_practice = { | |
type: 'html-keyboard-response', | |
choices: [' '], | |
stimulus: ` | |
<p> この弁別実験の各課題では a -> x -> b という順序で 3つの音を聞いてもらい、 | |
2つ目の音(x)が似ているのが | |
(a)1つ目の音か (b)3つ目の音か を a か b のキーで答えてもらいます。 | |
静かな環境で、可能な場合はイヤホンなどの装着をお願いいたします。 | |
スペースキーを押すと練習課題を1問呈示いたします。 | |
</p> | |
`, | |
}; | |
var fixation = { | |
type: 'html-keyboard-response', | |
stimulus: '<div style="font-size:60px;">+</div>', | |
choices: jsPsych.NO_KEYS, | |
trial_duration: 1000, | |
} | |
var trial_a = { | |
type: 'audio-keyboard-response', | |
stimulus: jsPsych.timelineVariable('a'), | |
choices: jsPsych.NO_KEYS, | |
trial_ends_after_audio: true, | |
post_trial_gap: 200, | |
}; | |
var trial_x = { | |
type: 'audio-keyboard-response', | |
stimulus: jsPsych.timelineVariable('x'), | |
choices: jsPsych.NO_KEYS, | |
trial_ends_after_audio: true, | |
post_trial_gap: 200, | |
}; | |
var trial_b = { | |
type: 'audio-keyboard-response', | |
stimulus: jsPsych.timelineVariable('b'), | |
choices: jsPsych.NO_KEYS, | |
trial_ends_after_audio: true, | |
}; | |
var axb_question = { | |
type: 'html-keyboard-response', | |
stimulus: '音声呈示は a -> x -> b の順でした。', | |
choices: ['a', 'b'], | |
prompt: "<p> 2つ目の音(x)は1つ目の音(a)と3つ目の音(b)のどちらに似ていますか。</p>", | |
data: { | |
task: 'axb', // production--perception-categorization | |
type: jsPsych.timelineVariable('type'), // filler--target | |
item_id: jsPsych.timelineVariable('item_id'), | |
correct: jsPsych.timelineVariable('correct'), | |
}, | |
on_finish: function (data) { | |
data.is_correct = jsPsych.pluginAPI.compareKeys(data.response, data.correct); | |
}, | |
}; | |
var feedback = { | |
type: 'html-keyboard-response', | |
stimulus: function () { | |
let last_trial_correct = jsPsych.data.get().last(1).values()[0].is_correct; | |
if (last_trial_correct) { return "<p>正解です。</p>"; } | |
else { return "<p>不正解です。</p>"; } | |
}, | |
choices: [' '], | |
prompt: "次の問題に進む場合はスペースキーを押してください。", | |
}; | |
var list_audio_preload = ['espo-1.wav', 'esupo-2.wav', 'esupo-3.wav'] | |
var preload = { | |
type: 'preload', | |
audio: list_audio_preload, | |
} | |
var timeline_variables = [ | |
{ | |
"a": "espo-1.wav", | |
"x": "esupo-2.wav", | |
"b": "esupo-3.wav", | |
"type": "target", | |
"item_id": 1, | |
"correct": "b" | |
}, | |
{ | |
"a": "esupo-3.wav", | |
"x": "esupo-2.wav", | |
"b": "espo-1.wav", | |
"type": "filler", | |
"item_id": 2, | |
"correct": "a" | |
} | |
] | |
// Shuffle an array, no repeats | |
var timeline_variables = jsPsych.randomization.repeat(timeline_variables, 1); | |
var axb_trial = { | |
timeline: [fixation, trial_a, trial_x, trial_b, axb_question, feedback], | |
timeline_variables: timeline_variables | |
}; | |
// TIMELINE | |
var timeline = []; | |
timeline.push(preload); | |
timeline.push(axb_instructions_practice); | |
timeline.push(axb_trial); | |
jsPsych.init({ | |
timeline: timeline, | |
on_finish: function() { | |
jsPsych.data.displayData(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment