-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAffectiveProbabilisticReversalLearningTask_v1.html
1717 lines (1591 loc) · 81.4 KB
/
AffectiveProbabilisticReversalLearningTask_v1.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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!---Coded and designed by Maris Vainre, Becky Gilbert, and Marc Bennet.
When using this work, or any part of it, please cite it:
Maris Vainre, Becky Gilbert & Marc Bennett. Affective Probabilistic Reversal Learning Task using jsPsych. Github repository.
https://github.com/mvainre/affective-probabilistic-reversal-learning-task--->
<!DOCTYPE html>
<html>
<head>
<title>SWELL: The Fictional Football Cup</title>
<script src = "js/jquery.min.js" type="text/javascript"></script>
<script src="jspsych/jspsych.js"></script>
<script src="jspsych/plugins/jspsych-instructions.js"></script>
<script src="jspsych/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jspsych/plugins/jspsych-image-keyboard-response.js"></script>
<script src="jspsych/plugins/jspsych-vsl-grid-scene.js"></script>
<script src="jspsych/plugins/jspsych-fullscreen.js"></script>
<script src = "jatos.js"></script>
<link href="css/SwellStyle.css" rel="stylesheet" type="text/css">
<meta charset="utf-8">
<style>
/* here's the CSS if you want to change the padding around the images */
td {
padding: 0px 0px !important;
border: 0px !important;
}
</style>
</head>
<body></body>
<script type="text/javascript">
//task set-up:
//Participant needs to choose a winning team between two competing football teams. There are 4 teams and 2 set pairs.
//The side of the field is randomised (AB matches could be set up as A-B or B-A)
//Each match is preceded by an image that can be either negative or neutral in nature
//There are 3 phases in each condition. Conditions are counterbalanced.
//set up timeline
var timeline = [];
// set up how many trials are run per phase, the actual matches will be double that.
var numberOfTrials = 19; //19 here due to number of images available
//set up duration
var fixationDuration = 300;
var IAPSduration = 1500;
var stimulusDuration = 2000;
var postTrial_gap = 500;
var feedbackDuration = 1000;
var errorDuration = 1500;
//set up team logos
var logo1 = 'img/Logos/1.png';
var logo2 = 'img/Logos/2.png';
var logo3 = 'img/Logos/3.png';
var logo4 = 'img/Logos/4.png';
// create an array of all pictures in the IAPS database
var photoDatabase_neu_trial = ['img/IAPS/Neutral/2020.f.jpg',
'img/IAPS/Neutral/2020.jpg',
'img/IAPS/Neutral/2025.f.jpg',
'img/IAPS/Neutral/2025.jpg',
'img/IAPS/Neutral/2102.f.jpg',
'img/IAPS/Neutral/2102.jpg',
'img/IAPS/Neutral/2191.f.jpg',
'img/IAPS/Neutral/2191.jpg',
'img/IAPS/Neutral/2214.f.jpg',
'img/IAPS/Neutral/2214.jpg',
'img/IAPS/Neutral/2220.f.jpg',
'img/IAPS/Neutral/2220.jpg',
'img/IAPS/Neutral/2305.f.jpg',
'img/IAPS/Neutral/2305.jpg',
'img/IAPS/Neutral/2357.f.jpg',
'img/IAPS/Neutral/2357.jpg',
'img/IAPS/Neutral/2372.f.jpg',
'img/IAPS/Neutral/2372.jpg',
'img/IAPS/Neutral/2381.f.jpg',
'img/IAPS/Neutral/2381.jpg',
'img/IAPS/Neutral/2385.f.jpg',
'img/IAPS/Neutral/2385.jpg',
'img/IAPS/Neutral/2394.f.jpg',
'img/IAPS/Neutral/2394.jpg',
'img/IAPS/Neutral/2396.f.jpg',
'img/IAPS/Neutral/2396.jpg',
'img/IAPS/Neutral/2485.f.jpg',
'img/IAPS/Neutral/2485.jpg',
'img/IAPS/Neutral/2487.f.jpg',
'img/IAPS/Neutral/2487.jpg',
'img/IAPS/Neutral/2493.f.jpg',
'img/IAPS/Neutral/2493.jpg',
'img/IAPS/Neutral/2495.f.jpg',
'img/IAPS/Neutral/2495.jpg',
'img/IAPS/Neutral/2499.f.jpg',
'img/IAPS/Neutral/2499.jpg',
'img/IAPS/Neutral/2506.f.jpg',
'img/IAPS/Neutral/2506.jpg',
'img/IAPS/Neutral/2512.f.jpg',
'img/IAPS/Neutral/2512.jpg',
'img/IAPS/Neutral/2513.f.jpg',
'img/IAPS/Neutral/2513.jpg',
'img/IAPS/Neutral/2516.f.jpg',
'img/IAPS/Neutral/2516.jpg',
'img/IAPS/Neutral/2518.f.jpg',
'img/IAPS/Neutral/2518.jpg',
'img/IAPS/Neutral/2575.f.jpg',
'img/IAPS/Neutral/2575.jpg',
'img/IAPS/Neutral/2579.f.jpg',
'img/IAPS/Neutral/2579.jpg',
'img/IAPS/Neutral/2593.f.jpg',
'img/IAPS/Neutral/2593.jpg',
'img/IAPS/Neutral/2595.f.jpg',
'img/IAPS/Neutral/2595.jpg',
'img/IAPS/Neutral/2597.f.jpg',
'img/IAPS/Neutral/2597.jpg',
'img/IAPS/Neutral/2635.f.jpg',
'img/IAPS/Neutral/2635.jpg',
'img/IAPS/Neutral/2702.f.jpg',
'img/IAPS/Neutral/2702.jpg',
'img/IAPS/Neutral/2704.f.jpg',
'img/IAPS/Neutral/2704.jpg',
'img/IAPS/Neutral/2745.1.f.jpg',
'img/IAPS/Neutral/2745.1.jpg',
'img/IAPS/Neutral/2749.f.jpg',
'img/IAPS/Neutral/2749.jpg',
'img/IAPS/Neutral/2850.f.jpg',
'img/IAPS/Neutral/2850.jpg',
'img/IAPS/Neutral/2870.f.jpg',
'img/IAPS/Neutral/2870.jpg',
'img/IAPS/Neutral/3550.2.f.jpg',
'img/IAPS/Neutral/3550.2.jpg',
'img/IAPS/Neutral/4274.f.jpg',
'img/IAPS/Neutral/4274.jpg',
'img/IAPS/Neutral/4275.f.jpg',
'img/IAPS/Neutral/4275.jpg',
'img/IAPS/Neutral/4500.f.jpg',
'img/IAPS/Neutral/4500.jpg',
'img/IAPS/Neutral/4510.f.jpg',
'img/IAPS/Neutral/4510.jpg',
'img/IAPS/Neutral/4531.f.jpg',
'img/IAPS/Neutral/4531.jpg',
'img/IAPS/Neutral/4534.f.jpg',
'img/IAPS/Neutral/4534.jpg',
'img/IAPS/Neutral/4537.f.jpg',
'img/IAPS/Neutral/4537.jpg',
'img/IAPS/Neutral/4559.f.jpg',
'img/IAPS/Neutral/4559.jpg',
'img/IAPS/Neutral/4571.f.jpg',
'img/IAPS/Neutral/4571.jpg',
'img/IAPS/Neutral/4605.f.jpg',
'img/IAPS/Neutral/4605.jpg',
'img/IAPS/Neutral/6570.2.f.jpg',
'img/IAPS/Neutral/6570.2.jpg',
'img/IAPS/Neutral/7493.f.jpg',
'img/IAPS/Neutral/7493.jpg',
'img/IAPS/Neutral/7506.f.jpg',
'img/IAPS/Neutral/7506.jpg',
'img/IAPS/Neutral/7550.f.jpg',
'img/IAPS/Neutral/7550.jpg',
'img/IAPS/Neutral/8060.f.jpg',
'img/IAPS/Neutral/8060.jpg',
'img/IAPS/Neutral/8160.f.jpg',
'img/IAPS/Neutral/8160.jpg',
'img/IAPS/Neutral/8192.f.jpg',
'img/IAPS/Neutral/8192.jpg',
'img/IAPS/Neutral/8232.f.jpg',
'img/IAPS/Neutral/8232.jpg',
'img/IAPS/Neutral/8241.f.jpg',
'img/IAPS/Neutral/8241.jpg',
'img/IAPS/Neutral/8475.f.jpg',
'img/IAPS/Neutral/8475.jpg',
'img/IAPS/Neutral/9070.f.jpg',
'img/IAPS/Neutral/9070.jpg',
];
var photoDatabase_neg_trial = ['img/IAPS/Negative/2055.1.f.jpg',
'img/IAPS/Negative/2055.1.jpg',
'img/IAPS/Negative/2100.f.jpg',
'img/IAPS/Negative/2100.jpg',
'img/IAPS/Negative/2110.f.jpg',
'img/IAPS/Negative/2110.jpg',
'img/IAPS/Negative/2120.f.jpg',
'img/IAPS/Negative/2120.jpg',
'img/IAPS/Negative/2141.f.jpg',
'img/IAPS/Negative/2141.jpg',
'img/IAPS/Negative/2276.f.jpg',
'img/IAPS/Negative/2276.jpg',
'img/IAPS/Negative/2278.f.jpg',
'img/IAPS/Negative/2278.jpg',
'img/IAPS/Negative/2312.f.jpg',
'img/IAPS/Negative/2312.jpg',
'img/IAPS/Negative/2399.f.jpg',
'img/IAPS/Negative/2399.jpg',
'img/IAPS/Negative/2455.f.jpg',
'img/IAPS/Negative/2455.jpg',
'img/IAPS/Negative/2490.f.jpg',
'img/IAPS/Negative/2490.jpg',
'img/IAPS/Negative/2590.f.jpg',
'img/IAPS/Negative/2590.jpg',
'img/IAPS/Negative/2694.f.jpg',
'img/IAPS/Negative/2694.jpg',
'img/IAPS/Negative/2700.f.jpg',
'img/IAPS/Negative/2700.jpg',
'img/IAPS/Negative/2710.f.jpg',
'img/IAPS/Negative/2710.jpg',
'img/IAPS/Negative/2718.f.jpg',
'img/IAPS/Negative/2718.jpg',
'img/IAPS/Negative/2745.2.f.jpg',
'img/IAPS/Negative/2745.2.jpg',
'img/IAPS/Negative/2750.f.jpg',
'img/IAPS/Negative/2750.jpg',
'img/IAPS/Negative/2753.f.jpg',
'img/IAPS/Negative/2753.jpg',
'img/IAPS/Negative/2900.f.jpg',
'img/IAPS/Negative/2900.jpg',
'img/IAPS/Negative/3017.f.jpg',
'img/IAPS/Negative/3017.jpg',
'img/IAPS/Negative/3160.f.jpg',
'img/IAPS/Negative/3160.jpg',
'img/IAPS/Negative/3215.f.jpg',
'img/IAPS/Negative/3215.jpg',
'img/IAPS/Negative/3216.f.jpg',
'img/IAPS/Negative/3216.jpg',
'img/IAPS/Negative/3220.f.jpg',
'img/IAPS/Negative/3220.jpg',
'img/IAPS/Negative/3280.f.jpg',
'img/IAPS/Negative/3280.jpg',
'img/IAPS/Negative/3300.f.jpg',
'img/IAPS/Negative/3300.jpg',
'img/IAPS/Negative/4621.f.jpg',
'img/IAPS/Negative/4621.jpg',
'img/IAPS/Negative/6010.f.jpg',
'img/IAPS/Negative/6010.jpg',
'img/IAPS/Negative/6242.f.jpg',
'img/IAPS/Negative/6242.jpg',
'img/IAPS/Negative/6311.f.jpg',
'img/IAPS/Negative/6311.jpg',
'img/IAPS/Negative/6562.f.jpg',
'img/IAPS/Negative/6562.jpg',
'img/IAPS/Negative/6571.f.jpg',
'img/IAPS/Negative/6571.jpg',
'img/IAPS/Negative/6825.f.jpg',
'img/IAPS/Negative/6825.jpg',
'img/IAPS/Negative/6831.f.jpg',
'img/IAPS/Negative/6831.jpg',
'img/IAPS/Negative/6836.f.jpg',
'img/IAPS/Negative/6836.jpg',
'img/IAPS/Negative/8231.f.jpg',
'img/IAPS/Negative/8231.jpg',
'img/IAPS/Negative/9007.f.jpg',
'img/IAPS/Negative/9007.jpg',
'img/IAPS/Negative/9041.f.jpg',
'img/IAPS/Negative/9041.jpg',
'img/IAPS/Negative/9046.f.jpg',
'img/IAPS/Negative/9046.jpg',
'img/IAPS/Negative/9190.f.jpg',
'img/IAPS/Negative/9190.jpg',
'img/IAPS/Negative/9265.f.jpg',
'img/IAPS/Negative/9265.jpg',
'img/IAPS/Negative/9270.f.jpg',
'img/IAPS/Negative/9270.jpg',
'img/IAPS/Negative/9331.f.jpg',
'img/IAPS/Negative/9331.jpg',
'img/IAPS/Negative/9341.f.jpg',
'img/IAPS/Negative/9341.jpg',
'img/IAPS/Negative/9404.f.jpg',
'img/IAPS/Negative/9404.jpg',
'img/IAPS/Negative/9415.f.jpg',
'img/IAPS/Negative/9415.jpg',
'img/IAPS/Negative/9417.f.jpg',
'img/IAPS/Negative/9417.jpg',
'img/IAPS/Negative/9419.f.jpg',
'img/IAPS/Negative/9419.jpg',
'img/IAPS/Negative/9426.f.jpg',
'img/IAPS/Negative/9426.jpg',
'img/IAPS/Negative/9427.f.jpg',
'img/IAPS/Negative/9427.jpg',
'img/IAPS/Negative/9430.f.jpg',
'img/IAPS/Negative/9430.jpg',
'img/IAPS/Negative/9452.f.jpg',
'img/IAPS/Negative/9452.jpg',
'img/IAPS/Negative/9490.f.jpg',
'img/IAPS/Negative/9490.jpg',
'img/IAPS/Negative/9520.f.jpg',
'img/IAPS/Negative/9520.jpg',
'img/IAPS/Negative/9530.f.jpg',
'img/IAPS/Negative/9530.jpg',
'img/IAPS/Negative/9584.f.jpg',
'img/IAPS/Negative/9584.jpg',
'img/IAPS/Negative/9900.f.jpg',
'img/IAPS/Negative/9900.jpg',
'img/IAPS/Negative/9926.f.jpg',
'img/IAPS/Negative/9926.jpg',
];
var logo_size = 300; // pixelscc
var image_size = 500;
// make the experiment to be fullscreen to avoid distractions
timeline.push({
type: 'fullscreen',
fullscreen_mode: true
});
// set up which keys to press for answering
let choices = ["c", "n"];
// create global variables to store information that you want to pass between trials/functions
var phase1LoserAB = '';
var phase1WinnerAB = '';
var phase1LoserCD = '';
var phase1WinnerCD = '';
// set up trial counter
let currentTrialNumber = 1;
var Phase1_trialnumber = 1;
var Phase2_trialnumber = 1;
var Phase3_trialnumber = 1;
var Phase4_trialnumber = 1;
var Phase5_trialnumber = 1;
var Phase6_trialnumber = 1;
// collecting the trial info variables into this globally scoped object
var trialInfo = {
phase: 1,
teamLeft: '',
teamRight: '',
IAPSconditionSelected: '',
pointsTotal: 0
};
// assign team logos to teams randomly. This ensures that across participants, different "logos" play against each other.
var logos = [logo1, logo2, logo3, logo4];
var shuffleLogos = jsPsych.randomization.shuffle(logos);
var teamA = shuffleLogos[0];
var teamB = shuffleLogos[1];
var teamC = shuffleLogos[2];
var teamD = shuffleLogos[3];
// just checking if all's running well:
console.log("Team A is: " + teamA);
console.log("Team B is: " + teamB);
console.log("Team C is: " + teamC);
console.log("Team D is: " + teamD);
/* define welcome message*/
var welcome = {
type: "html-keyboard-response",
stimulus: "<h1>The Fictional Football Match Game</h1>" +
"<p>Thank you for taking your time to participate in this study! </p><h2>Press any key to start</h2>"
};
timeline.push(welcome);
var instructions1 = {
type: 'instructions',
pages: ["<h1>Get settled in for the next 15 minutes</h1>" +
"<p>Make sure you're <b>sitting comfortably</b>.<br><br><h1>🔕</h1>Shield yourself from <b>distractions</b>: <br>📴 <b>mute</b> your phone and <br>📩 e-mail alerts </p>" +
"<h2><br>Ready? Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions1);
var instructions3 = {
type: 'instructions',
pages: ["<h1>⚽</h1><p>This game is about <b>guessing which fictional football team won</b> a hypothetical match.</p>"+
"<p>The teams played in a mini-league. <br>The same two teams played against each other over an entire season.</p>" +
"<h2><br>Press space to see the matches</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions3);
//Display the teams' logos in pairs in which they will appear
var teamsAB = [
[teamA, 0, teamB]
];
var teamsAB_demo_prep = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(teamsAB, [logo_size, logo_size]);
var teamsAB_demo = {
type: 'html-keyboard-response',
stimulus: teamsAB_demo_prep,
choices: [32],
prompt: "<h2>Press space to see the next match</h2>",
stimulus_duration: null,
trial_duration: null,
response_ends_trial: true
};
timeline.push(teamsAB_demo);
var teamsCD = [
[teamC, 0, teamD]
];
var teamsCD_demo_prep = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(teamsCD, [logo_size, logo_size]);
var teamsCD_demo = {
type: 'html-keyboard-response',
stimulus: teamsCD_demo_prep,
choices: [32],
prompt: "<p>That's it!</p><h2>Press space to continue</h2>",
//stimulus_duration: stimulusDuration,
trial_duration: null,
response_ends_trial: true
};
timeline.push(teamsCD_demo);
var instructions4 = {
type: 'instructions',
pages: ["<h1>🏆</h1>"+
"<h2>Your job is simple: <br>guess which team won each match</h2>"+
"<p>Select the team that you think was most likely to win that match. <br>Do this by pressing the right key: <br><b>C-key = team on the left. N-key = team on the right.</b></p>" +
"<h2><br>Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions4);
var instructions5 = {
type: 'instructions',
pages: [
"<h1>💰</h1>" +
"<p>Correct guesses will win you some (hypothetical) cash: <br><b>£0.10</b> to be precise. <br>If you guess wrong, don't worry - you won't lose any money.</p>" +
"<p><b>Your goal is to earn as much fictional £££ as possible</b> by the end of the season.</p>" +
"<h2><br>Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions5);
var instructions6 = {
type: 'instructions',
pages: [
"<h1>🤔</h1>" +
"<p>At first, you might not be sure who was likely to win but <br><b>soon you might develop an idea about which team was stronger</b> <br>at a given time in the season.<p>"+
"<h2><br>Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions6);
var instructions7 = {
type: 'instructions',
pages: [
"<h1>🥅<br>Stay focused!</h1>" +
"<p>While <b>one team is always much more likely to win</b> than the other, <br>the good team may have had a particularly bad game or <br>they may be going through a bad patch so the other team is more likely to win. <br><br>Use the feedback provided to guess the winner and <br>win as much non-real £££ as you can.</p>" +
"<h2><br>Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions7);
var instructions8 = {
type: 'instructions',
pages: [
"<p>Also, before each match, you'll see a photo. It's there to keep you alert. <br>It won't predict the result of the match.</p>"+
"<h2><br>Press space to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions8);
var instructions9 = {
type: 'instructions',
pages: ["<h1>⏱</h1>"+
"<h2>Try to be <b>as quick as possible</b> in your responses</h2>"+
"<p>To make it faster, <br>put your left index finger on the C-key and your right index finger on the N-key.</b></p>"+
"<h2><br>Ready? Press space to start</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
timeline.push(instructions9);
// Set up elements that are universal across the task
// Gets triggered when response in the 5 last trials has been slower than 1200ms.
// It was initially 500ms and then 700ms but testing showed it was too quick and annoyed people.
// Only kicks in after 6 trials have run.
var too_slow_message = {
type: 'html-keyboard-response',
stimulus: '<h1 style="color:#ef476f;">Please respond faster</h1>',
trial_duration: errorDuration
};
var display_too_slow_message_conditional = {
timeline: [too_slow_message],
conditional_function: function() {
if (currentTrialNumber > 6) {
var meanrt_last5trials = jsPsych.data.get().filter({trial_element: 'match'}).last(5).select('rt').mean(); // takes the last 5 trials where choice needs to be made (labeled as match trials)
if (meanrt_last5trials > 1200) { // gets triggered if RT has been more than 1200ms
display_too_slow_message = true;
console.log('I am being too slow. RT so far: ' + meanrt_last5trials);
return true;
} else {
display_too_slow_message = false;
console.log('going fast enough!. RT so far: ' + meanrt_last5trials);
return false;
}
} else {
console.log('trial number not yet 5. Current one: ' + currentTrialNumber);
return false;
}
}
};
// Gets triggered when no keyboard response has made for the last 3 trials where response is needed. The trial is paused and will continue when space is pressed.
var instructions_break1 = {
type: 'instructions',
pages: ["<h1>Need a break?</h1>" +
"<p>Have a good stretch if so.</p>" +
"<h2><br>Press space when you're ready to continue</h2>"],
key_forward: 32, // code for space
show_clickable_nav: false
};
var display_haveabreak_message_conditional = {
timeline: [instructions_break1],
conditional_function: function() {
if (currentTrialNumber > 2) {
var trial_totalmisses = jsPsych.data.get().filter({trial_element: 'match', key_press: null}).count(); // this is just to test the function in console. It has no functionality for the function and can be deleted.
var trial_last3matches = jsPsych.data.get().filter({trial_element: 'match'}).last(3); // count the last 3 trials that are matches (ie where keypress is needed):
var trial_last3matches_misses = trial_last3matches.filter({key_press: null}).count(); // count the number of times where there were no keypress (a proxy that the participant may not be paying attention);
console.log('trials misses ' + trial_totalmisses + ' out of ' + currentTrialNumber + ' trials. Number of trials missed in the last 3: ' + trial_last3matches_misses);
if (trial_last3matches_misses == 3) { // gets triggered if missed at least 3 trials
display_haveabreak_message = true;
console.log('Should I have a break? I have missed many trials: ' + trial_last3matches_misses);
return true;
} else {
display_haveabreak_message = false;
console.log('No need for a break! Only missed few trials: ' + trial_last3matches_misses);
return false;
}
} else {
console.log('trial number not yet 3. Current one: ' + currentTrialNumber);
return false;
}
},
};
// first show fixation
var fixation = {
type: 'html-keyboard-response',
stimulus: '<span style="font-size:60px;">+</span>',
choices: jsPsych.NO_KEYS,
trial_duration: fixationDuration
}
// choose which which affective condition comes first negative or neutral
var IAPSconditions = ['neg', 'neu'];
var shuffleIAPSconditions = jsPsych.randomization.shuffle(IAPSconditions);
var IAPScondition1 = shuffleIAPSconditions[0];
var IAPScondition2 = shuffleIAPSconditions[1];
// shuffle IAPS images so that the order is different for each participant
var shuffleIAPSneg = jsPsych.randomization.shuffle(photoDatabase_neg_trial)
var shuffleIAPSneu = jsPsych.randomization.shuffle(photoDatabase_neu_trial)
// pick the IAPS images in the order in which they got shuffled
function choose_IAPSimage() {
console.log('condition: ', IAPScondition1);
if (IAPScondition1 == 'neg') {
IAPSimage = shuffleIAPSneg[currentTrialNumber-1]; //Subtracting 1 because javascript starts indexing at 0. So the first image is [0]
} else {
IAPSimage = shuffleIAPSneu[currentTrialNumber-1];
};
console.log('image selected: ', IAPSimage);
return [[IAPSimage]];
}
// now show the image on screen
var pick_IAPSimage = {
type: 'html-keyboard-response',
stimulus: function() {
// need to wrap all of this in a function so that it runs on every repetition of the trial
var curr_image = choose_IAPSimage();
return jsPsych.plugins['vsl-grid-scene'].generate_stimulus(curr_image, [image_size]);
},
choices: jsPsych.NO_KEYS,
prompt: "",
trial_duration: IAPSduration,
data: function () {
return {
trial_element: "iaps image",
image_shown: IAPSimage,
affect: IAPScondition1
};
},
};
// pick the winner for the first phase AB and CD matches at random
var ABmatches = [teamA, teamB];
var shuffleABmatches = jsPsych.randomization.shuffle(ABmatches);
var phase1WinnerAB = shuffleABmatches[1];
var phase1LoserAB = shuffleABmatches[0];
console.log('phase 1 winner AB: ', phase1WinnerAB);
console.log('phase 1 loser AB: ', phase1LoserAB);
var CDmatches = [teamC, teamD];
var shuffleCDmatches = jsPsych.randomization.shuffle(CDmatches);
var phase1WinnerCD = shuffleCDmatches[1];
var phase1LoserCD = shuffleCDmatches[0];
console.log('phase 1 winner CD: ', phase1WinnerCD);
console.log('phase 1 loser CD: ', phase1LoserCD);
//////// PHASE 1 ///////
//set up trial Phase1 1. numberOfTrials controls how many times this thing loops (1 trial in this code is fixation + IAPS + AB-match + feedback + fixation + IAPS + CD-match + feedback).
// participant will be shown a fixation cross, then a IAPS image that is either neutral or negative, and then the match
function chooseLayout_subsequent_Phase1 (matchType) {
console.log('match type: ', matchType);
if (matchType == 'ab') {
// create an array of all teams
var teams = [teamA, teamB];
// pick layout at random so all are equally likely. That is, pick the team that is on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamA) {
trialInfo_teamLeft = teamA;
trialInfo_teamRight = teamB;
} else {
trialInfo_teamLeft = teamB;
trialInfo_teamRight = teamA
}
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
} else {
// create an array of teams
var teams = [teamC, teamD];
// pick layout at random so all are equally likely. Pick the team that will be on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamC) {
trialInfo_teamLeft = teamC; // adding trialInfo_Phase1 so that this can be accessed outside the function
trialInfo_teamRight = teamD;
} else {
trialInfo_teamLeft = teamD;
trialInfo_teamRight = teamC
};
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
}
}
// set up A-B trial for use in phase 1 looping trial procedure
var match_phase1_subsequentAB = {
type: 'html-keyboard-response',
stimulus: function() {
// need to wrap all of this in a function so that it runs on every repetition of the trial
var curr_layout = chooseLayout_subsequent_Phase1('ab');
var vsl_layout = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(curr_layout, [logo_size, logo_size]);
return vsl_layout;
},
choices: choices,
prompt: "Who will win? Press C or N",
trial_duration: stimulusDuration,
data: function() {
return {
phase: 1,
trial_element: "match",
condition: IAPScondition1,
PhaseTrialNumber: Phase1_trialnumber,
teamLeft: trialInfo_teamLeft,
teamRight: trialInfo_teamRight,
phase1Winner: phase1WinnerAB,
points_cumulative_excludingThisTrial: jsPsych.data.get().select('pointsTotal').max()
};
},
on_finish: function(data) {
Phase1_trialnumber += 1;
currentTrialNumber += 1;
// choose the winner
var matchPlayers = [phase1WinnerAB, phase1LoserAB];
var matchOutcome = jsPsych.randomization.sampleWithReplacement(matchPlayers, 1, [80, 20])[0]; //winning team has a 80% chance of winning
console.log('trial winner: ', matchOutcome);
// add match winner to data
data.match_winner = matchOutcome;
var selected_team;
if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "c") {
// if c key was pressed, then the participant chose whichever team was on the left
selected_team = trialInfo_teamLeft;
} else if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "n") {
// if c key was pressed, then the participant chose whichever team was on the right
selected_team = trialInfo_teamRight;
}
console.log('selected team: ', selected_team);
// add selected team to data
data.selected_team = selected_team;
// compare the winning team with the selected team
if (selected_team == matchOutcome) {
console.log('correct selection');
data.accuracy = true;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0.10;
data.pointsTotal = trialInfo.pointsTotal;
console.log('points: ' + trialInfo.pointsTotal);
} else {
console.log('incorrect selection');
data.accuracy = false;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0;
data.pointsTotal = trialInfo.pointsTotal;
console.log('points: ' + trialInfo.pointsTotal);
}
}
};
// set up C-D trial for use in phase 1 looping trial procedure
var match_phase1_subsequentCD = {
type: 'html-keyboard-response',
stimulus: function() {
// need to wrap all of this in a function so that it runs on every repetition of the trial
var curr_layout = chooseLayout_subsequent_Phase1('cd');
var vsl_layout = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(curr_layout, [logo_size, logo_size]);
return vsl_layout;
},
choices: choices,
prompt: "Who will win? Press C or N",
trial_duration: stimulusDuration,
data: function() {
return {
phase: 1,
trial_element: "match",
condition: IAPScondition1,
trialNumber: Phase1_trialnumber,
teamLeft: trialInfo_teamLeft,
teamRight: trialInfo_teamRight,
phase1Winner: phase1WinnerCD,
points_cumulative_excludingThisTrial: jsPsych.data.get().select('pointsTotal').max()
};
},
on_finish: function(data) {
Phase1_trialnumber += 1;
currentTrialNumber += 1;
// choose the winner
var matchPlayers = [phase1WinnerCD, phase1LoserCD];
var matchOutcome = jsPsych.randomization.sampleWithReplacement(matchPlayers, 1, [80, 20])[0]; //winning team has a 80% chance of winning
console.log('trial winner: ', matchOutcome);
// add match winner to data
data.match_winner = matchOutcome;
var selected_team;
if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "c") {
// if c key was pressed, then the participant chose whichever team was on the left
selected_team = trialInfo_teamLeft;
} else if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "n") {
// if n key was pressed, then the participant chose whichever team was on the right
selected_team = trialInfo_teamRight;
}
console.log('selected team: ', selected_team);
// add selected team to data
data.selected_team = selected_team;
// compare the winning team with the selected team
// phase 1 winner/loser is just used to set the sampling weights so that the winner is selected more often)
if (selected_team == matchOutcome) {
console.log('correct selection');
data.accuracy = true;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0.10;
console.log('points: ' + trialInfo.pointsTotal);
} else {
console.log('incorrect selection');
data.accuracy = false;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0;
console.log('points: ' + trialInfo.pointsTotal);
}
}
};
// set up points feedback screen for use in phase 1 looping trial procedure
var points_tracker_inloop = {
type: 'html-keyboard-response',
stimulus: function () {
var points_feedback = '<span style="color:#584b53;font-size:20px;">£0.00</span>';
var last_match_correct = jsPsych.data.getLastTrialData().values()[0].accuracy;
if (last_match_correct == true) {
points_feedback = '<span style="color:#06d6a0;font-size:20px;">+£0.10</span>'
}
return points_feedback;
},
trial_duration: feedbackDuration
};
var trial_procedure_phase1_loop = {
timeline: [fixation, pick_IAPSimage, match_phase1_subsequentAB, points_tracker_inloop, display_too_slow_message_conditional, display_haveabreak_message_conditional, fixation, pick_IAPSimage, match_phase1_subsequentCD, points_tracker_inloop],
repetitions: numberOfTrials,
};
// add phase 1 looping procedure to the main timeline
timeline.push(trial_procedure_phase1_loop);
//////// PHASE 2 ////////
//The probability will now be reversed but the condition stays same. Everything else is also the same.
function chooseLayout_subsequent_Phase2 (matchType) {
console.log('match type: ', matchType);
if (matchType == 'ab') {
// create an array of all teams
var teams = [teamA, teamB];
// pick layout at random so all are equally likely. That is, pick the team that is on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamA) {
trialInfo_teamLeft = teamA;
trialInfo_teamRight = teamB;
} else {
trialInfo_teamLeft = teamB;
trialInfo_teamRight = teamA
}
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
} else {
// create an array of teams
var teams = [teamC, teamD];
// pick layout at random so all are equally likely. Pick the team that will be on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamC) {
trialInfo_teamLeft = teamC; // adding trialInfo_Phase1 so that this can be accessed outside the function
trialInfo_teamRight = teamD;
} else {
trialInfo_teamLeft = teamD;
trialInfo_teamRight = teamC
};
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
}
}
// set up A-B trial for use in phase 1 looping trial procedure
var match_phase2_subsequentAB = {
type: 'html-keyboard-response',
stimulus: function() {
// need to wrap all of this in a function so that it runs on every repetition of the trial
var curr_layout = chooseLayout_subsequent_Phase2('ab');
var vsl_layout = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(curr_layout, [logo_size, logo_size]);
return vsl_layout;
},
choices: choices,
prompt: "Who will win? Press C or N",
trial_duration: stimulusDuration,
data: function() {
return {
phase: 2,
trial_element: "match",
condition: IAPScondition1,
trialNumber: Phase2_trialnumber,
teamLeft: trialInfo_teamLeft,
teamRight: trialInfo_teamRight,
phase2Winner: phase1LoserAB,
points_cumulative_excludingThisTrial: jsPsych.data.get().select('pointsTotal').max()
};
},
on_finish: function(data) {
Phase2_trialnumber += 1;
currentTrialNumber += 1;
// choose the winner
var matchPlayers = [phase1WinnerAB, phase1LoserAB];
var matchOutcome = jsPsych.randomization.sampleWithReplacement(matchPlayers, 1, [20, 80])[0];
console.log('trial winner: ', matchOutcome);
// add match winner to data
data.match_winner = matchOutcome;
var selected_team;
if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "c") {
// if c key was pressed, then the participant chose whichever team was on the left
selected_team = trialInfo_teamLeft;
} else if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "n") {
// if c key was pressed, then the participant chose whichever team was on the right
selected_team = trialInfo_teamRight;
}
console.log('selected team: ', selected_team);
// add selected team to data
data.selected_team = selected_team;
// compare the winning team with the selected team
if (selected_team == matchOutcome) {
console.log('correct selection');
data.accuracy = true;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0.10;
data.pointsTotal = trialInfo.pointsTotal;
console.log('points: ' + trialInfo.pointsTotal);
} else {
console.log('incorrect selection');
data.accuracy = false;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0;
data.pointsTotal = trialInfo.pointsTotal;
console.log('points: ' + trialInfo.pointsTotal);
}
}
};
// set up C-D trial for use in phase 1 looping trial procedure
var match_phase2_subsequentCD = {
type: 'html-keyboard-response',
stimulus: function() {
// need to wrap all of this in a function so that it runs on every repetition of the trial
var curr_layout = chooseLayout_subsequent_Phase2('cd');
var vsl_layout = jsPsych.plugins['vsl-grid-scene'].generate_stimulus(curr_layout, [logo_size, logo_size]);
return vsl_layout;
},
choices: choices,
prompt: "Who will win? Press C or N",
trial_duration: stimulusDuration,
data: function() {
return {
phase: 2,
trial_element: "match",
condition: IAPScondition1,
trialNumber: Phase2_trialnumber,
teamLeft: trialInfo_teamLeft,
teamRight: trialInfo_teamRight,
phase2Winner: phase1LoserCD,
points_cumulative_excludingThisTrial: jsPsych.data.get().select('pointsTotal').max()
};
},
on_finish: function (data) {
Phase2_trialnumber += 1;
currentTrialNumber += 1;
// choose the winner
var matchPlayers = [phase1WinnerCD, phase1LoserCD];
var matchOutcome = jsPsych.randomization.sampleWithReplacement(matchPlayers, 1, [20, 80])[0];
console.log('trial winner: ', matchOutcome);
// add match winner to data
data.match_winner = matchOutcome;
var selected_team;
if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "c") {
// if c key was pressed, then the participant chose whichever team was on the left
selected_team = trialInfo_teamLeft;
} else if (jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press) == "n") {
// if n key was pressed, then the participant chose whichever team was on the right
selected_team = trialInfo_teamRight;
}
console.log('selected team: ', selected_team);
// add selected team to data
data.selected_team = selected_team;
// compare the winning team with the selected team
// phase 1 winner/loser is just used to set the sampling weights so that the winner is selected more often)
if (selected_team == matchOutcome) {
console.log('correct selection');
data.accuracy = true;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0.10;
console.log('points: ' + trialInfo.pointsTotal);
} else {
console.log('incorrect selection');
data.accuracy = false;
trialInfo.pointsTotal = trialInfo.pointsTotal + 0;
console.log('points: ' + trialInfo.pointsTotal);
}
}
};
var trial_procedure_phase2_loop = {
timeline: [fixation, pick_IAPSimage, match_phase2_subsequentAB, points_tracker_inloop, display_too_slow_message_conditional, display_haveabreak_message_conditional, fixation, pick_IAPSimage, match_phase2_subsequentCD, points_tracker_inloop],
repetitions: numberOfTrials,
};
// add phase 2 looping procedure to the main timeline
timeline.push(trial_procedure_phase2_loop);
//////// PHASE 3 ////////
// this is essentially the same as Phase 1
function chooseLayout_subsequent_Phase3 (matchType) {
console.log('match type: ', matchType);
if (matchType == 'ab') {
// create an array of all teams
var teams = [teamA, teamB];
// pick layout at random so all are equally likely. That is, pick the team that is on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamA) {
trialInfo_teamLeft = teamA;
trialInfo_teamRight = teamB;
} else {
trialInfo_teamLeft = teamB;
trialInfo_teamRight = teamA
}
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
} else {
// create an array of teams
var teams = [teamC, teamD];
// pick layout at random so all are equally likely. Pick the team that will be on the left.
var layoutSelected = jsPsych.randomization.sampleWithReplacement(teams, 1, [1, 1])[0];
if (layoutSelected == teamC) {
trialInfo_teamLeft = teamC; // adding trialInfo_Phase1 so that this can be accessed outside the function
trialInfo_teamRight = teamD;
} else {
trialInfo_teamLeft = teamD;
trialInfo_teamRight = teamC
};
return [[trialInfo_teamLeft, 0, trialInfo_teamRight]];
}
}
// set up A-B trial for use in phase 3 looping trial procedure
var match_phase3_subsequentAB = {
type: 'html-keyboard-response',