-
Notifications
You must be signed in to change notification settings - Fork 0
/
wheel03.html
387 lines (353 loc) · 17.1 KB
/
wheel03.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<!DOCTYPE html>
<html lang = 'en'>
<head>
<title>Experiment - Scene similarity</title>
<style>
</style>
<script src='jspsych-6.2.0/jspsych.js'></script>
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es5.min.js"></script>
<script src="js_library/modernizr-custom.js"></script>
<script src="js_library/underscore-min.js"></script>
<script src="js_library/factorial_noRandom.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-fullscreen.js"></script>
<script src='jspsych-6.2.0/plugins/jspsych-html-likert.js'></script>
<script src="jspsych-6.2.0/plugins/jspsych-external-html.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-html-button-response.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-survey-html-form.js"></script>
<link href='jspsych-6.2.0/css/jspsych.css' rel='stylesheet' type="text/css">
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-database.js"></script>
</head>
<body></body>
<script type="text/javascript">
// Firebase set up
var firebaseConfig = {
apiKey: "AIzaSyCCfqbctlvGARj_IPbIOVAXlI5nv7gE-78",
authDomain: "scenewheel-simjudge.firebaseapp.com",
databaseURL: "https://scenewheel-simjudge-default-rtdb.firebaseio.com",
projectId: "scenewheel-simjudge",
storageBucket: "scenewheel-simjudge.appspot.com",
messagingSenderId: "657235385952",
appId: "1:657235385952:web:0d6e1eb7021d80d58f2d05"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// login anonymous user
firebase.auth().signInAnonymously().catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
});
</script>
<script>
// * Participation IDs * //
var turkInfo = jsPsych.turk.turkInfo();
// * browser info * //
var browser = bowser.getParser(window.navigator.userAgent);
var browser_info = browser.getBrowser();
// * image host * //
var img_host = 'https://macklab.dev/resources/sceneWheel/validation_5radii/';
// * wheel info * //
var main_wheel = '03';
var prac_wheel = '00';
// * condition set up * //
var p_cond = [ // pairs covering the entire range of px-correlation
{radius:'02', stim_list:[0 ,0 ]},
{radius:'02', stim_list:[240,270]},
{radius:'04', stim_list:[90 ,120]},
{radius:'04', stim_list:[90 ,210]},
{radius:'08', stim_list:[60 ,120]},
{radius:'08', stim_list:[0 ,300]},
{radius:'16', stim_list:[240,270]},
{radius:'16', stim_list:[240,330]},
{radius:'32', stim_list:[0 ,180]},
{radius:'32', stim_list:[90 ,210]}
];
var left_item = _.shuffle(Array(Math.floor(p_cond.length/2)).fill(0).concat(Array(Math.ceil(p_cond.length/2)).fill(1)));
for (var i=0; i<p_cond.length; i++){
p_cond[i].left_item_idx = left_item[i];
p_cond[i].stim_path_left = [
img_host+'Wheel'+prac_wheel+'/wheel'+prac_wheel+'_r'+p_cond[i].radius+'/'+
("00000"+p_cond[i].stim_list[left_item[i]]).slice(-6)+'.webp'
];
p_cond[i].stim_path_right = [
img_host+'Wheel'+prac_wheel+'/wheel'+prac_wheel+'_r'+p_cond[i].radius+'/'+
("00000"+p_cond[i].stim_list[(left_item[i]+1)%2]).slice(-6)+'.webp'
];
};
// -- main condition -- //
var pair = []; // prepare all possible pairs
var img_num = _.range(0,360,30);
var identical_pair = _.sample(img_num,2); // catch trials
pair.push([identical_pair[0],identical_pair[0]]);
pair.push([identical_pair[1],identical_pair[1]]);
for (var i = 0; i < img_num.length - 1; i++) {
for (var j = i + 1; j < img_num.length; j++) {
pair.push([img_num[i], img_num[j]]);
}
};
var e_factors = {
radius: ['02', '04', '08', '16', '32'],
stim_list: pair
};
var e_cond = factorial_noRandom(e_factors);
// select one to be preseted left
var left_item = _.shuffle(Array(e_cond.length/2).fill(0).concat(Array(e_cond.length/2).fill(1)));
// specify path
for (var i=0; i<e_cond.length; i++){
e_cond[i].left_item_idx = left_item[i];
e_cond[i].stim_path_left = [
img_host+'Wheel'+main_wheel+'/wheel'+main_wheel+'_r'+e_cond[i].radius+'/'+
("00000"+e_cond[i].stim_list[left_item[i]]).slice(-6)+'.webp'
];
e_cond[i].stim_path_right = [
img_host+'Wheel'+main_wheel+'/wheel'+main_wheel+'_r'+e_cond[i].radius+'/'+
("00000"+e_cond[i].stim_list[(left_item[i]+1)%2]).slice(-6)+'.webp'
];
};
// divide into 5 blocks
var n_block = 5;
var e_cond = _.chunk(_.shuffle(e_cond), e_cond.length/n_block);
// * preload images *//
var stimuli = [];
for (i=0; i <p_cond.length; i++){
stimuli.push(
p_cond[i].stim_path_left,
p_cond[i].stim_path_right,
);
}
for (b=0; b<n_block; b++){
for (i=0; i <e_cond[b].length; i++){
stimuli.push(
e_cond[b][i].stim_path_left,
e_cond[b][i].stim_path_right,
);
};
};
// ************** Display set up *************** //
// * Instruction * //
var instruction1 = {
type: 'html-button-response',
stimulus: '<p style="color: black; font-size: 20px;">'+
'<b>Welcome to the experiment!</b><br><br>'+
'In this experiment, you will be asked to judge the similarity of scene image pairs.<br>'+
'Carefully look at the images and rate how similar they look to each other.<br>'+
'Click the Next button to start the practice block. There will be '+p_cond.length+' trials.</p>',
choices: ['Start Practice'],
data: {disp_type: 'instrcution-practice'}
};
var n_trials = _.flatten(e_cond).length;
var instruction2 = {
type: 'html-button-response',
stimulus: '<p style="color: black; font-size: 20px;">'+
"Practice trials are done. Now let's move onto the main session.<br><br>"+
'In the main session, you will perform the same task.<br>'+
'There will be '+n_trials+' trials, and '+(n_block-1)+' breaks will be given.</p>',
choices: ['Start Main'],
data: {disp_type: 'instruction-parctice'}
};
var test_break = {
type: 'html-button-response',
stimulus: '<p style="color: black; font-size: 20px;">'+
'Take a break, and press the button to start again.</p>',
choices: ['Start'],
data: {disp_type: 'instruction-break'}
};
// * Trial composition * //
var scale = [
"<b>0</b><br>Low similarity",
"<b>1</b>",
"<b>2</b>",
"<b>3</b>",
"<b>4</b>",
"<b>5</b><br>High similarity"
];
var pair_judge ={
type: 'html-likert',
questions: [{
name: 'thisPair',
stimulus_L: jsPsych.timelineVariable('stim_path_left'),
stimulus_R: jsPsych.timelineVariable('stim_path_right'),
labels: scale,
required: true
}],
scale_width: 500,
data: {
disp_type: 'likert_display',
radius: jsPsych.timelineVariable('radius'),
pair: jsPsych.timelineVariable('stim_list'),
},
on_finish: function() {
// progress bar
var curr_progress_bar_value = jsPsych.getProgressBarCompleted();
jsPsych.setProgressBar(curr_progress_bar_value + (1/n_trials));
}
}
var judgment_prac = {
timeline: [pair_judge],
timeline_variables: p_cond,
randomize_order: true
}
var judgment_main0 = {
timeline: [pair_judge],
timeline_variables: e_cond[0],
randomize_order: true
}
var judgment_main1 = {
timeline: [pair_judge],
timeline_variables: e_cond[1],
randomize_order: true
}
var judgment_main2 = {
timeline: [pair_judge],
timeline_variables: e_cond[2],
randomize_order: true
}
var judgment_main3 = {
timeline: [pair_judge],
timeline_variables: e_cond[3],
randomize_order: true
}
var judgment_main4 = {
timeline: [pair_judge],
timeline_variables: e_cond[4],
randomize_order: true
}
// * demographic page * //
// definiting response scales that can be used.
var gender_options = ['Male', 'Female', 'Other'];
var handed_option = ['Right', 'Left'];
var page_2_options = ["Strongly Disagree", "Disagree", "Somewhat Disagree", "Neural", "Somewhat Agree", "Agree", "Strongly Agree"];
var dem_info = {
type: 'survey-html-form',
preamble: '<p><b>Task is done! Now we would like to collect the basic information below.</b></p>',
html: '<p style="font-size:12pt;"> Gender: '+
'<input name="gender" type="radio" value="male" /><label for="male">Male</label>'+
'<input name="gender" type="radio" value="female" /><label for="female">Female</label>'+
'<input name="gender" type="radio" value="other" /><label for="other">Other</label></br>'+
// age
'Age: <input name="age" type="text"/></br>'+
// handedness
'Handedness: '+
'<input name="hand" type="radio" value="right" /><label for="right">Right</label>'+
'<input name="hand" type="radio" value="left" /><label for="left">Left</label></br></br>'+
'Please respond to the following quetions by checking "Yes" or "No": </br>'+
// lenses
'</br>Do you wear corrective lenses?: '+
'<input name="lense" type="radio" value="yes" /><label for="yes">Yes</label>'+
'<input name="lense" type="radio" value="no" /><label for="no">No</label>'+
'</br>If yes, specify glasses or contacts: <input name="lensetype" type="text" /></br>'+
// hearing aids
'</br>Do you use hearing aid?: '+
'<input name="hear" type="radio" value="yes" /><label for="yes">Yes</label>'+
'<input name="hear" type="radio" value="no" /><label for="no">No</label>'+
'</br>If yes, please specify what kinds: <input name="hearaidtype" type="text" /></br>'+
// brain malfunction
'</br>Do you have any known brain malfunctions?: '+
'<input name="brain" type="radio" value="yes" /><label for="yes">Yes</label>'+
'<input name="brain" type="radio" value="no" /><label for="no">No</label>'+
'</br>If yes, please specify type and location: <input name="brainmaltype" type="text" /></br>'+
// color blindness
'</br>Do you experience color blindness?: '+
'<input name="color" type="radio" value="yes" /><label for="yes">Yes</label>'+
'<input name="color" type="radio" value="no" /><label for="no">No</label>'+
// neurological conditions
'</br>Do you have (or have you had) any neurological conditions?: '+
'<input name="neuro" type="radio" value="yes" /><label for="yes">Yes</label>'+
'<input name="neuro" type="radio" value="no" /><label for="no">No</label></br></p>',
data: {
disp_type: 'demographic_info'
}
}
// * save data * //
var save_data = {
type: 'html-keyboard-response',
stimulus: '<p>We are saving your data, please stay on this page.</p>',
choices: jsPsych.NO_KEYS,
trial_duration: 3000,
data: { // create confirmation code with data saving
conf_code: Math.floor(1000 + Math.random() * 9000)
},
on_finish: function(){
// get data values
var data = {experiment:"sceneWheel_similarityJudgment",
repo:"sceneWheel_similarityJudgment",
turkID: turkInfo,
wheel_info:[main_wheel, prac_wheel],
data:jsPsych.data.get().values(),
browser_info:browser_info,
interaction_data:jsPsych.data.getInteractionData().values(),
exp_condition:e_cond}
// send data to savejs
var xhr = new XMLHttpRequest();
xhr.open('POST','https://macklab-savejs.netlify.app/api/savejs');
xhr.setRequestHeader('Content-Type','application/json');
xhr.onload = function(){
if(xhr.status==200){
var response=JSON.parse(xhr.responseText);
console.log(response.success);
}
};
xhr.send(JSON.stringify(data));
// send data to firebase
var tmp = new Uint32Array(1);
tmp = window.crypto.getRandomValues(tmp)
var dbpath = firebase.auth().currentUser.uid+'/'+tmp;
firebase.database().ref(dbpath).set({
experiment:"sceneWheel_similarityJudgment",
repo:"sceneWheel_similarityJudgment",
turkID: turkInfo,
wheel_info:[main_wheel, prac_wheel],
data:jsPsych.data.get().values(),
browser_info:browser_info,
interaction_data:jsPsych.data.getInteractionData().values(),
exp_condition:e_cond,
date: Date()
});
}
}
// * Debriefing form * //
var debrief_page = {
type: 'html-keyboard-response',
stimulus: function(){
var html =
'<p area-selected="font-size:15px;"> You are done! Your confirmation code is: '+
'<b>'+save_data.data.conf_code+'</b>'+
'<p>Thank you for participating!</p>'+
'<embed src="debriefing/Debriefing.pdf" style="width:80vw; height:70vh;"></embed>'
return html;
},
choices: jsPsych.NO_KEYS,
data: {disp_type: 'debriefing_page'}
}
// * timeline fill up * //
timeline = [];
timeline.push({
type: 'fullscreen',
fullscreen_mode: true
});
timeline.push(instruction1);
timeline.push(judgment_prac);
timeline.push(instruction2);
for (b=0; b<n_block-1; b++) {
timeline.push(eval('judgment_main'+(b)));
timeline.push(test_break);
}
timeline.push(eval('judgment_main'+(n_block-1)));
timeline.push(dem_info);
timeline.push(save_data);
timeline.push({
type: 'fullscreen',
fullscreen_mode: false
});
timeline.push(debrief_page);
jsPsych.init({
timeline: timeline,
preload_images: stimuli,
show_progress_bar: true,
auto_update_progress_bar: false
});
</script>
</html>