-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
207 lines (188 loc) · 6.96 KB
/
index.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!-- Load jsPsych 7.3.1 (last updated: 19/10/1991)-->
<!DOCTYPE html>
<html>
<head>
<!--create title shown in tab; not the same as header on webpage-->
<title>Resting State</title>
<script src="utils/jspsych/jspsych.js"></script>
<!--Load all necessary plugins stored in utils-->
<script src="utils/jspsych/plugin-html-keyboard-response.js"></script>
<script src="utils/jspsych/plugin-browser-check.js"></script>
<script src="utils/jspsych/plugin-html-button-response.js"></script>
<script src="utils/jspsych/plugin-fullscreen.js"></script>
<script src="utils/jspsych/plugin-survey-text.js"></script>
<script src="utils/jspsych/plugin-audio-button-response.js"></script>
<script src="utils/jspsych/plugin-canvas-button-response.js"></script>
<script src="utils/jspsych/plugin-preload.js"></script>
<script src="utils/jspsych/multiple-slider.js"></script>
<script src="utils/jspsych/extension-record-video.js"></script>
<script src="utils/jspsych/plugin-initialize-camera.js"></script>
<!-- Load parameters here (always below the loading of the JsPsych) -->
<script src="RestingState.js"></script>
<link
href="utils/jspsych/jspsych.css"
rel="stylesheet"
type="text/css"
/>
<style>
/* set canvas to be full screen */
.jspsych-content {
max-width: 100%;
}
/*Hide scrollbar while keeping it functional */
body {
overflow-y: scroll;
}
Body::-webkit-scrollbar {
display: none;
}
</style>
</head>
<body></body>
<script>
/* ----------------- Initialize experiment ----------------- */
var timeline = []
var jsPsych = initJsPsych({
extensions: extensions, // This variable comes from RestingState.js
// override_safe_mode: true,
on_finish: function () {
if (raw_data == false) {
jsPsych.data.allData.trials = [clean_data()]
}
// jsPsych.data.displayData("json")
jsPsych.data
.get()
.localSave(
"json",
`${
jsPsych.data.get().values()[0]["participant_id"]
}_RestingState.json`
)
},
})
// Enter fullscreen mode
timeline.push({
type: jsPsychFullscreen,
fullscreen_mode: true,
delay_after: 0,
})
// Webcam initialization (can be activated in RestingStates.js)
if (record_webcam == true) {
timeline.push({
type: jsPsychInitializeCamera,
})
}
// Retrieve and save browser info
var browser_check = {
type: jsPsychBrowserCheck,
data: {
screen: "browser_info",
},
on_finish: function () {
data = jsPsych.data
.get()
.filter({ screen: "browser_info" })
.values()[0]
jsPsych.data.addProperties({
["screen_height"]: data["height"],
["screen_width"]: data["width"],
})
for (var key in data) {
if (
[
"vsync_rate",
"os",
"mobile",
"browser",
"browser_version",
].includes(key)
) {
jsPsych.data.addProperties({
[key]: data[key],
})
}
}
jsPsych.data.addProperties()
},
}
timeline.push(browser_check)
/* ----------------- Session Info ----------------- */
// Participant information
var participant_info = {
type: jsPsychSurveyText,
questions: [
{
prompt: "Enter the participant's ID:",
placeholder: "S00",
name: "Participant_ID",
},
],
data: {
screen: "participant_info",
version: version,
date: new Date().toLocaleDateString("fr-FR"),
time: new Date().toLocaleTimeString("fr-FR"),
},
on_finish: function () {
jsPsych.data.addProperties({
participant_id: jsPsych.data.get().last().values()[0][
"response"
]["Participant_ID"],
})
},
}
timeline.push(participant_info)
/* ----------------- Preloading ----------------- */
// Preload audio variables
var beep = ["utils/beep.mp3"]
timeline.push({
type: jsPsychPreload,
auto_preload: true,
audio: beep,
})
/* ----------------- Experiment Variables ----------------- */
// Task ============================================================
// Instructions
timeline.push(RS_instructions)
// Create blank grey screen just before rest period
timeline.push(RS_buffer)
// Create blank grey screen for resting state
timeline.push(RS_task)
// Play beep
timeline.push(RS_beep)
// Add debriefing questionnaire
timeline.push(RS_questionnaire)
// =================================================================
// Exit fullscreen mode
timeline.push({
type: jsPsychFullscreen,
fullscreen_mode: false,
})
/* ----------------- Run the timeline ----------------- */
jsPsych.run(timeline)
function clean_data() {
var info = jsPsych.data
.get()
.filter({ screen: "participant_info" })
.values()[0]
var items = jsPsych.data
.get()
.filter({ screen: "questionnaire" })
.values()[0]
items["response"] = JSON.parse(items["response"])
items["question_order"] = JSON.parse(items["question_order"])
items["duration"] = jsPsych.data
.get()
.filter({ screen: "resting" })
.values()[0]["duration"]
if (record_webcam == true) {
items["video"] = jsPsych.data
.get()
.filter({ screen: "resting" })
.values()[0]["record_video_data"]
}
var out = Object.assign({}, info, items)
return out
}
</script>
</html>