-
Notifications
You must be signed in to change notification settings - Fork 0
/
color-shape.html
134 lines (119 loc) · 4.3 KB
/
color-shape.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<title>Color Shape</title>
<script src="./dist/jspsych.js"></script>
<script src="./dist/plugin-preload.js"></script>
<script src="./dist/plugin-html-keyboard-response.js"></script>
<script src="./dist/plugin-html-button-response.js"></script>
<script src="./dist/plugin-image-keyboard-response.js"></script>
<script src="./dist/plugin-survey-text.js"></script>
<script src="./dist/plugin-fullscreen.js"></script>
<script src="./config/variables.js"></script>
<script src="./config/en.js"></script> <!-- Use en.js for English instructions, jp.js for Japanese -->
<link href="./dist/jspsych.css" rel="stylesheet" type="text/css" />
<link href="./style/style.css" rel="stylesheet" type="text/css" />
</head>
<body></body>
<script>
const jsPsych = initJsPsych({
on_finish: function() {
jsPsych.data.displayData(); // for debugging
}
});
let timeline = [];
const images = color_shape.images;
const cues = color_shape.cue;
const preload = {
type: jsPsychPreload,
images: images
};
timeline.push(preload);
const enter_fullscreen = {
type: jsPsychFullscreen,
fullscreen_mode: true,
message: lang.fullscreen,
button_label: lang.utils.next
}
const welcome = {
type: jsPsychHtmlButtonResponse,
stimulus: lang.welcome,
choices: [lang.utils.next]
};
const instructions = {
type: jsPsychHtmlButtonResponse,
stimulus: lang.instructions.color_shape,
choices: [lang.utils.next]
};
const beginTask = {
type: jsPsychHtmlButtonResponse,
stimulus: lang.begin,
choices: [lang.utils.next],
post_trial_gap: interstimuli_interval.instructions
};
timeline.push(enter_fullscreen, welcome, instructions, beginTask);
const trials = [
{ stimulus: images[0], cue: cues[0], correct_response: "1" },
{ stimulus: images[1], cue: cues[0], correct_response: "2" },
{ stimulus: images[2], cue: cues[1], correct_response: "1" },
{ stimulus: images[3], cue: cues[1], correct_response: "2" }
];
const choices = color_shape.choices.toString().split(',');
const cue_and_blank_procedure = {
timeline: [
{
type: jsPsychHtmlKeyboardResponse,
stimulus: function() {
const cue = jsPsych.timelineVariable('cue');
return cue === cues[0] ? `<p class='text'>${cues[0]}</p>` : `<p class='text'>${cues[1]}</p>`;
},
choices: "NO_KEYS",
trial_duration: color_shape.cue_duration,
post_trial_gap: color_shape.cue_interstimuli_interval
},
{
type: jsPsychImageKeyboardResponse,
stimulus: jsPsych.timelineVariable('stimulus'),
choices: choices,
trial_duration: color_shape.trial_duration,
post_trial_gap: color_shape.interstimuli_interval,
data: {
cue: jsPsych.timelineVariable('cue'),
task: 'response',
correct_response: jsPsych.timelineVariable('correct_response')
},
on_finish: function(data){
data.correct = jsPsych.pluginAPI.compareKeys(data.response, data.correct_response);
}
}
],
timeline_variables: trials,
randomize_order: true,
repetitions: color_shape.trial_length
};
timeline.push(cue_and_blank_procedure);
const end = {
type: jsPsychHtmlButtonResponse,
stimulus: lang.end,
choices: [lang.utils.finish]
};
const exit_fullscreen = {
type: jsPsychFullscreen,
fullscreen_mode: false,
delay_after: 0
}
timeline.push(end, exit_fullscreen);
const debrief_block = {
type: jsPsychHtmlKeyboardResponse,
stimulus: function() {
const trials = jsPsych.data.get().filter({task: 'response'});
const correct_trials = trials.filter({correct: true});
const accuracy = Math.round(correct_trials.count() / trials.count() * 100);
// var rt = Math.round(correct_trials.select('rt').mean());
return feedback(accuracy)
}
};
timeline.push(debrief_block);
jsPsych.run(timeline)
</script>
</html>