forked from Qlab-UDel/SL-experiments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvsl.html
More file actions
507 lines (438 loc) · 17.5 KB
/
vsl.html
File metadata and controls
507 lines (438 loc) · 17.5 KB
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>VSL</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="jspsych-5.0.3/jspsych.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-survey-text.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-text.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-single-stim.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-single-audio.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-call-function.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-multi-stim-multi-response.js"></script>
<link href="jspsych-5.0.3/css/jspsych.css" rel="stylesheet" type="text/css">
</head>
<body>
</body>
<script>
var timeline = [];
var par_id = {
type: 'survey-text',
questions: ['Enter your participant ID'],
timing_post_trial: 1000
};
String.prototype.format = function () {
var i = 0, args = arguments;
return this.replace(/{}/g, function () {
return typeof args[i] != 'undefined' ? args[i++] : '';
});
};
var cond_assign = jsPsych.randomization.sample(['lang1','lang2'],1)[0];
var datetime = jsPsych.startTime();
if (cond_assign === 'lang1') {
var targali = [3,6,9,12][Math.floor(Math.random()*4)];
} else if (cond_assign === 'lang2') {
var targali = [1,4,7,10][Math.floor(Math.random()*4)];
}
var lookup = {
type: 'call-function',
func: function () {var par = jsPsych.data.getTrialsOfType('survey-text')[0].responses.match(/[a-zA-Z0-9]/g).join('').split(/Q0/)[1];
return par;}
};
var send_targali = {
type: 'single-stim',
stimulus: '../../images/alien{}.jpg'.format(targali),
choices:['space'],
timing_response: -1,
response_ends_trial:true
};
var send_time = {
type: 'call-function',
func: function () {var datetime = jsPsych.startTime(); return datetime;}
};
var use_space = {
type: 'text',
text: 'Parts of the experiment require that you press the spacebar to continue. Please remember to always listen to and read the instructions completely before pressing the spacebar.',
cont_key: ['space']
};
var target_stim_choice = [
function() {
return "<p>Hi there, today you are going to see some aliens line up to enter a cool spaceship. " +
"We need you to help us keep track of a very special alien as the aliens line up to enter their spaceship. " +
"We'll show you the alien now.</p>"}
];
var target_alien = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr1.wav',
prompt: target_stim_choice[0],
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr1 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr2.wav',
prompt: "<img src='../../images/Spaceship1.jpg' style='position:fixed;top:20%;left:30%;'>" ,
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr2 = {
type: 'single-stim',
stimulus: '../../images/Spaceship2.jpg',
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr3 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr3.wav',
prompt: "<img src='../../images/Spaceship3.jpg' style='position:fixed;top:20%;left:35%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr4 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr4.wav',
prompt: "<img src='../../images/Ladder1.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr5 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr5.wav',
prompt: "<img src='../../images/Ladder2.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr6 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr6.wav',
prompt: "<img src='../../images/Ladder3.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var target_stim_reminder = [
function() {
return "<p>Remember, this is the special alien to keep track of. The aliens will appear " +
"one at a time on the screen as they line up. To keep track of our special alien press " +
"the spacebar whenever you see it.</p><img src='../../images/alien{}.jpg' style='position:fixed;top:40%;left:40%;margin-top:-100px;margin-left: -80px;'>".format(targali);}
];
var target_alien_reminder = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr7.wav',
prompt: target_stim_reminder[0],
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
if (cond_assign === 'lang1') {
var seq1=[1, 2, 3, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9,
4, 5, 6, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1,
2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 1, 2, 3, 10, 11, 12, 4, 5,
6, 1, 2, 3, 7, 8, 9, 1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10,
11, 12, 4, 5, 6, 1, 2, 3, 10, 11, 12, 7, 8, 9, 4, 5, 6, 10, 11,
12, 1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12, 4, 5, 6, 1, 2, 3, 7, 8, 9,
10, 11, 12, 1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9, 1, 2, 3, 4, 5,
6, 7, 8, 9, 1, 2, 3, 10, 11, 12, 1, 2, 3, 7, 8, 9, 4, 5, 6, 1,
2, 3, 7, 8, 9, 10, 11, 12, 4, 5, 6, 1, 2, 3, 10, 11, 12, 7, 8,
9, 4, 5, 6, 10, 11, 12, 4, 5, 6, 7, 8, 9, 1, 2, 3, 7, 8, 9, 10,
11, 12, 4, 5, 6, 1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 1, 2, 3,
10, 11, 12, 4, 5, 6, 7, 8, 9, 1, 2, 3, 10, 11, 12, 4, 5, 6, 1, 2,
3, 10, 11, 12, 7, 8, 9, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 1,
2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12, 1, 2, 3, 7, 8, 9, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 7, 8, 9]
} else if (cond_assign === 'lang2') {
var seq1 = [2, 9, 4, 8, 3, 10, 2, 9, 4, 5, 12, 1, 11, 6, 7, 5, 12, 1,
2, 9, 4, 8, 3, 10, 11, 6, 7, 5, 12, 1, 8, 3, 10, 2, 9, 4, 8, 3,
10, 5, 12, 1, 2, 9, 4, 11, 6, 7, 8, 3, 10, 5, 12, 1, 11, 6, 7,
2, 9, 4, 11, 6, 7, 2, 9, 4, 5, 12, 1, 8, 3, 10, 11, 6, 7, 2, 9,
4, 5, 12, 1, 8, 3, 10, 5, 12, 1, 11, 6, 7, 2, 9, 4, 8, 3, 10, 11,
6, 7, 2, 9, 4, 5, 12, 1, 8, 3, 10, 5, 12, 1, 11, 6, 7, 8, 3, 10,
2, 9, 4, 8, 3, 10, 5, 12, 1, 11, 6, 7, 2, 9, 4, 11, 6, 7, 8, 3,
10, 5, 12, 1, 2, 9, 4, 8, 3, 10, 11, 6, 7, 5, 12, 1, 11, 6, 7, 2,
9, 4, 5, 12, 1, 8, 3, 10, 5, 12, 1, 11, 6, 7, 8, 3, 10, 2, 9, 4,
5, 12, 1, 11, 6, 7, 8, 3, 10, 11, 6, 7, 2, 9, 4, 5, 12, 1, 11, 6,
7, 2, 9, 4, 5, 12, 1, 8, 3, 10, 2, 9, 4, 8, 3, 10, 11, 6, 7, 5, 12,
1, 2, 9, 4, 11, 6, 7, 8, 3, 10, 5, 12, 1, 2, 9, 4, 11, 6, 7, 2, 9, 4,
5, 12, 1, 8, 3, 10, 5, 12, 1, 2, 9, 4, 8, 3, 10, 11, 6, 7, 2, 9, 4,
8, 3, 10, 11, 6, 7, 5, 12, 1, 11, 6, 7, 2, 9, 4, 8, 3, 10, 5, 12,
1, 8, 3, 10, 11, 6, 7]
}
// creates a javascript object that will be used in the for loop below
// this helps with defining the familiarizaiton block
var pics = [];
pics['1'] = '../../images/alien1.jpg';
pics['2'] = '../../images/alien2.jpg';
pics['3'] = '../../images/alien3.jpg';
pics['4'] = '../../images/alien4.jpg';
pics['5'] = '../../images/alien5.jpg';
pics['6'] = '../../images/alien6.jpg';
pics['7'] = '../../images/alien7.jpg';
pics['8'] = '../../images/alien8.jpg';
pics['9'] = '../../images/alien9.jpg';
pics['10'] = '../../images/alien10.jpg';
pics['11'] = '../../images/alien11.jpg';
pics['12'] = '../../images/alien12.jpg';
pics['13'] = '../../images/blank.png';
// creates the familiarization block sequence to be fed into struct_block
// the structure must be {'stimulus': 'path/to/image.png'}
var img_block_1 = [];
for (var m=0; m<seq1.length; m++) {
img_block_1.push({'stimulus': pics[seq1[m]]});
}
// this is the strucutred block
var struct_block = {
type: 'single-stim',
choices: ['space'],
timeline: img_block_1,
timing_response: 796,
timing_post_trial: 200,
response_ends_trial: false
};
// test phase instructions begin
var end_struck_block = {
type: 'single-audio',
stimulus: '../../vsl_audio/vsl_instr_between.wav',
prompt: 'Great job! We are now going to give you another set of instructions please pay attention!',
cont_key: ['space']
};
var vsl_instr9 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr9.wav',
prompt: "<img src='../../images/Ladder4.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr10 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr10.wav',
prompt: "<img src='../../images/Ladder6.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr11 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr11.wav',
prompt: "<img src='../../images/Ladder7.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr12 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr12.wav',
prompt: "<img src='../../images/Ladder8.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var vsl_instr13 = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr13.wav',
prompt: "<img src='../../images/Ladder10.jpg' style='position:fixed;top:20%;left:30%'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
// more forced choice explanation
var forced_choiced_exp_cont = {
type: 'single-audio',
stimulus: '../../vsl_audio/sound_instruct/vsl_instr14.wav',
prompt: "<p>We're going to show you aliens one at a time. The first 3 will belong to one group of aliens " +
"that might have lined up together and the last three will belong to another group of aliens " +
"that might have lined up together. Your job is to decide which of the two groups lined up together.</p>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
// sequence of images for the forced choice portion of the experimet
if (cond_assign === 'lang1') {
var seqc1 = [
13, 1, 2, [3,0], 10, 2, 6, 13, 4, 8, [12,0], 4, 5, 6, 13,
7, 11, [3,0], 1, 2, 3, 13, 1, 5, [9,0], 10, 11, 12, 13, 7,
8, [9,0], 7, 11, 3, 13, 1, 2, [3,0], 4, 8, 12, 13, 1, 5, [9,0],
10, 11, 12, 13, 4, 5, [6,0], 10, 2, 6, 13, 7, 8, [9,0], 4,
8, 12, 13, 1, 5, [9,0], 4, 5, 6, 13, 10, 11, [12,0], 7, 11,
3, 13, 10, 2, [6,0], 1, 2, 3, 13, 4, 5, [6,0], 4, 8, 12, 13,
1, 2, [3,0], 1, 5, 9, 13, 7, 11, [3,0], 7, 8, 9, 13, 4, 8, [12,0],
10, 11, 12, 13, 1, 2, [3,0], 10, 2, 6, 13, 7, 8, [9,0], 1, 5, 9,
13, 4, 8, [12,0], 4, 5, 6, 13, 10, 11, [12,0], 10, 2, 6, 13, 7, 11,
[3,0], 7, 8, 9, 13, 1, 5, [9,0], 1, 2, 3, 13, 10, 11, [12,0], 4, 8, 12,
13, 7, 11, [3,0], 4, 5, 6, 13, 1, 5, [9,0], 1, 2, 3, 13, 10, 2, [6,0],
7, 8, 9, 13, 10, 11, [12,0], 1, 5, 9, 13, 10, 2, [6,0], 4, 5, 6, 13,
10, 11, [12,0], 4, 8, 12, 13, 7, 11, [3,0], 4, 5, 6, 13, 7, 8, [9,0],
10, 2, 6, 13, 1, 2, [3,0], 7, 11, 3, 13
]
} else if (cond_assign === 'lang2') {
var seqc1 = [
13, 2, 9, [4,0], 5, 3, 7, 13, 8, 3, [10,0], 11, 9, 10, 13, 2, 6, [1,0],
2, 9, 4, 13, 5, 12, [1,0], 8, 12, 4, 13, 11, 6, [7,0], 5, 3, 7, 13,
5, 12, [1,0], 8, 12, 4, 13, 11, 9, [10,0], 2, 9, 4, 13, 2, 6, [1,0],
8, 3, 10, 13, 5, 3, [7,0], 11, 6, 7, 13, 8, 12, [4,0], 5, 12, 1, 13,
8, 3, [10,0], 11, 9, 10, 13, 2, 9, [4,0], 2, 6, 1, 13, 8, 3, [10,0],
11, 9, 10, 13, 8, 12, [4,0], 5, 12, 1, 13, 5, 3, [7,0], 2, 9, 4, 13,
11, 6, [7,0], 2, 6, 1, 13, 8, 12, [4,0], 8, 3, 10, 13, 11, 9, [10,0],
5, 12, 1, 13, 11, 6, [7,0], 5, 3, 7, 13, 2, 9, [4,0], 11, 9, 10, 13,
8, 12, [4,0], 11, 6, 7, 13, 2, 9, [4,0], 2, 6, 1, 13, 5, 3, [7,0],
5, 12, 1, 13, 8, 3, [10,0], 2, 6, 1, 13, 5, 3, [7,0], 11, 6, 7, 13,
2, 9, [4,0], 11, 9, 10, 13, 8, 12, [4,0], 5, 12, 1, 13, 8, 3, [10,0],
11, 9, 10, 13, 5, 12, [1,0], 2, 6, 1, 13, 5, 3, [7,0], 11, 6, 7, 13,
2, 6, [1,0], 2, 9, 4, 13, 8, 12, [4,0], 8, 3, 10, 13
]
}
// creats the array of images to be show for the focrced choice
// since it is zero indexed, the first image is just a blank screen
// the order in the seq2 variable should reflect this
// the order in seq2 should also build in the fact that every 7th stimulus will not be presented
var img_block_2 = [];
for (ii=0; ii<seqc1.length; ii++) {
if (ii % 7 === 0 && ii !== 0 && seqc1[ii] === 13) {
img_block_2.push({'stimulus': '',
'prompt': 'If the first three aliens were a group of friends that always lined up together to enter the spaceship, press 1; If the second three aliens were a group of friends that always lined up together to enter the spaceship, press 2',
'choices': ['1','2'],
'timing_response': 1600000000,
'timing_post_trial': 200,
'response_ends_trial': true});
} else if (ii === 0) {
img_block_2.push({'stimulus': '',
'prompt': '',
'choices': ['1','2'],
'timing_response': 200,
'timing_post_trial': 200,
'response_ends_trial': false});
} else if (seqc1[ii][1] === 0){
img_block_2.push({'stimulus': pics[seqc1[ii][0]],
'response_ends_trial': false,
'timing_response': 796,
'timing_post_trial': 1000});
} else {
img_block_2.push({'stimulus': pics[seqc1[ii]],
'response_ends_trial': false,
'timing_response': 796,
'timing_post_trial': 200});
}
}
// create the forced choice block
var forced_choice_block = {
type: 'single-stim',
timeline: img_block_2,
timing_response: 796,
timing_post_trial: 200,
response_ends_trial: false
};
var end = {
type: 'text',
text: "Great, you're done with this task. Press wait while we redirect you to the next page.",
cont_key: ['space'],
}
timeline.push(par_id);
timeline.push(lookup);
timeline.push(use_space);
timeline.push(target_alien);
timeline.push(send_targali);
timeline.push(send_time);
timeline.push(vsl_instr1);
timeline.push(vsl_instr2);
timeline.push(vsl_instr3);
timeline.push(vsl_instr4);
timeline.push(vsl_instr5);
timeline.push(vsl_instr6);
timeline.push(target_alien_reminder);
//timeline.push(struct_block);
timeline.push(end_struck_block);
timeline.push(vsl_instr9);
timeline.push(vsl_instr10);
timeline.push(vsl_instr11);
timeline.push(vsl_instr12);
timeline.push(vsl_instr13);
timeline.push(forced_choiced_exp_cont);
//timeline.push(forced_choice_block);
timeline.push(end);
var datajson = jsPsych.data.dataAsCSV();
jsPsych.data.addProperties({
cond: cond_assign,
targ: 'alien{}'.format(targali),
});
function saveData(filename, filedata){
$.ajax({
type:'post',
cache: false,
url: 'local_data_save.php', // this is the path to the above PHP script
data: {filename: filename, filedata: filedata}
});
}
jsPsych.init({
timeline: timeline,
fullscreen: false,
on_finish: function save_data(datajson){
saveData("{}_vsl.csv".format(jsPsych.data.getTrialsOfType('survey-text')[0]
.responses.match(/[a-zA-Z0-9]/g)
.join('').split(/Q0/)[1]), jsPsych.data.dataAsCSV());
var data_table = "vsl_table";
$.ajax({
type:'post',
cache: false,
url: '../../savedata.php',
data: {
table: data_table,
json: JSON.stringify(datajson)
},
success: function(output) { console.log(output); }
});
setTimeout(function() {
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
console.log(arraylist);
if (arraylist.length == 0) {return window.location.replace('../../LSL_Exp/end_page.html');}
var pick_exp = function(expType) {
return expType[Math.floor(Math.random()*expType.length)];
};
var exp = pick_exp(arraylist);
if (exp === 'v'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("v");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('vsl.html');
}
if (exp === 't'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("t");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('tsl.html');
}
if (exp === 'l'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("l");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('../../LSL_Exp/lsl.html');
}
if (exp === 's'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("s");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('../../SSL_Exp/ssl.html');
}
}, 3000);
}
});
</script>
</html>