forked from emmetaobrien/semt-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSEMT.js
2138 lines (1789 loc) · 69.9 KB
/
SEMT.js
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
/*************
* Semt Test *
*************/
import { PsychoJS } from './lib/core-2021.1.4.js';
import * as core from './lib/core-2021.1.4.js';
import { TrialHandler } from './lib/data-2021.1.4.js';
import { Scheduler } from './lib/util-2021.1.4.js';
import * as visual from './lib/visual-2021.1.4.js';
import * as sound from './lib/sound-2021.1.4.js';
import * as util from './lib/util-2021.1.4.js';
//some handy aliases as in the psychopy scripts;
const { abs, sin, cos, PI: pi, sqrt } = Math;
const { round } = util;
// init psychoJS:
const psychoJS = new PsychoJS({
debug: true
});
// open window:
psychoJS.openWindow({
fullscr: true,
color: new util.Color([1, 1, 1]),
units: 'height',
waitBlanking: true
});
// store info about the experiment session:
let expName = 'SEMT'; // from the Builder filename that created this script
let expInfo = {'participant': '', 'session': '001'};
// Start code blocks for 'Before Experiment'
// schedule the experiment:
psychoJS.schedule(psychoJS.gui.DlgFromDict({
dictionary: expInfo,
title: expName
}));
const flowScheduler = new Scheduler(psychoJS);
const dialogCancelScheduler = new Scheduler(psychoJS);
psychoJS.scheduleCondition(function() { return (psychoJS.gui.dialogComponent.button === 'OK'); }, flowScheduler, dialogCancelScheduler);
// flowScheduler gets run if the participants presses OK
flowScheduler.add(updateInfo); // add timeStamp
flowScheduler.add(experimentInit);
flowScheduler.add(langRoutineBegin());
flowScheduler.add(langRoutineEachFrame());
flowScheduler.add(langRoutineEnd());
flowScheduler.add(instrRoutineBegin());
flowScheduler.add(instrRoutineEachFrame());
flowScheduler.add(instrRoutineEnd());
const prac_repeatLoopScheduler = new Scheduler(psychoJS);
flowScheduler.add(prac_repeatLoopBegin, prac_repeatLoopScheduler);
flowScheduler.add(prac_repeatLoopScheduler);
flowScheduler.add(prac_repeatLoopEnd);
flowScheduler.add(readyRoutineBegin());
flowScheduler.add(readyRoutineEachFrame());
flowScheduler.add(readyRoutineEnd());
flowScheduler.add(cntdownRoutineBegin());
flowScheduler.add(cntdownRoutineEachFrame());
flowScheduler.add(cntdownRoutineEnd());
const trials_repeatLoopScheduler = new Scheduler(psychoJS);
flowScheduler.add(trials_repeatLoopBegin, trials_repeatLoopScheduler);
flowScheduler.add(trials_repeatLoopScheduler);
flowScheduler.add(trials_repeatLoopEnd);
flowScheduler.add(thanksRoutineBegin());
flowScheduler.add(thanksRoutineEachFrame());
flowScheduler.add(thanksRoutineEnd());
flowScheduler.add(quitPsychoJS, '', true);
// quit if user presses Cancel in dialog box:
dialogCancelScheduler.add(quitPsychoJS, '', false);
psychoJS.start({
expName: expName,
expInfo: expInfo,
resources: [
{'name': 'left_cr.jpg', 'path': 'left_cr.jpg'},
{'name': 'right_cr.jpg', 'path': 'right_cr.jpg'}
]
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.DEBUG);
var frameDur;
function updateInfo() {
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2021.1.4';
expInfo['OS'] = window.navigator.platform;
// store frame rate of monitor if we can measure it successfully
expInfo['frameRate'] = psychoJS.window.getActualFrameRate();
if (typeof expInfo['frameRate'] !== 'undefined')
frameDur = 1.0 / Math.round(expInfo['frameRate']);
else
frameDur = 1.0 / 60.0; // couldn't get a reliable measure so guess
// add info from the URL:
util.addInfoFromUrl(expInfo);
return Scheduler.Event.NEXT;
}
var langClock;
var text_lang;
var key_lang;
var instrClock;
var instr_text_1;
var instr_text_2;
var instr_text_3;
var instr_text_4;
var instr_text_5;
var pracClock;
var item1_img_pr;
var brL_img_pr;
var que_text_pr;
var item2_img_pr;
var brR_img_pr;
var response_pr;
var timer_pr;
var fix_text_pr;
var key_prac;
var transitionClock;
var txt_transi;
var key_transi;
var readyClock;
var txt_rdy;
var key_rdy;
var cntdownClock;
var timer_ctdown;
var trialClock;
var item1_img;
var brL_img;
var que_text;
var item2_img;
var brR_img;
var response;
var timer;
var fix_text;
var key;
var restClock;
var txt_rest;
var key_rest;
var ready_2Clock;
var txt_rdy2;
var key_rdy2;
var cntdown_2Clock;
var timer_ctdown2;
var thanksClock;
var txt_thx;
var globalClock;
var routineTimer;
function experimentInit() {
// Initialize components for Routine "lang"
langClock = new util.Clock();
text_lang = new visual.TextStim({
win: psychoJS.window,
name: 'text_lang',
text: 'Veuillez sélectionner votre langue.\nAppuyez sur 1 pour Français.\n\nPlease select your language.\nPress 2 for English.',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
key_lang = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "instr"
instrClock = new util.Clock();
instr_text_1 = new visual.TextStim({
win: psychoJS.window,
name: 'instr_text_1',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
instr_text_2 = new visual.TextStim({
win: psychoJS.window,
name: 'instr_text_2',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -2.0
});
instr_text_3 = new visual.TextStim({
win: psychoJS.window,
name: 'instr_text_3',
text: 'Any text\n\nincluding line breaks',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -3.0
});
instr_text_4 = new visual.TextStim({
win: psychoJS.window,
name: 'instr_text_4',
text: 'Any text\n\nincluding line breaks',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -4.0
});
instr_text_5 = new visual.TextStim({
win: psychoJS.window,
name: 'instr_text_5',
text: 'Any text\n\nincluding line breaks',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0.0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1.0,
depth: -5.0
});
// Initialize components for Routine "prac"
pracClock = new util.Clock();
item1_img_pr = new visual.ImageStim({
win : psychoJS.window,
name : 'item1_img_pr', units : undefined,
image : undefined, mask : undefined,
ori : 0, pos : [0, 0], size : undefined,
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -1.0
});
brL_img_pr = new visual.ImageStim({
win : psychoJS.window,
name : 'brL_img_pr', units : undefined,
image : 'left_cr.jpg', mask : undefined,
ori : 0, pos : [(- 0.6), 0], size : [0.1, 0.6],
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -2.0
});
que_text_pr = new visual.TextStim({
win: psychoJS.window,
name: 'que_text_pr',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.06, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -3.0
});
item2_img_pr = new visual.ImageStim({
win : psychoJS.window,
name : 'item2_img_pr', units : undefined,
image : undefined, mask : undefined,
ori : 0, pos : [0, 0], size : undefined,
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -4.0
});
brR_img_pr = new visual.ImageStim({
win : psychoJS.window,
name : 'brR_img_pr', units : undefined,
image : 'right_cr.jpg', mask : undefined,
ori : 0, pos : [0.6, 0], size : [0.1, 0.6],
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -5.0
});
response_pr = new visual.TextStim({
win: psychoJS.window,
name: 'response_pr',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 0,
depth: -6.0
});
timer_pr = new visual.TextStim({
win: psychoJS.window,
name: 'timer_pr',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 0,
depth: -7.0
});
fix_text_pr = new visual.TextStim({
win: psychoJS.window,
name: 'fix_text_pr',
text: '+',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.11, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -8.0
});
key_prac = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "transition"
transitionClock = new util.Clock();
txt_transi = new visual.TextStim({
win: psychoJS.window,
name: 'txt_transi',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
key_transi = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "ready"
readyClock = new util.Clock();
txt_rdy = new visual.TextStim({
win: psychoJS.window,
name: 'txt_rdy',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: 1.1, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
key_rdy = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "cntdown"
cntdownClock = new util.Clock();
timer_ctdown = new visual.TextStim({
win: psychoJS.window,
name: 'timer_ctdown',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.08, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
// Initialize components for Routine "trial"
trialClock = new util.Clock();
item1_img = new visual.ImageStim({
win : psychoJS.window,
name : 'item1_img', units : undefined,
image : undefined, mask : undefined,
ori : 0, pos : [0, 0], size : undefined,
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -1.0
});
brL_img = new visual.ImageStim({
win : psychoJS.window,
name : 'brL_img', units : undefined,
image : 'left_cr.jpg', mask : undefined,
ori : 0, pos : [(- 0.6), 0], size : [0.1, 0.6],
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -2.0
});
que_text = new visual.TextStim({
win: psychoJS.window,
name: 'que_text',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.06, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -3.0
});
item2_img = new visual.ImageStim({
win : psychoJS.window,
name : 'item2_img', units : undefined,
image : undefined, mask : undefined,
ori : 0, pos : [0, 0], size : undefined,
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -4.0
});
brR_img = new visual.ImageStim({
win : psychoJS.window,
name : 'brR_img', units : undefined,
image : 'right_cr.jpg', mask : undefined,
ori : 0, pos : [0.6, 0], size : [0.1, 0.6],
color : new util.Color([1, 1, 1]), opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 512, interpolate : false, depth : -5.0
});
response = new visual.TextStim({
win: psychoJS.window,
name: 'response',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 0,
depth: -6.0
});
timer = new visual.TextStim({
win: psychoJS.window,
name: 'timer',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color('white'), opacity: 0,
depth: -7.0
});
fix_text = new visual.TextStim({
win: psychoJS.window,
name: 'fix_text',
text: '+',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.11, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -8.0
});
key = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "rest"
restClock = new util.Clock();
txt_rest = new visual.TextStim({
win: psychoJS.window,
name: 'txt_rest',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
key_rest = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "ready_2"
ready_2Clock = new util.Clock();
txt_rdy2 = new visual.TextStim({
win: psychoJS.window,
name: 'txt_rdy2',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
key_rdy2 = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "cntdown_2"
cntdown_2Clock = new util.Clock();
timer_ctdown2 = new visual.TextStim({
win: psychoJS.window,
name: 'timer_ctdown2',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.08, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
// Initialize components for Routine "thanks"
thanksClock = new util.Clock();
txt_thx = new visual.TextStim({
win: psychoJS.window,
name: 'txt_thx',
text: '',
font: 'Arial',
units: undefined,
pos: [0, 0], height: 0.04, wrapWidth: 1.1, ori: 0,
color: new util.Color([(- 1), (- 1), (- 1)]), opacity: 1,
depth: -1.0
});
// Create some handy timers
globalClock = new util.Clock(); // to track the time since experiment started
routineTimer = new util.CountdownTimer(); // to track time remaining of each (non-slip) routine
return Scheduler.Event.NEXT;
}
var t;
var frameN;
var continueRoutine;
var _key_lang_allKeys;
var langComponents;
function langRoutineBegin(snapshot) {
return function () {
//------Prepare to start Routine 'lang'-------
t = 0;
langClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
key_lang.keys = undefined;
key_lang.rt = undefined;
_key_lang_allKeys = [];
// keep track of which components have finished
langComponents = [];
langComponents.push(text_lang);
langComponents.push(key_lang);
for (const thisComponent of langComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;
}
}
function langRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'lang'-------
// get current time
t = langClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *text_lang* updates
if (t >= 0.0 && text_lang.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
text_lang.tStart = t; // (not accounting for frame time here)
text_lang.frameNStart = frameN; // exact frame index
text_lang.setAutoDraw(true);
}
// *key_lang* updates
if (t >= 0.0 && key_lang.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
key_lang.tStart = t; // (not accounting for frame time here)
key_lang.frameNStart = frameN; // exact frame index
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { key_lang.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_lang.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_lang.clearEvents(); });
}
if (key_lang.status === PsychoJS.Status.STARTED) {
let theseKeys = key_lang.getKeys({keyList: ['1', '2', 'esc'], waitRelease: false});
_key_lang_allKeys = _key_lang_allKeys.concat(theseKeys);
if (_key_lang_allKeys.length > 0) {
key_lang.keys = _key_lang_allKeys[_key_lang_allKeys.length - 1].name; // just the last key pressed
key_lang.rt = _key_lang_allKeys[_key_lang_allKeys.length - 1].rt;
}
}
// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({keyList:['escape']}).length > 0) {
return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
continueRoutine = false; // reverts to True if at least one component still running
for (const thisComponent of langComponents)
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
break;
}
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function langRoutineEnd(snapshot) {
return function () {
//------Ending Routine 'lang'-------
for (const thisComponent of langComponents) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
}
psychoJS.experiment.addData('key_lang.keys', key_lang.keys);
if (typeof key_lang.keys !== 'undefined') { // we had a response
psychoJS.experiment.addData('key_lang.rt', key_lang.rt);
}
key_lang.stop();
// the Routine "lang" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
return Scheduler.Event.NEXT;
};
}
var instrComponents;
function instrRoutineBegin(snapshot) {
return function () {
//------Prepare to start Routine 'instr'-------
t = 0;
instrClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
// keep track of which components have finished
instrComponents = [];
instrComponents.push(instr_text_1);
instrComponents.push(instr_text_2);
instrComponents.push(instr_text_3);
instrComponents.push(instr_text_4);
instrComponents.push(instr_text_5);
for (const thisComponent of instrComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;
}
}
function instrRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'instr'-------
// get current time
t = instrClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *instr_text_1* updates
if (t >= 0.0 && instr_text_1.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
instr_text_1.tStart = t; // (not accounting for frame time here)
instr_text_1.frameNStart = frameN; // exact frame index
instr_text_1.setAutoDraw(true);
}
if (instr_text_1.status === PsychoJS.Status.STARTED && Boolean((curIns == 2))) {
instr_text_1.setAutoDraw(false);
}
// *instr_text_2* updates
if (((curIns == 2)) && instr_text_2.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
instr_text_2.tStart = t; // (not accounting for frame time here)
instr_text_2.frameNStart = frameN; // exact frame index
instr_text_2.setAutoDraw(true);
}
if (instr_text_2.status === PsychoJS.Status.STARTED && Boolean((curIns == 3))) {
instr_text_2.setAutoDraw(false);
}
// *instr_text_3* updates
if (((curIns == 3)) && instr_text_3.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
instr_text_3.tStart = t; // (not accounting for frame time here)
instr_text_3.frameNStart = frameN; // exact frame index
instr_text_3.setAutoDraw(true);
}
if (instr_text_3.status === PsychoJS.Status.STARTED && Boolean((curIns == 4))) {
instr_text_3.setAutoDraw(false);
}
// *instr_text_4* updates
if (((curIns == 4)) && instr_text_4.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
instr_text_4.tStart = t; // (not accounting for frame time here)
instr_text_4.frameNStart = frameN; // exact frame index
instr_text_4.setAutoDraw(true);
}
if (instr_text_4.status === PsychoJS.Status.STARTED && Boolean((curIns == 5))) {
instr_text_4.setAutoDraw(false);
}
// *instr_text_5* updates
if ((curIns == 5) && instr_text_5.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
instr_text_5.tStart = t; // (not accounting for frame time here)
instr_text_5.frameNStart = frameN; // exact frame index
instr_text_5.setAutoDraw(true);
}
// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({keyList:['escape']}).length > 0) {
return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
continueRoutine = false; // reverts to True if at least one component still running
for (const thisComponent of instrComponents)
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
break;
}
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function instrRoutineEnd(snapshot) {
return function () {
//------Ending Routine 'instr'-------
for (const thisComponent of instrComponents) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
}
// the Routine "instr" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
return Scheduler.Event.NEXT;
};
}
var prac_repeat;
var currentLoop;
function prac_repeatLoopBegin(prac_repeatLoopScheduler) {
// set up handler to look after randomisation of conditions etc
prac_repeat = new TrialHandler({
psychoJS: psychoJS,
nReps: 100, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: undefined,
seed: undefined, name: 'prac_repeat'
});
psychoJS.experiment.addLoop(prac_repeat); // add the loop to the experiment
currentLoop = prac_repeat; // we're now the current loop
// Schedule all the trials in the trialList:
for (const thisPrac_repeat of prac_repeat) {
const snapshot = prac_repeat.getSnapshot();
prac_repeatLoopScheduler.add(importConditions(snapshot));
const practiceLoopScheduler = new Scheduler(psychoJS);
prac_repeatLoopScheduler.add(practiceLoopBegin, practiceLoopScheduler);
prac_repeatLoopScheduler.add(practiceLoopScheduler);
prac_repeatLoopScheduler.add(practiceLoopEnd);
prac_repeatLoopScheduler.add(transitionRoutineBegin(snapshot));
prac_repeatLoopScheduler.add(transitionRoutineEachFrame(snapshot));
prac_repeatLoopScheduler.add(transitionRoutineEnd(snapshot));
prac_repeatLoopScheduler.add(endLoopIteration(prac_repeatLoopScheduler, snapshot));
}
return Scheduler.Event.NEXT;
}
var practice;
function practiceLoopBegin(practiceLoopScheduler) {
// set up handler to look after randomisation of conditions etc
practice = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: pracConditions,
seed: undefined, name: 'practice'
});
psychoJS.experiment.addLoop(practice); // add the loop to the experiment
currentLoop = practice; // we're now the current loop
// Schedule all the trials in the trialList:
for (const thisPractice of practice) {
const snapshot = practice.getSnapshot();
practiceLoopScheduler.add(importConditions(snapshot));
practiceLoopScheduler.add(pracRoutineBegin(snapshot));
practiceLoopScheduler.add(pracRoutineEachFrame(snapshot));
practiceLoopScheduler.add(pracRoutineEnd(snapshot));
practiceLoopScheduler.add(endLoopIteration(practiceLoopScheduler, snapshot));
}
return Scheduler.Event.NEXT;
}
function practiceLoopEnd() {
psychoJS.experiment.removeLoop(practice);
return Scheduler.Event.NEXT;
}
function prac_repeatLoopEnd() {
psychoJS.experiment.removeLoop(prac_repeat);
return Scheduler.Event.NEXT;
}
var trials_repeat;
function trials_repeatLoopBegin(trials_repeatLoopScheduler) {
// set up handler to look after randomisation of conditions etc
trials_repeat = new TrialHandler({
psychoJS: psychoJS,
nReps: 4, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: undefined,
seed: undefined, name: 'trials_repeat'
});
psychoJS.experiment.addLoop(trials_repeat); // add the loop to the experiment
currentLoop = trials_repeat; // we're now the current loop
// Schedule all the trials in the trialList:
for (const thisTrials_repeat of trials_repeat) {
const snapshot = trials_repeat.getSnapshot();
trials_repeatLoopScheduler.add(importConditions(snapshot));
const trialsLoopScheduler = new Scheduler(psychoJS);
trials_repeatLoopScheduler.add(trialsLoopBegin, trialsLoopScheduler);
trials_repeatLoopScheduler.add(trialsLoopScheduler);
trials_repeatLoopScheduler.add(trialsLoopEnd);
trials_repeatLoopScheduler.add(restRoutineBegin(snapshot));
trials_repeatLoopScheduler.add(restRoutineEachFrame(snapshot));
trials_repeatLoopScheduler.add(restRoutineEnd(snapshot));
trials_repeatLoopScheduler.add(ready_2RoutineBegin(snapshot));
trials_repeatLoopScheduler.add(ready_2RoutineEachFrame(snapshot));
trials_repeatLoopScheduler.add(ready_2RoutineEnd(snapshot));
trials_repeatLoopScheduler.add(cntdown_2RoutineBegin(snapshot));
trials_repeatLoopScheduler.add(cntdown_2RoutineEachFrame(snapshot));
trials_repeatLoopScheduler.add(cntdown_2RoutineEnd(snapshot));
trials_repeatLoopScheduler.add(endLoopIteration(trials_repeatLoopScheduler, snapshot));
}
return Scheduler.Event.NEXT;
}
var trials;
function trialsLoopBegin(trialsLoopScheduler) {
// set up handler to look after randomisation of conditions etc
trials = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: trialConditions,
seed: undefined, name: 'trials'
});
psychoJS.experiment.addLoop(trials); // add the loop to the experiment
currentLoop = trials; // we're now the current loop
// Schedule all the trials in the trialList:
for (const thisTrial of trials) {
const snapshot = trials.getSnapshot();
trialsLoopScheduler.add(importConditions(snapshot));
trialsLoopScheduler.add(trialRoutineBegin(snapshot));
trialsLoopScheduler.add(trialRoutineEachFrame(snapshot));
trialsLoopScheduler.add(trialRoutineEnd(snapshot));
trialsLoopScheduler.add(endLoopIteration(trialsLoopScheduler, snapshot));
}
return Scheduler.Event.NEXT;
}
function trialsLoopEnd() {
psychoJS.experiment.removeLoop(trials);
return Scheduler.Event.NEXT;
}
function trials_repeatLoopEnd() {
psychoJS.experiment.removeLoop(trials_repeat);
return Scheduler.Event.NEXT;
}
var _key_prac_allKeys;
var pracComponents;
function pracRoutineBegin(snapshot) {
return function () {
//------Prepare to start Routine 'prac'-------
t = 0;
pracClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
item1_img_pr.setImage(img1);
item2_img_pr.setImage(img2);
key_prac.keys = undefined;
key_prac.rt = undefined;
_key_prac_allKeys = [];
// keep track of which components have finished
pracComponents = [];
pracComponents.push(item1_img_pr);
pracComponents.push(brL_img_pr);
pracComponents.push(que_text_pr);
pracComponents.push(item2_img_pr);
pracComponents.push(brR_img_pr);
pracComponents.push(response_pr);
pracComponents.push(timer_pr);
pracComponents.push(fix_text_pr);
pracComponents.push(key_prac);
for (const thisComponent of pracComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;
}
}
var frameRemains;
function pracRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'prac'-------
// get current time
t = pracClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *item1_img_pr* updates
if (t >= 0 && item1_img_pr.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
item1_img_pr.tStart = t; // (not accounting for frame time here)
item1_img_pr.frameNStart = frameN; // exact frame index
item1_img_pr.setAutoDraw(true);
}
frameRemains = 0 + n_secs_img1 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if (item1_img_pr.status === PsychoJS.Status.STARTED && t >= frameRemains) {
item1_img_pr.setAutoDraw(false);
}
// *brL_img_pr* updates
if (t >= 0.0 && brL_img_pr.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
brL_img_pr.tStart = t; // (not accounting for frame time here)
brL_img_pr.frameNStart = frameN; // exact frame index
brL_img_pr.setAutoDraw(true);
}
frameRemains = 0.0 + n_secs_img1 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if (brL_img_pr.status === PsychoJS.Status.STARTED && t >= frameRemains) {
brL_img_pr.setAutoDraw(false);
}
// *que_text_pr* updates
if (((item1_finished == True)) && que_text_pr.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
que_text_pr.tStart = t; // (not accounting for frame time here)
que_text_pr.frameNStart = frameN; // exact frame index
que_text_pr.setAutoDraw(true);
}
if (que_text_pr.status === PsychoJS.Status.STARTED && t >= (que_text_pr.tStart + timeQue)) {
que_text_pr.setAutoDraw(false);
}
// *item2_img_pr* updates
if (((que_finished == True)) && item2_img_pr.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
item2_img_pr.tStart = t; // (not accounting for frame time here)
item2_img_pr.frameNStart = frameN; // exact frame index