Skip to content

Instantly share code, notes, and snippets.

@kishiyamat
Last active June 8, 2023 21:11
Show Gist options
  • Save kishiyamat/c438b3dc16c66141e307262f35168db3 to your computer and use it in GitHub Desktop.
Save kishiyamat/c438b3dc16c66141e307262f35168db3 to your computer and use it in GitHub Desktop.
var jsPsych = initJsPsych({
use_webaudio: false,
on_finish: function() {
jsPsych.data.displayData();
}
});
// TODO: timeline_variables は事前に読み込んでいる ことを前提とします。
var list_audio_preload = timeline_variables.map(
function(obj) {return [obj.sound]; }).flat(1);
var preload = {
type: jsPsychPreload, audio: list_audio_preload,
}
var shuffled_list = jsPsych.randomization.shuffle (timeline_variables);
var survey = {
type: jsPsychSurveyText,
questions: [
{prompt: '実験の参加に同意する場合、学籍番号を記入してください (半角英数)'}
]
}
var welcome = {
type: jsPsychHtmlKeyboardResponse,
choices: [' '],
stimulus: `
<p>実験へのご参加ありがとうございます。<br>
この実験では呈示された音声が「う」の音色を「音声として」含んでいるかを判断してもらいます。
例として、「オプド」は「含んでいる」、
「オピド」は「含んでいない」となります。
静かな環境で、可能な場合はイヤホンなどの装着をお願いいたします。
スペースキーで始めます。
</p>
`,
};
var present = {
type: jsPsych,
stimulus: jsPsych.timelineVariable('sound'),
choices: "NO_KEYS",
trial_ends_after_audio: true,
// post_trial_gap: 200, // 最後は不要
};
var fixation = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<div style="font-size:60px;">+</div>',
choices: "NO_KEYS",
trial_duration: 1000,
}
var present = {
type: jsPsychAudioKeyboardResponse,
stimulus: jsPsych.timelineVariable('sound'),
choices: "NO_KEYS",
trial_ends_after_audio: true,
// post_trial_gap: 200, // 最後は不要
};
var question = {
type: jsPsychHtmlButtonResponse,
stimulus: '呈示された音は「う」の音色を含んでいましたか?',
choices: ['はい', 'いいえ'],
data:{
task: 'dupoux',
item_id: jsPsych.timelineVariable('sound'),
}
}
var dupoux = {
timeline: [fixation, present, question],
timeline_variables: shuffled_list
};
var goodbye = {
type: jsPsychHtmlKeyboardResponse,
choices: [' '],
stimulus: `
<p> 実験へのご参加ありがとうございます。
スペースキーで終わります。
</p>
`,
};
var timeline = [preload, survey, welcome, dupoux, goodbye];
jsPsych.run(timeline);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment