-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscale.html
367 lines (294 loc) · 10 KB
/
scale.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
<!DOCTYPE html>
<html>
<head>
<title>Estimate average emotion expressed by faces</title>
<script src="jsPsych/jspsych.js"></script>
<script src="jsPsych/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jsPsych/plugins/jspsych-image-button-response.js"></script>
<script src="jsPsych/plugins/jspsych-image-slider-response_noButton.js"></script>
<script src="jsPsych/plugins/jspsych-instructions.js"></script>
<script src="jsPsych/plugins/jspsych-survey-text.js"></script>
<script src="jsPsych/plugins/jspsych-external-html.js"></script>
<script src="jquery-3.3.1.min.js"></script>
<script src="sequential_task_functions.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.713.0.min.js"></script>
<link href="jsPsych/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<style>
.instructions_img {
border: solid 5px black;
width: 700px;
}
span.grid{
display: grid;
grid-template-columns: 120px 120px 120px 120px 120px;
grid-template-rows: 130px 130px 130px 130px 130px;
}
body{
background-color: #AAAAAA;
}
.jspsych-instructions-nav { margin-bottom: 100px; }
#consentDiv { font-size: 9pt; text-align: justify; }
.Happy {
display: inline-block;
width: 53px;
height: 68px;
background-size: 5000% 800%;
background-image: url('Happy.jpg');
padding: 20px;
}
.Angry {
display: inline-block;
width: 53px;
height: 68px;
background-size: 5000% 800%;
background-image: url('Angry.jpg');
padding: 20px;
}
div.preload {
display: none;
}
span div {
width: 100px;
}
</style>
<body>
<div class="preload">
<img src="Happy.jpg" />
<img src="Angry.jpg" />
</div>
</body>
<script>
/* Require a new-ish browser:
------------------------------------------ */
function supportsLiterals() {
try { return eval("''===``") }
catch(e) { return false; }
}
if (!supportsLiterals()) {
var txt = "Sorry, this experiment requires a newer browser, so yours is not able to be used. The latest Chrome, Firefox, Safari or Edge all work.";
alert(txt);
document.body.onload = function() { document.body.innerHTML = txt; };
}
/* Variables
------------------------------------------ */
var Face = {}; //create a data dictionary that will capture all of the data
var pool = loadFacePool(51,150);
Face.wordList = ['but','rock','sky','our','course','we','table','house','here','mouth','tree', 'hello'];
var trialList = [];
var total_trials = 50;
var falseAnswer = 0; var falseAllowance = 4; //attention check - the amount of time participants rate the same picture before they get an alert
var repeatAlert = 0; var repeatAllowance = 2; //how many times they can get alerts before they are cicked out
var trialCount = 0;
function updateCounter() {
trialCount = trialCount+1;
}
var attentionStimulus = loadStimulus(2);
var imageTestDescription = attentionStimulus;
Face.face_offset = {
"A": "0",
"B": "-100",
"C": "-200",
"D": "-300",
"E": "-400",
"F": "-500",
"G": "-600",
"H": "-700"
};
/* Instructions
------------------------------------------ */
var random_array = getRandomElement(["warray.png","barray.png"])
var random_gif = getRandomElement(["wscale.gif","bscale.gif"])
// trialList.push({
// type:'external-html',
// url: "external_page.html",
// cont_btn: "start",
// check_fn: check_consent
// });
// trialList.push({
// type: "instructions",
// pages: [
// "<p>This study aims to examine whether people can <b>estimate the <span style='color:red'>average</span> emotional expression</b> of multiple faces. In each trial, up to 12 faces expressing various degrees of emotion will appear on the screen.</p> <br> <img class = 'instructions_img' src='ins/" +random_array+ "'>",
// "The faces will either express positive (happy) or negative (angry) emotions.",
// "After the face group is displayed, one face will appear in the center of the screen. As you move your mouse, the face's expression will change gradually, from <b>neutral to emotional</b>. You must move the mouse until the face expresses the emotion that you think matches the <b>average</b> emotion in the face group you just saw. <br> <img class='instructions_img' src='ins/"+random_gif+"'>",
// "Once you have reached your estimate, <b>click the mouse</b> to select your estimate and advance to the next trial.",
// "Remember, the goal here is provide <strong>YOUR ESTIMATION of the <span style='color:red'>AVERAGE </span>EMOTIONAL RESPONSE </strong> of the faces you just saw.",
// ],
// show_clickable_nav: true,
// })
// trialList.push({
// type: 'survey-text',
// questions: [{prompt: "Please enter your Prolific ID (this will be used for validation purposes)"}],
// on_finish: function(data){
// Face.subject_id = JSON.parse(data.responses).Q0; // save id as global variable
// jsPsych.data.addProperties({participant_id: Face.subject_id});} // add the participant column to all current and future data entries
// })
/* PRACTICE TRIALS
------------------------------------------ */
//word attentionCheck
var askTypeWord = { //attention check - participants are asked to copy a word that appears on the screen
type: 'survey-text',
questions: function (){return [{prompt:'Please type the word: '+ getWord().bold() + ' (pay attention to capital letters)'}]},
};
var attentionCheck = { //function for the attention check
timeline: [askTypeWord],
loop_function: checkTyping,
on_start: function(data){
saveDataToS3()}
};
var imageDescription = {
type: 'survey-text',
questions: [{prompt: "Please describe the picture in your own words"}],
preamble: function() {
var curr_stim = imageTestDescription.shift()
return '<img src='+curr_stim+'></img>';
},
on_finish: function(data){
saveDataToS3()
Face.description = JSON.parse(data.responses).Q0; },
on_start: function(data){
saveDataToS3()
} //save description
};
// trialList.push({
// type:"instructions",
// pages:['You will begin with 3 practice trials.'],
// show_clickable_nav: true
// });
// trialList.push(imageDescription);
for (let dd = 0; dd < 3; dd++) {
if (dd == 0){trialList.push(attentionCheck)
}
trialList.push({ //getting new fixation time and face
type: 'html-keyboard-response',
stimulus: '<p style="font-size: 48px;"> + </p>',
trial_duration: getTimeAndFace, //random select fixation time
data: {Name:'fixation'}
});
trialList.push({ //there is an array of randomly selected pictures//
type: 'html-keyboard-response',
stimulus: getFaceSample,
trial_duration: 1500, //display faces for 1.5 second
choices: jsPsych.NO_KEYS,
// data: function(){Name:'singleFace',
// //add data of the single face to face pool
// Face.facePool.push(Face.singleFace)},
});
trialList.push({ //participants see a slider and asked to estimate the mean group emotion
type: 'image-slider-response_noButton',
stimulus: getScale,
prompt: "<p>Estimate the average emotion of the faces you just viewed</p>",
step:1,
max:50,
start: 0,
on_load: morphedScale,
data: function(){
updateCounter()
return {
Name: 'response',
fixationTime: Face.fixationTime,
faceIdentity_b: Face.b_identity,
faceIdentity_w: Face.w_identity,
b_faces_no: Face.b_person_ratio*Face.array_length,
b_faces_ratio : Face.b_person_ratio,
person_array: Face.person_array,
array_length: Face.array_length,
array_values: Face.array_values,
valence: Face.valence,
description: Face.description,
// face_1:(Face.emotionX + Face.singleFace),
trial: trialCount,
}
},
on_finish: function(){
if (trialCount % 10 == 0) saveDataToS3();
if (trialCount == 53) saveDataToS3();
}
});
}
trialList.push({
type:"instructions",
pages:['You completed the practice. Now you will complete 50 real trials.'],
show_clickable_nav: true
})
for (let dd = 0; dd < (total_trials); dd++) {
if (dd % 5 == 0){
trialList.push(attentionCheck)
}
trialList.push({ //getting new fixation time and face
type: 'html-keyboard-response',
stimulus: '<p style="font-size: 48px;"> + </p>',
trial_duration: getTimeAndFace, //random select fixation time
data: {Name:'fixation'}
});
trialList.push({ //there is an array of randomly selected pictures//
type: 'html-keyboard-response',
stimulus: getFaceSample,
trial_duration: 1500, //display faces for 1.5 second
choices: jsPsych.NO_KEYS,
// data: function(){Name:'singleFace',
// //add data of the single face to face pool
// Face.facePool.push(Face.singleFace)},
});
trialList.push({ //participants see a slider and asked to estimate the mean group emotion
type: 'image-slider-response_noButton',
stimulus: getScale,
prompt: "<p>Estimate the average emotion of the faces you just viewed</p>",
step:1,
max:50,
start: 0,
on_load: morphedScale,
data: function(){
updateCounter()
return {
Name: 'response',
fixationTime: Face.fixationTime,
faceIdentity: Face.personX,
array_length: Face.array_length,
array_values: Face.array_values,
valence: Face.valence,
description: Face.description,
// face_1:(Face.emotionX + Face.singleFace),
trial: trialCount,
}
},
on_finish: function(){
if (trialCount % 10 == 0) saveDataToS3();
if (trialCount == 53) saveDataToS3();
}
});
}
trialList.push(imageDescription);
trialList.push({
type:"instructions",
pages:["You're done with the task! Click 'next' to proceed to the survey"],
show_clickable_nav: true,
on_start: function(data){
saveDataToS3()
},
on_finish: function(data){
saveDataToS3()
}
})
/******************************************/
/* run the study */
/******************************************/
jsPsych.init({
timeline: trialList,
preload_images: pool,
use_webaudio: false,
experiment_width: 750,
exclusions: {
min_width: 700,
min_height: 500
},
on_close: function(){
saveDataToS3()
},
on_finish: function(){
saveDataToS3();
window.location = "https://hbs.qualtrics.com/jfe/form/SV_bNRKpZcOW9MM7Bk" //amplification race pilot 2021
}
});
</script>
</html>