generated from psych251/rescue_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
470 lines (426 loc) · 21.8 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
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
<!DOCTYPE html>
<html>
<head>
<title>Mirror Invariance experiment</title>
<script src="https://unpkg.com/[email protected]"> /* Load jsPsych library */ </script>
<script src="https://unpkg.com/@jspsych/[email protected]">/* To show text on screen */</script>
<script src="https://unpkg.com/@jspsych/[email protected]">/* Keyboard response */</script>
<script src="https://unpkg.com/@jspsych/[email protected]">/* Button plugin */</script>
<script src="https://unpkg.com/@jspsych/[email protected]">/* Preload plugin */</script>
<script src="https://unpkg.com/@jspsych/[email protected]">/* Instructions plugin */</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">/* jQuery Library for proliferate data collection */</script>
<script src="https://proliferate.alps.science/static/js/proliferate.js" type="text/javascript">/* Proliferate data collection plugin */</script>
<link href="https://unpkg.com/[email protected]/css/jspsych.css" rel="stylesheet" type="text/css" />
</head>
<body></body>
<script>
/* Initialize jsPsych */
var jsPsych = initJsPsych({
on_finish: function(data) {
// DISPLAY RESPONSES IN BROWSER AFTER EXPERIMENT
// jsPsych.data.displayData('csv');
// DOWNLOAD RESPONSES AS .CSV FILE AFTER EXPERIMENT
// jsPsych.data.get().localSave( 'csv','pilotA_data.csv');
// COLLECT RESPONSES IN PROLIFERATE
proliferate.submit({"trials": data.values()});
window.location = "https://app.prolific.com/submissions/complete?cc=C1A8YHGZ";
}
});
/*
------------------------------------------
ADD SUBJECT_ID IN PROLIFIC DATA
------------------------------------------
*/
// capture info from Prolific
var subject_id = jsPsych.data.getURLVariable('PROLIFIC_PID');
// var study_id = jsPsych.data.getURLVariable('STUDY_ID');
// var session_id = jsPsych.data.getURLVariable('SESSION_ID');
jsPsych.data.addProperties({
subject_id: subject_id,
// study_id: study_id,
// session_id: session_id
});
/* Timeline array holding stimuli*/
var timeline = [];
/*
------------------------
PRELOADING
------------------------
*/
var preload = {
type: jsPsychPreload,
images: [
// Faces
'img_mproj/faces/1.jpg',
'img_mproj/faces/2.jpg',
'img_mproj/faces/3.jpg',
'img_mproj/faces/4.jpg',
'img_mproj/faces/5.jpg',
'img_mproj/faces/6.jpg',
'img_mproj/faces/7.jpg',
'img_mproj/faces/8.jpg',
'img_mproj/faces/9.jpg',
'img_mproj/faces/10.jpg',
'img_mproj/faces/11.jpg',
'img_mproj/faces/12.jpg',
'img_mproj/faces/13.jpg',
'img_mproj/faces/14.jpg',
// Mfaces
'img_mproj/Mfaces/1.jpg',
'img_mproj/Mfaces/2.jpg',
'img_mproj/Mfaces/3.jpg',
'img_mproj/Mfaces/4.jpg',
'img_mproj/Mfaces/5.jpg',
'img_mproj/Mfaces/6.jpg',
'img_mproj/Mfaces/7.jpg',
'img_mproj/Mfaces/8.jpg',
'img_mproj/Mfaces/9.jpg',
'img_mproj/Mfaces/10.jpg',
'img_mproj/Mfaces/11.jpg',
'img_mproj/Mfaces/12.jpg',
'img_mproj/Mfaces/13.jpg',
'img_mproj/Mfaces/14.jpg',
// False
'img_mproj/false/1.jpg',
'img_mproj/false/2.jpg',
'img_mproj/false/3.jpg',
'img_mproj/false/4.jpg',
'img_mproj/false/5.jpg',
'img_mproj/false/6.jpg',
'img_mproj/false/7.jpg',
'img_mproj/false/8.jpg',
'img_mproj/false/9.jpg',
'img_mproj/false/10.jpg',
'img_mproj/false/11.jpg',
'img_mproj/false/12.jpg',
'img_mproj/false/13.jpg',
'img_mproj/false/14.jpg',
// Mfalse
'img_mproj/Mfalse/1.jpg',
'img_mproj/Mfalse/2.jpg',
'img_mproj/Mfalse/3.jpg',
'img_mproj/Mfalse/4.jpg',
'img_mproj/Mfalse/5.jpg',
'img_mproj/Mfalse/6.jpg',
'img_mproj/Mfalse/7.jpg',
'img_mproj/Mfalse/8.jpg',
'img_mproj/Mfalse/9.jpg',
'img_mproj/Mfalse/10.jpg',
'img_mproj/Mfalse/11.jpg',
'img_mproj/Mfalse/12.jpg',
'img_mproj/Mfalse/13.jpg',
'img_mproj/Mfalse/14.jpg',
// French
'img_mproj/french/1.jpg',
'img_mproj/french/2.jpg',
'img_mproj/french/3.jpg',
'img_mproj/french/4.jpg',
'img_mproj/french/5.jpg',
'img_mproj/french/6.jpg',
'img_mproj/french/7.jpg',
'img_mproj/french/8.jpg',
'img_mproj/french/9.jpg',
'img_mproj/french/10.jpg',
'img_mproj/french/11.jpg',
'img_mproj/french/12.jpg',
'img_mproj/french/13.jpg',
'img_mproj/french/14.jpg',
// Mfrench
'img_mproj/Mfrench/1.jpg',
'img_mproj/Mfrench/2.jpg',
'img_mproj/Mfrench/3.jpg',
'img_mproj/Mfrench/4.jpg',
'img_mproj/Mfrench/5.jpg',
'img_mproj/Mfrench/6.jpg',
'img_mproj/Mfrench/7.jpg',
'img_mproj/Mfrench/8.jpg',
'img_mproj/Mfrench/9.jpg',
'img_mproj/Mfrench/10.jpg',
'img_mproj/Mfrench/11.jpg',
'img_mproj/Mfrench/12.jpg',
'img_mproj/Mfrench/13.jpg',
'img_mproj/Mfrench/14.jpg',
// Jap
'img_mproj/jap/1.jpg',
'img_mproj/jap/2.jpg',
'img_mproj/jap/3.jpg',
'img_mproj/jap/4.jpg',
'img_mproj/jap/5.jpg',
'img_mproj/jap/6.jpg',
'img_mproj/jap/7.jpg',
'img_mproj/jap/8.jpg',
'img_mproj/jap/9.jpg',
'img_mproj/jap/10.jpg',
'img_mproj/jap/11.jpg',
'img_mproj/jap/12.jpg',
'img_mproj/jap/13.jpg',
'img_mproj/jap/14.jpg',
// Mjap
'img_mproj/Mjap/1.jpg',
'img_mproj/Mjap/2.jpg',
'img_mproj/Mjap/3.jpg',
'img_mproj/Mjap/4.jpg',
'img_mproj/Mjap/5.jpg',
'img_mproj/Mjap/6.jpg',
'img_mproj/Mjap/7.jpg',
'img_mproj/Mjap/8.jpg',
'img_mproj/Mjap/9.jpg',
'img_mproj/Mjap/10.jpg',
'img_mproj/Mjap/11.jpg',
'img_mproj/Mjap/12.jpg',
'img_mproj/Mjap/13.jpg',
'img_mproj/Mjap/14.jpg',
// Tools
'img_mproj/tools/1.jpg',
'img_mproj/tools/2.jpg',
'img_mproj/tools/3.jpg',
'img_mproj/tools/4.jpg',
'img_mproj/tools/5.jpg',
'img_mproj/tools/6.jpg',
'img_mproj/tools/7.jpg',
'img_mproj/tools/8.jpg',
'img_mproj/tools/9.jpg',
'img_mproj/tools/10.jpg',
'img_mproj/tools/11.jpg',
'img_mproj/tools/12.jpg',
'img_mproj/tools/13.jpg',
'img_mproj/tools/14.jpg',
// Mtools
'img_mproj/Mtools/1.jpg',
'img_mproj/Mtools/2.jpg',
'img_mproj/Mtools/3.jpg',
'img_mproj/Mtools/4.jpg',
'img_mproj/Mtools/5.jpg',
'img_mproj/Mtools/6.jpg',
'img_mproj/Mtools/7.jpg',
'img_mproj/Mtools/8.jpg',
'img_mproj/Mtools/9.jpg',
'img_mproj/Mtools/10.jpg',
'img_mproj/Mtools/11.jpg',
'img_mproj/Mtools/12.jpg',
'img_mproj/Mtools/13.jpg',
'img_mproj/Mtools/14.jpg'
],
show_progress_bar: true
};
/*
-------------------------------------------
WELCOME AND INSTRUCTIONS
-------------------------------------------
*/
var welcome = {
type: jsPsychInstructions,
pages: [
`<p>Welcome to the experiment. By answering the following questions, you are participating in a study being performed by cognitive scientists
in the Stanford Department of Psychology. If you have questions about this research, please contact us at [email protected]. You must be at
least 18 years old to participate. Your participation in this research is voluntary. You may decline to answer any or all of the following questions.
You may decline further participation, at any time, without adverse consequences. Your anonymity is assured; the researchers who have requested your
participation will not receive any personal information about you. Click next to continue to the experiment. </p>`,
`<p>Before starting the experiment, please ensure that you are performing this task on a laptop or a desktop. In addition, please set your
window size to less than 100% by pressing the command/Ctrl and - (minus sign) keys simultaneously or by going on View > Zoom out. </p>`,
`<p>Directions: You will be presented one image after another. Press S if the first word or image is the same as the second word or image.
The word or image can be in the same or different orientation. Press D if the second word or image is different from the first word or image. </p>`,
`<p>Let us try a few examples. Click next to begin trial. </p>`
],
show_clickable_nav: true
}
// var welcome = {
// type: jsPsychHtmlButtonResponse,
// stimulus: `<p>Welcome to the experiment. By answering the following questions, you are participating in a study being performed by cognitive scientists
// in the Stanford Department of Psychology. If you have questions about this research, please contact us at [email protected]. You must be at
// least 18 years old to participate. Your participation in this research is voluntary. You may decline to answer any or all of the following questions.
// You may decline further participation, at any time, without adverse consequences. Your anonymity is assured; the researchers who have requested your
// participation will not receive any personal information about you. Click next to continue to the experiment. </p>`,
// choices: ['Next']
// };
// var view_inst = {
// type: jsPsychHtmlButtonResponse,
// stimulus: `<p>Before starting the experiment, please ensure that you are performing this task on a laptop or a desktop. In addition, please set your
// window size to less than 100% by pressing the command/Ctrl and - (minus sign) keys simultaneously or by going on View > Zoom out. </p>`,
// choices: ['Previous', 'Next']
// };
// var task_inst = {
// type: jsPsychHtmlButtonResponse,
// stimulus: `<p>Directions: You will be presented one image after another. Press S if the first word or image is the same as the second word or image.
// The word or image can be in the same or different orientation. Press D if the second word or image is different from the first word or image. </p>`,
// choices: ['Previous', 'Next']
// };
// var eg_view = {
// type: jsPsychHtmlButtonResponse,
// stimulus: `<p>Let us try a few examples. Click next to begin trial. </p>`,
// choices: ['Previous', 'Next']
// };
/*
-----------------------------------------------------
TRIAL COMPONENTS + FIXATION + RESPONSE COLLECTION TEXT
------------------------------------------------------
*/
/* define TRIAL stimuli array for timeline variables */
var test_stimuli = [
{ stimulus1: 'img_mproj/french/2.jpg', stimulus2: 'img_mproj/french/2.jpg', txt: "<p>The two words were the same, with same orientation. The correct response was 'S'. Let us try another example. Click next to continue.</p>", correct_response:'s', answer:'SNF'},
{ stimulus1: 'img_mproj/tools/2.jpg' , stimulus2: "img_mproj/Mtools/2.jpg", txt: "<p>The two images were the same, but in different orientation. The correct response was 'S'. Let us try one last example. Click next to continue.</p>", correct_response:'s', answer:'SMT'},
{ stimulus1: 'img_mproj/jap/1.jpg' , stimulus2: "img_mproj/jap/2.jpg", txt: "<p>The two words/images were different. The correct response was 'D'. Click next to begin the task.</p>", correct_response:'d', answer:'DNT'}
];
/* Fixation cross */
var fixation = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<div style="font-size:60px;">+</div>',
choices: "NO_KEYS",
trial_duration: 300,
data: {
task: 'fixation'
}
};
/* Presenting TRIAL images 1 */
var test1 = {
type: jsPsychImageKeyboardResponse,
stimulus: jsPsych.timelineVariable('stimulus1'),
choices: "NO_KEYS",
trial_duration: 200,
data: {
task: 'stimuli_presentation_1'
}
};
/* Presenting TRIAL images 2 */
var test2 = {
type: jsPsychImageKeyboardResponse,
stimulus: jsPsych.timelineVariable('stimulus2'),
choices: "NO_KEYS",
trial_duration: 200,
data: {
task: 'stimuli_presentation_2'
}
};
/* Presenting collecting response text */
var resp_trial = {
type: jsPsychHtmlKeyboardResponse,
stimulus: "<p> Press S if the two images were the same, Press D if the two images were different. </p>",
choices: ['s', 'd'],
data: {
task: 'response',
correct_response: jsPsych.timelineVariable('correct_response'),
category: jsPsych.timelineVariable('answer')
}
};
/* Presenting After TRIAL Response Text*/
var test_textbut = {
type: jsPsychHtmlButtonResponse,
stimulus: jsPsych.timelineVariable('txt'),
choices: ["Next"],
data: {
task: 'After_trial_text'
}
};
/* define TRIAL procedure */
var test_procedure = {
timeline: [test1, fixation, test2, resp_trial, test_textbut],
timeline_variables: test_stimuli
};
/*
----------------------------------------
ACTUAL TASK BEGINS HERE
----------------------------------------
*/
const image_list=["1","2","3","4","5","6","7","8","9","10","11","12","13","14"];
var task_stimuli = [];
for (let i=0; i <image_list.length; i++)
{
//normal-same
item = image_list[i]
task_stimuli.push({pair1: "img_mproj/tools/"+item+".jpg", pair2: "img_mproj/tools/"+item+".jpg", answer: 'SNT', correct_response: 's'}) //tools
task_stimuli.push({pair1: "img_mproj/faces/"+item+".jpg", pair2: "img_mproj/faces/"+item+".jpg", answer: 'SNM', correct_response: 's'}) //faces
task_stimuli.push({pair1: "img_mproj/french/"+item+".jpg", pair2: "img_mproj/french/"+item+".jpg", answer: 'SNF', correct_response: 's'}) //french
task_stimuli.push({pair1: "img_mproj/jap/"+item+".jpg", pair2: "img_mproj/jap/"+item+".jpg", answer: 'SNJ', correct_response: 's'}) //japanese
task_stimuli.push({pair1: "img_mproj/false/"+item+".jpg", pair2: "img_mproj/false/"+item+".jpg", answer: 'SNP', correct_response: 's'}) //false words
//normal-different
const different = image_list.filter(difimage => difimage!=item)
const random_different = different[Math.floor(Math.random()*different.length)]
task_stimuli.push({pair1: "img_mproj/tools/"+item+".jpg", pair2: "img_mproj/tools/"+random_different+".jpg", answer: 'DNT', correct_response: 'd'}) //tools
task_stimuli.push({pair1: "img_mproj/faces/"+item+".jpg", pair2: "img_mproj/faces/"+random_different+".jpg", answer:'DNM', correct_response: 'd'}) //faces
task_stimuli.push({pair1: "img_mproj/french/"+item+".jpg", pair2: "img_mproj/french/"+random_different+".jpg", answer: 'DNF', correct_response: 'd'}) //french
task_stimuli.push({pair1: "img_mproj/jap/"+item+".jpg", pair2: "img_mproj/jap/"+random_different+".jpg", answer: 'DNJ', correct_response: 'd'}) //japanese
task_stimuli.push({pair1: "img_mproj/false/"+item+".jpg", pair2: "img_mproj/false/"+random_different+".jpg", answer: 'DNP', correct_response: 'd'}) //false words
//mirror-same
task_stimuli.push({pair1: "img_mproj/tools/"+item+".jpg", pair2: "img_mproj/Mtools/"+item+".jpg", answer: 'SMT', correct_response: 's' }) //tools
task_stimuli.push({pair1: "img_mproj/faces/"+item+".jpg", pair2: "img_mproj/Mfaces/"+item+".jpg", answer: 'SMM', correct_response: 's'})// faces
task_stimuli.push({pair1: "img_mproj/french/"+item+".jpg", pair2: "img_mproj/Mfrench/"+item+".jpg", answer: 'SMF', correct_response: 's'}) //french
task_stimuli.push({pair1: "img_mproj/jap/"+item+".jpg", pair2: "img_mproj/Mjap/"+item+".jpg", answer: 'SMJ', correct_response: 's'}) //japanese
task_stimuli.push({pair1: "img_mproj/false/"+item+".jpg", pair2: "img_mproj/Mfalse/"+item+".jpg", answer: 'SMP', correct_response: 's'}) //false words
//mirror-different
task_stimuli.push({pair1: "img_mproj/Mtools/"+item+".jpg", pair2: "img_mproj/Mtools/"+random_different+".jpg", answer: 'DMT', correct_response: 'd' }) //tools
task_stimuli.push({pair1: "img_mproj/Mfaces/"+item+".jpg", pair2: "img_mproj/Mfaces/"+random_different+".jpg", answer:'DMM', correct_response: 'd'}) // faces
task_stimuli.push({pair1: "img_mproj/Mfrench/"+item+".jpg", pair2: "img_mproj/Mfrench/"+random_different+".jpg", answer: 'DMF', correct_response: 'd'}) // french
task_stimuli.push({pair1: "img_mproj/Mjap/"+item+".jpg", pair2: "img_mproj/Mjap/"+random_different+".jpg", answer: 'DMJ', correct_response: 'd'}) // japanese
task_stimuli.push({pair1: "img_mproj/Mfalse/"+item+".jpg", pair2: "img_mproj/Mfalse/"+random_different+".jpg", answer: 'DMP', correct_response: 'd'}) // false words
}
/* Presenting TASK images 1 */
var actask1 = {
type: jsPsychImageKeyboardResponse,
stimulus: jsPsych.timelineVariable('pair1'),
choices: "NO_KEYS",
trial_duration: 200,
data: {
task: 'actual_stimuli_presentation_1'
}
};
/* Presenting TASK images 2 */
var actask2 = {
type: jsPsychImageKeyboardResponse,
stimulus: jsPsych.timelineVariable('pair2'),
choices: "NO_KEYS",
trial_duration: 200,
data: {
task: 'actual_stimuli_presentation_2'
}
};
/* define TASK procedure */
var task_procedure = {
timeline: [actask1, fixation, actask2, resp_trial],
timeline_variables: task_stimuli,
randomize_order: true
};
/*
----------------------------------------
END OF TASK MESSAGES
----------------------------------------
*/
// Good Job message
var good_job = {
type: jsPsychHtmlButtonResponse,
stimulus: `<p> Great job! You have finished the experiment. Click next to learn about the experiment. </p>`,
choices: [ 'Next']
};
// About task
var abt_task = {
type: jsPsychHtmlButtonResponse,
stimulus: `<p> The goal of the experiment was to replicate a study on mirror invariance which is a visual mechanism
that allows recognition of mirror images. The study examines if mirror invariance is retained in adults and if
mirror invariance is present for recognizing objects, faces, familiar, and nonfamiliar words. </p>`,
choices: [ 'Next']
};
// Contact Message
var contact_msg = {
type: jsPsychHtmlButtonResponse,
stimulus: `<p> Thank you for completing the experiment. Please email [email protected] for any questions or concerns. </p>`,
choices: [ 'Finish']
};
/*
---------------------------
TIMELINE PUSH
---------------------------
*/
/* Push to end of timeline */
timeline.push(preload);
timeline.push(welcome);
//timeline.push(view_inst);
//timeline.push(task_inst);
//timeline.push(eg_view);
timeline.push(test_procedure);
timeline.push(task_procedure);
timeline.push(good_job);
timeline.push(abt_task);
timeline.push(contact_msg);
/* Run Timeline */
jsPsych.run(timeline);
</script>
</html>