-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbisection1.3_test_leftshort.html
504 lines (459 loc) · 19.5 KB
/
bisection1.3_test_leftshort.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
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
<!DOCTYPE html>
<html>
<head>
<title>Short or Long Game</title>
<script src="jspsych-6.0.5/jspsych.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-survey-text.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-survey-multi-choice.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-audio-keyboard-response.js"></script>
<link href="jspsych-6.0.5/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body></body>
<script>
//next steps://
//get the file to save with participant_ID//
//get habituation audio to play at the same time as fixation cross//
//create timeline array//
var timeline = [];
//input and store particpant info//
var participant_info = {
type: 'survey-text',
questions: [
{prompt: "Participant name", name: "participant_name"},
{prompt: "Participant ID", name: "participant_ID"}
],
data: {task_part: 'id_question'},
on_finish: function(data){
var responses = JSON.parse(data.responses);
var participant_name = responses.Q0;
var participant_id = responses.Q1;
// var short_tone = responses.Q2;
// var long_tone = responses.Q3;
jsPsych.data.addProperties(
{participantName: participant_name,
participantID: participant_id,
// shortTone: short_tone,
// long_tone:longTone
}
)
}
}
// randomly choose a version: 1 or 2
var version = 1;
//Manual condition assignment
//var shorty = 'f';
//var longy = 'j';
//welcome message//
var welcome = {
type: 'html-keyboard-response',
stimulus: 'Welcome to the experiment! Press any key to begin.'
};
//description of what the subject is about to hear (pretraining)//
var pretraining_instructions = {
type: "html-keyboard-response",
stimulus: "<p>We're going to play with two types of circles, a short circle and a long circle.</p>" +
"<p>Before each circle, I will tell you what type of circle it is.</p>"
//"<p>[Press any key to begin.]</p>"
};
//pretraining phase: showing participants short tones and a long tones//
var pretraining_short = {
timeline:[
{
type: 'html-keyboard-response',
stimulus: 'Look, it’s the short circle. It stays on for a short time.'
},
{
type: "audio-keyboard-response",
stimulus: "sound/1s.mp3",
choices: jsPsych.NO_KEYS,
prompt: "<div style='float: left;'><img src='img/blue.png'></img>",
trial_ends_after_audio: true
},
{
type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS,
trial_duration: 2000
}
]
}
var pretraining_long = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'Look, it’s the long circle. It stays on for a long time.'
},
{
type: "audio-keyboard-response",
stimulus: "sound/4s.mp3",
choices: jsPsych.NO_KEYS,
prompt: "<div style='float: left;'><img src='img/blue.png'></img>",
trial_ends_after_audio: true
},
{
type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS,
trial_duration: 2000
}
]
}
var pretraining = {
timeline: [
pretraining_short,
pretraining_long,
],
repetitions: 5
}
//training instructions//
var training_instructions_1_v1 = {
type: "html-keyboard-response",
stimulus: "<p>Now you're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'F' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'J' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var training_instructions_1_v2 = {
type: "html-keyboard-response",
stimulus: "<p>Now you're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'J' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'F' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
// get the trial info for this version
var training_instructions_1;
if (version == 1) {
training_instructions_1 = training_instructions_1_v1;
} else {
training_instructions_1 = training_instructions_1_v2;
}
var fixation = {
type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS,
trial_duration: function(){
return jsPsych.randomization.sampleWithReplacement([1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000],1)[0];
}
}
var training_audio_v1 = [
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'F'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'F'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'F'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'F'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'J'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'J'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'J'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'J'}},
]; //note: the code is like this so each trial will have p=.5 of appearing rather than randomizing 1s and 4s in pairs of trials
var training_audio_v2 = [
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'J'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'J'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'J'}},
{audio: "sound/1s.mp3", data: {stimulus_type: 'short', correct_response: 'J'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'F'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'F'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'F'}},
{audio: "sound/4s.mp3", data: {stimulus_type: 'long', correct_response: 'F'}},
]; //note: the code is like this so each trial will have p=.5 of appearing rather than randomizing 1s and 4s in pairs of trials
var training_audio;
if (version == 1) {
training_audio = training_audio_v1;
} else {
training_audio = training_audio_v2;
}
var training_stim = {
type: "audio-keyboard-response",
stimulus: jsPsych.timelineVariable('audio'),
choices: jsPsych.NO_KEYS,
prompt: "<div style='float: left;'><img src='img/blue.png'></img>",
trial_ends_after_audio: true
}
var training_trial_v1 = {
type: "html-keyboard-response",
stimulus: '',
choices: ['F', 'J'],
prompt: "<p>Was that the short circle or the long circle?</p>", //change comma to + if including short = F, long = j
//"<p>[Short = F]</p>" +
//"<p>[Long = J]</p>",
data: jsPsych.timelineVariable('data'),
on_finish: function(data){
data.responses = jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press);
data.correct = data.key_press == jsPsych.pluginAPI.convertKeyCharacterToKeyCode(data.correct_response);
},
}
var training_trial_v2 = {
type: "html-keyboard-response",
stimulus: '',
choices: ['F', 'J'],
prompt: "<p>Was that the short circle or the long circle?</p>", //change comma to + if including short = F, long = j
//"<p>[Short = J]</p>" +
//"<p>[Long = F]</p>",
data: jsPsych.timelineVariable('data'),
on_finish: function(data){
data.responses = jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press);
data.correct = data.key_press == jsPsych.pluginAPI.convertKeyCharacterToKeyCode(data.correct_response);
},
}
var training_trial;
if (version == 1) {
training_trial = training_trial_v1;
} else {
training_trial = training_trial_v2;
}
var feedback = {
type: 'html-keyboard-response',
choices: jsPsych.NO_KEYS,
stimulus: function(){
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if(last_trial_correct){
return "<div style='float: left;'><img src='img/cathappy.png'></img>"
} else {
return "<div style='float: left;'><img src='img/catsad.png'></img>"
}
},
trial_duration: 2000
}
var training_1 = {
timeline: [fixation, training_stim, training_trial, feedback],
timeline_variables: training_audio,
repetitions: 1,
randomize_order: true
}
// get the trial info for this version
var training_instructions_2_setup_v1 = {
type: "html-keyboard-response",
stimulus: "<p>Good job! We're going to try that again.</p>" +
"<p>You're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'F' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'J' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var training_instructions_2_setup_v2 = {
type: "html-keyboard-response",
stimulus: "<p>Good job! We're going to try that again.</p>" +
"<p>You're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'J' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'F' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var training_instructions_2_setup;
if (version == 1) {
training_instructions_2_setup = training_instructions_2_setup_v1;
} else {
training_instructions_2_setup = training_instructions_2_setup_v2;
}
var training_instructions_2 = {
timeline: [training_instructions_2_setup],
conditional_function: function(){
var block1 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block1){
return false;
} else {
return true;
}
}
}
var training_2 = {
timeline: [training_1],
conditional_function: function(){
var block1 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block1){
return false;
} else {
return true;
}
}
}
// get the trial info for this version
var training_instructions_3_setup_v1 = {
type: "html-keyboard-response",
stimulus: "<p>Good job! We're going to try that one more time.</p>" +
"<p>You're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'F' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'J' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var training_instructions_3_setup_v2 = {
type: "html-keyboard-response",
stimulus: "<p>Good job! We're going to try that one more time.</p>" +
"<p>You're going to choose if the circle is short or long.</p>" +
"<p>If you get it right, you'll see a happy cat. If you get it wrong, you'll see a sad cat.</p>"
//"<p>Press 'J' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'F' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var training_instructions_3_setup;
if (version == 1) {
training_instructions_3_setup = training_instructions_3_setup_v1;
} else {
training_instructions_3_setup = training_instructions_3_setup_v2;
}
var training_instructions_3 = {
timeline: [training_instructions_3_setup],
conditional_function: function(){
var block2 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block2){
return false;
} else {
return true;
}
}
}
var training_3 = {
timeline: [training_1],
conditional_function: function(){
var block2 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block2){
return false;
} else {
return true;
}
}
}
//test instructions: description of what the subject is about to hear//
// get the trial info for this version
var test_instructions_setup_v1 = {
type: "html-keyboard-response",
stimulus: "<p>Now you're going to choose if the circle is short or long.</p>" +
"<p>It's the same game, but now the cats aren't here to tell you whether or not you’ve played well.</p>"
//"<p>Press 'F' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'J' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var test_instructions_setup_v2 = {
type: "html-keyboard-response",
stimulus: "<p>Now you're going to choose if the circle is short or long.</p>" +
"<p>It's the same game, but now the cats aren't here to tell you whether or not you’ve played well.</p>"
//"<p>Press 'J' if you think the sound you hear sounds more like the short sound.</p>" +
//"<p>Press 'F' if you think the sound you hear sounds more like the long sound.</p>" +
//"<p>[Press any key to begin.]</p>"
};
var test_instructions_setup;
if (version == 1) {
test_instructions_setup = test_instructions_setup_v1;
} else {
test_instructions_setup = test_instructions_setup_v2;
}
var test_instructions = {
timeline: [test_instructions_setup],
conditional_function: function(){
var block3 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block3){
return true;
} else {
return false;
}
}
}
//array for different test stimuli//
var test_stimuli = [
{audio: "sound/1s.mp3",},
{audio: "sound/1.5s.mp3"},
{audio: "sound/2s.mp3"},
{audio: "sound/2.5s.mp3"},
{audio: "sound/3s.mp3"},
{audio: "sound/3.5s.mp3"},
{audio: "sound/4s.mp3"}
];
var stim = {
type: "audio-keyboard-response",
stimulus: jsPsych.timelineVariable('audio'),
choices: jsPsych.NO_KEYS,
prompt: "<div style='float: left;'><img src='img/blue.png'></img>",
trial_ends_after_audio: true
}
var trial_v1 = {
type: "html-keyboard-response",
stimulus: '',
choices: ['F', 'J', '0', '1'],
prompt: "<p>Short or long?</p>"
//"<p>[Short = F]</p>"
//"<p>[Long = J]</p>",
data: jsPsych.timelineVariable('data'),
on_finish: function(data){
data.responses = jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press);
var id = jsPsych.data.get().filter({task_part: 'id_question'}).values()[0].participantID;
var file_name = 'SRP_' + id + '.csv';
if(jsPsych.pluginAPI.compareKeys(data.responses, "0")){
jsPsych.endExperiment("<p>Thank you for participating in this game!</p>"),
jsPsych.data.get().localSave('csv',file_name);
}
}
}
var trial_v2 = {
type: "html-keyboard-response",
stimulus: '',
choices: ['F', 'J', '0', '1'],
prompt: "<p>Short or long?</p>" +
"<p>[Short = J]</p>" +
"<p>[Long = F]</p>",
data: jsPsych.timelineVariable('data'),
on_finish: function(data){
data.responses = jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press);
var id = jsPsych.data.get().filter({task_part: 'id_question'}).values()[0].participantID;
var file_name = 'SRP_' + id + '.csv';
if(jsPsych.pluginAPI.compareKeys(data.responses, "0")){
jsPsych.endExperiment("<p>Thank you for participating in this game!</p>"),
jsPsych.data.get().localSave('csv',file_name);
}
}
}
var trial;
if (version == 1) {
trial = trial_v1;
} else {
trial = trial_v2;
}
var test_setup = {
timeline: [fixation, stim, trial],
timeline_variables: test_stimuli,
repetitions: 10,
randomize_order: true
}
var test = {
timeline: [test_setup],
conditional_function: function(){
var block3 = jsPsych.data.get().filter([{correct:true},{correct:false}]).last(8).filter({correct:true}).count() == 8;
if(block3){
return true;
} else {
return false;
}
}
}
//end message//
var ending = {
type: "html-keyboard-response",
stimulus: "<p>Thank you for participating in this game!</p>",
on_start: function(data){
var id = jsPsych.data.get().filter({task_part: 'id_question'}).values()[0].participantID;
var file_name = 'SRP_' + id + '.csv';
jsPsych.data.get().localSave('csv',file_name); // Saves a file on the computer running the experiment. First localSave argument is the format, second is the filename.
}
};
timeline.push(participant_info);
timeline.push(welcome);
//timeline.push(pretraining_instructions);
//timeline.push(pretraining);
//timeline.push(training_instructions_1)
//timeline.push(training_1)
//timeline.push(training_instructions_2)
//timeline.push(training_2)
//timeline.push(training_instructions_3)
//timeline.push(training_3)
timeline.push(test_instructions);
timeline.push(test);
timeline.push(ending);
jsPsych.init({
timeline: timeline,
use_webaudio: false,
preload_audio: ['sound/1s.mp3', 'sound/1.5s.mp3', 'sound/2s.mp3', 'sound/2.5s.mp3', 'sound/3s.mp3', 'sound/3.5s.mp3', 'sound/4s.mp3']
})
</script>
</html>