mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
79 lines
2.3 KiB
HTML
79 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../jspsych.js"></script>
|
|
<script src="../plugins/jspsych-image-keyboard-response.js"></script>
|
|
<link rel="stylesheet" href="../css/jspsych.css">
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
|
|
// If render_on_canvas is false, the images will be shown via an <img> rather than <canvas> element.
|
|
// In some browsers, the first time the images are shown, the <img> method (render_on_canvas: false) will produce a brief
|
|
// blank screen (white flash) between images that are presented consecutively with no post_trial_gap between them.
|
|
var trial = {
|
|
type: 'image-keyboard-response',
|
|
stimulus: jsPsych.timelineVariable('stim'),
|
|
trial_duration: 300,
|
|
choices: jsPsych.NO_KEYS,
|
|
prompt: '<p>Watch the faces.</p>',
|
|
stimulus_width: 400,
|
|
maintain_aspect_ratio: true,
|
|
post_trial_gap: 0,
|
|
//render_on_canvas: false
|
|
}
|
|
|
|
var trial_proc = {
|
|
timeline: [trial],
|
|
timeline_variables: [
|
|
{stim: 'img/happy_face_1.jpg'},
|
|
{stim: 'img/happy_face_2.jpg'},
|
|
{stim: 'img/happy_face_3.jpg'},
|
|
{stim: 'img/happy_face_4.jpg'}
|
|
],
|
|
repetitions: 3
|
|
}
|
|
|
|
var trial_1 = {
|
|
type: 'image-keyboard-response',
|
|
stimulus: 'img/happy_face_1.jpg',
|
|
choices: ['y','n'],
|
|
prompt: '<p>Have you seen this face before? Y or N.</p>'
|
|
}
|
|
|
|
var trial_2 = {
|
|
type: 'image-keyboard-response',
|
|
stimulus: 'img/happy_face_2.jpg',
|
|
choices: ['y','n'],
|
|
trial_duration: 5000,
|
|
prompt: '<p>Have you seen this face before? Y or N. (5s time limit).</p>'
|
|
}
|
|
|
|
var trial_3 = {
|
|
type: 'image-keyboard-response',
|
|
stimulus: 'img/happy_face_3.jpg',
|
|
choices: jsPsych.NO_KEYS,
|
|
trial_duration: 2000,
|
|
prompt: '<p>No response allowed. 2s wait.</p>'
|
|
}
|
|
|
|
var trial_4 = {
|
|
type: 'image-keyboard-response',
|
|
stimulus: 'img/happy_face_4.jpg',
|
|
choices: ['y','n'],
|
|
stimulus_width: 400,
|
|
maintain_aspect_ratio: false,
|
|
prompt: '<p>Have you seen this face before? Y or N.</p><p>(Stimulus_width set to a smaller value and maintain_aspect_ratio set to false.)</p>'
|
|
}
|
|
|
|
jsPsych.init({
|
|
timeline: [trial_proc, trial_1, trial_2, trial_3, trial_4],
|
|
preload_images: ['img/happy_face_1.jpg','img/happy_face_2.jpg','img/happy_face_3.jpg','img/happy_face_4.jpg'],
|
|
on_finish: function() {
|
|
jsPsych.data.displayData();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</html>
|