-
Notifications
You must be signed in to change notification settings - Fork 0
/
ET_MW_DEV-legacy-browsers.js
1447 lines (1235 loc) · 51.1 KB
/
ET_MW_DEV-legacy-browsers.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
/******************
* Et_Mw_Dev Test *
******************/
// store info about the experiment session:
let expName = 'ET_MW_DEV'; // from the Builder filename that created this script
let expInfo = {
'participant': '',
'session': '001',
};
// Start code blocks for 'Before Experiment'
// init psychoJS:
const psychoJS = new PsychoJS({
debug: true
});
// open window:
psychoJS.openWindow({
fullscr: true,
color: new util.Color([1.0, 1.0, 1.0]),
units: 'height',
waitBlanking: true
});
// 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(Calibration_InstructionsRoutineBegin());
flowScheduler.add(Calibration_InstructionsRoutineEachFrame());
flowScheduler.add(Calibration_InstructionsRoutineEnd());
flowScheduler.add(LaunchRoutineBegin());
flowScheduler.add(LaunchRoutineEachFrame());
flowScheduler.add(LaunchRoutineEnd());
const MWdefinitionsLoopScheduler = new Scheduler(psychoJS);
flowScheduler.add(MWdefinitionsLoopBegin(MWdefinitionsLoopScheduler));
flowScheduler.add(MWdefinitionsLoopScheduler);
flowScheduler.add(MWdefinitionsLoopEnd);
flowScheduler.add(IntroExpRoutineBegin());
flowScheduler.add(IntroExpRoutineEachFrame());
flowScheduler.add(IntroExpRoutineEnd());
flowScheduler.add(PageSkippingRoutineBegin());
flowScheduler.add(PageSkippingRoutineEachFrame());
flowScheduler.add(PageSkippingRoutineEnd());
const ReadingLoopLoopScheduler = new Scheduler(psychoJS);
flowScheduler.add(ReadingLoopLoopBegin(ReadingLoopLoopScheduler));
flowScheduler.add(ReadingLoopLoopScheduler);
flowScheduler.add(ReadingLoopLoopEnd);
flowScheduler.add(EYE_RECORD_STOPRoutineBegin());
flowScheduler.add(EYE_RECORD_STOPRoutineEachFrame());
flowScheduler.add(EYE_RECORD_STOPRoutineEnd());
flowScheduler.add(blankRoutineBegin());
flowScheduler.add(blankRoutineEachFrame());
flowScheduler.add(blankRoutineEnd());
flowScheduler.add(EndTextRoutineBegin());
flowScheduler.add(EndTextRoutineEachFrame());
flowScheduler.add(EndTextRoutineEnd());
flowScheduler.add(quitPsychoJS, '', true);
// quit if user presses Cancel in dialog box:
dialogCancelScheduler.add(quitPsychoJS, '', false);
psychoJS.start({
expName: expName,
expInfo: expInfo,
resources: [
{'name': 'images/SC_v2.png', 'path': 'images/SC_v2.png'},
{'name': 'images/PC_v2.png', 'path': 'images/PC_v2.png'}
]
});
psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.EXP);
async function updateInfo() {
currentLoop = psychoJS.experiment; // right now there are no loops
expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp
expInfo['expName'] = expName;
expInfo['psychopyVersion'] = '2022.2.5';
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);
psychoJS.experiment.dataFileName = (("." + "/") + `data/${expInfo["participant"]}_${expName}_${expInfo["date"]}`);
return Scheduler.Event.NEXT;
}
async function experimentInit() {
// Initialize components for Routine "Calibration_Instructions"
Calibration_InstructionsClock = new util.Clock();
Cal_Instruct1 = new visual.TextStim({
win: psychoJS.window,
name: 'Cal_Instruct1',
text: "EYETRACKER CALIBRATION\n\nNow that you're fitted with the eyetracker, there will be some calibration points shown on the screen. Please follow the center of the targets with your eyes while keeping your head still. \n\nThe researcher may then need to make adjustments to the eyetracker. Please let them know if you're uncomfortable.\n\n(press spacebar to continue)",
font: 'Open Sans',
units: undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0.0,
languageStyle: 'LTR',
color: new util.Color([(- 1.0), (- 1.0), (- 1.0)]), opacity: undefined,
depth: 0.0
});
Calibration_text_resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Launch"
LaunchClock = new util.Clock();
// Run 'Begin Experiment' code from code
import * as random from 'random';
import * as xlrd from 'xlrd';
import * as time from 'time';
var currCondition, currConditionP, rand, randP;
random.seed(time.clock());
rand = random.randint(1, 2);
randP = random.randint(3, 4);
if ((rand === 1)) {
currCondition = "PC";
} else {
if ((rand === 2)) {
currCondition = "SC";
}
}
if ((randP === 3)) {
currConditionP = "Tropo";
} else {
if ((randP === 4)) {
currConditionP = "Life";
}
}
currCondition = "PC";
// Initialize components for Routine "MW_def"
MW_defClock = new util.Clock();
MWdefInstr = new visual.ImageStim({
win : psychoJS.window,
name : 'MWdefInstr', units : undefined,
image : undefined, mask : undefined,
ori : 0.0, pos : [0, 0], size : [1, 0.8],
color : new util.Color([1,1,1]), opacity : undefined,
flipHoriz : false, flipVert : false,
texRes : 128.0, interpolate : true, depth : 0.0
});
MWdefInstr_key_resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "IntroExp"
IntroExpClock = new util.Clock();
text = new visual.TextStim({
win: psychoJS.window,
name: 'text',
text: probeMessage,
font: 'Open Sans',
units: undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0.0,
languageStyle: 'LTR',
color: new util.Color('white'), opacity: 1.0,
depth: 0.0
});
IntroExp_key_resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "PageSkipping"
PageSkippingClock = new util.Clock();
NoSkipping = new visual.TextStim({
win: psychoJS.window,
name: 'NoSkipping',
text: 'Please read at your normal pace and do not skip pages.\n\n\n(press spacebar to continue)',
font: 'Open Sans',
units: undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0.0,
languageStyle: 'LTR',
color: new util.Color('white'), opacity: undefined,
depth: 0.0
});
key_Skip = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// Initialize components for Routine "Reading"
ReadingClock = new util.Clock();
// Run 'Begin Experiment' code from code_3
import * as random from 'random';
import * as copy from 'copy';
import {randint} from 'random';
import {*} from 'decimal';
import * as csv from 'csv';
import {*} from 'numpy';
import {core} from 'psychopy';
var isPaused, mainTimer, myCount, opacityImage1, opacityImage2, opacityRestart, printNow, printX, probe, probeTimer, resp1, resp2, time1, time2, timeThru;
opacityImage1 = 0;
opacityImage2 = 0;
opacityRestart = 0;
isPaused = 0;
time1 = 0;
time2 = 0;
resp1 = 0;
resp2 = 0;
timeThru = 0;
printNow = 0;
printX = 0;
mainTimer = new core.Clock();
probeTimer = new core.Clock();
myCount = 1;
probe = [0, 8, 10, 15];
Reading_key_resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
imagePages = new visual.ImageStim({
win : psychoJS.window,
name : 'imagePages', units : undefined,
image : undefined, mask : undefined,
ori : 0.0, pos : [0, 0], size : [0.85, 0.85],
color : new util.Color([1,1,1]), opacity : 1.0,
flipHoriz : false, flipVert : false,
texRes : 128.0, interpolate : true, depth : -2.0
});
PCProbe = new visual.ImageStim({
win : psychoJS.window,
name : 'PCProbe', units : undefined,
image : 'images/PC_v2.png', mask : undefined,
ori : 0.0, pos : [0, 0], size : [1, 0.85],
color : new util.Color([1,1,1]), opacity : 1.0,
flipHoriz : false, flipVert : false,
texRes : 128.0, interpolate : true, depth : -3.0
});
SCProbe = new visual.ImageStim({
win : psychoJS.window,
name : 'SCProbe', units : undefined,
image : 'images/SC_v2.png', mask : undefined,
ori : 0, pos : [0, 0], size : [1, 0.85],
color : new util.Color([1, 1, 1]), opacity : 1.0,
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : -4.0
});
// Initialize components for Routine "EYE_RECORD_STOP"
EYE_RECORD_STOPClock = new util.Clock();
// Initialize components for Routine "blank"
blankClock = new util.Clock();
textInterval = new visual.TextStim({
win: psychoJS.window,
name: 'textInterval',
text: '',
font: 'Open Sans',
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0.0,
languageStyle: 'LTR',
color: new util.Color('white'), opacity: undefined,
depth: 0.0
});
// Initialize components for Routine "EndText"
EndTextClock = new util.Clock();
EndExpText = new visual.TextStim({
win: psychoJS.window,
name: 'EndExpText',
text: "Thank you for participating in this experiment!\n\nPlease let the research assistant know if you would like to be debriefed.\n\nThank you!\n\n(Press 'space' to continue)",
font: 'Open Sans',
units: undefined,
pos: [0, 0], height: 0.05, wrapWidth: undefined, ori: 0.0,
languageStyle: 'LTR',
color: new util.Color('white'), opacity: undefined,
depth: 0.0
});
key_resp = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
// 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;
}
function Calibration_InstructionsRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'Calibration_Instructions' ---
t = 0;
Calibration_InstructionsClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
Calibration_text_resp.keys = undefined;
Calibration_text_resp.rt = undefined;
_Calibration_text_resp_allKeys = [];
// keep track of which components have finished
Calibration_InstructionsComponents = [];
Calibration_InstructionsComponents.push(Cal_Instruct1);
Calibration_InstructionsComponents.push(Calibration_text_resp);
Calibration_InstructionsComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function Calibration_InstructionsRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'Calibration_Instructions' ---
// get current time
t = Calibration_InstructionsClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *Cal_Instruct1* updates
if (t >= 0.0 && Cal_Instruct1.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
Cal_Instruct1.tStart = t; // (not accounting for frame time here)
Cal_Instruct1.frameNStart = frameN; // exact frame index
Cal_Instruct1.setAutoDraw(true);
}
// *Calibration_text_resp* updates
if (t >= 0.0 && Calibration_text_resp.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
Calibration_text_resp.tStart = t; // (not accounting for frame time here)
Calibration_text_resp.frameNStart = frameN; // exact frame index
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { Calibration_text_resp.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { Calibration_text_resp.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { Calibration_text_resp.clearEvents(); });
}
if (Calibration_text_resp.status === PsychoJS.Status.STARTED) {
let theseKeys = Calibration_text_resp.getKeys({keyList: ['space'], waitRelease: false});
_Calibration_text_resp_allKeys = _Calibration_text_resp_allKeys.concat(theseKeys);
if (_Calibration_text_resp_allKeys.length > 0) {
Calibration_text_resp.keys = _Calibration_text_resp_allKeys[_Calibration_text_resp_allKeys.length - 1].name; // just the last key pressed
Calibration_text_resp.rt = _Calibration_text_resp_allKeys[_Calibration_text_resp_allKeys.length - 1].rt;
// a response ends the routine
continueRoutine = false;
}
}
// 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
Calibration_InstructionsComponents.forEach( function(thisComponent) {
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
}
});
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function Calibration_InstructionsRoutineEnd(snapshot) {
return async function () {
//--- Ending Routine 'Calibration_Instructions' ---
Calibration_InstructionsComponents.forEach( function(thisComponent) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
});
// update the trial handler
if (currentLoop instanceof MultiStairHandler) {
currentLoop.addResponse(Calibration_text_resp.corr, level);
}
psychoJS.experiment.addData('Calibration_text_resp.keys', Calibration_text_resp.keys);
if (typeof Calibration_text_resp.keys !== 'undefined') { // we had a response
psychoJS.experiment.addData('Calibration_text_resp.rt', Calibration_text_resp.rt);
routineTimer.reset();
}
Calibration_text_resp.stop();
// the Routine "Calibration_Instructions" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
// Routines running outside a loop should always advance the datafile row
if (currentLoop === psychoJS.experiment) {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
}
function LaunchRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'Launch' ---
t = 0;
LaunchClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
// keep track of which components have finished
LaunchComponents = [];
LaunchComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function LaunchRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'Launch' ---
// get current time
t = LaunchClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// 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
LaunchComponents.forEach( function(thisComponent) {
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
}
});
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function LaunchRoutineEnd(snapshot) {
return async function () {
//--- Ending Routine 'Launch' ---
LaunchComponents.forEach( function(thisComponent) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
});
// the Routine "Launch" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
// Routines running outside a loop should always advance the datafile row
if (currentLoop === psychoJS.experiment) {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
}
function MWdefinitionsLoopBegin(MWdefinitionsLoopScheduler, snapshot) {
return async function() {
TrialHandler.fromSnapshot(snapshot); // update internal variables (.thisN etc) of the loop
// set up handler to look after randomisation of conditions etc
MWdefinitions = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: InstrFile,
seed: undefined, name: 'MWdefinitions'
});
psychoJS.experiment.addLoop(MWdefinitions); // add the loop to the experiment
currentLoop = MWdefinitions; // we're now the current loop
// Schedule all the trials in the trialList:
MWdefinitions.forEach(function() {
snapshot = MWdefinitions.getSnapshot();
MWdefinitionsLoopScheduler.add(importConditions(snapshot));
MWdefinitionsLoopScheduler.add(MW_defRoutineBegin(snapshot));
MWdefinitionsLoopScheduler.add(MW_defRoutineEachFrame());
MWdefinitionsLoopScheduler.add(MW_defRoutineEnd(snapshot));
MWdefinitionsLoopScheduler.add(MWdefinitionsLoopEndIteration(MWdefinitionsLoopScheduler, snapshot));
});
return Scheduler.Event.NEXT;
}
}
async function MWdefinitionsLoopEnd() {
// terminate loop
psychoJS.experiment.removeLoop(MWdefinitions);
// update the current loop from the ExperimentHandler
if (psychoJS.experiment._unfinishedLoops.length>0)
currentLoop = psychoJS.experiment._unfinishedLoops.at(-1);
else
currentLoop = psychoJS.experiment; // so we use addData from the experiment
return Scheduler.Event.NEXT;
}
function MWdefinitionsLoopEndIteration(scheduler, snapshot) {
// ------Prepare for next entry------
return async function () {
if (typeof snapshot !== 'undefined') {
// ------Check if user ended loop early------
if (snapshot.finished) {
// Check for and save orphaned data
if (psychoJS.experiment.isEntryEmpty()) {
psychoJS.experiment.nextEntry(snapshot);
}
scheduler.stop();
} else {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
};
}
function ReadingLoopLoopBegin(ReadingLoopLoopScheduler, snapshot) {
return async function() {
TrialHandler.fromSnapshot(snapshot); // update internal variables (.thisN etc) of the loop
// set up handler to look after randomisation of conditions etc
ReadingLoop = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: stimFile,
seed: undefined, name: 'ReadingLoop'
});
psychoJS.experiment.addLoop(ReadingLoop); // add the loop to the experiment
currentLoop = ReadingLoop; // we're now the current loop
// Schedule all the trials in the trialList:
ReadingLoop.forEach(function() {
snapshot = ReadingLoop.getSnapshot();
ReadingLoopLoopScheduler.add(importConditions(snapshot));
ReadingLoopLoopScheduler.add(ReadingRoutineBegin(snapshot));
ReadingLoopLoopScheduler.add(ReadingRoutineEachFrame());
ReadingLoopLoopScheduler.add(ReadingRoutineEnd(snapshot));
ReadingLoopLoopScheduler.add(ReadingLoopLoopEndIteration(ReadingLoopLoopScheduler, snapshot));
});
return Scheduler.Event.NEXT;
}
}
async function ReadingLoopLoopEnd() {
// terminate loop
psychoJS.experiment.removeLoop(ReadingLoop);
// update the current loop from the ExperimentHandler
if (psychoJS.experiment._unfinishedLoops.length>0)
currentLoop = psychoJS.experiment._unfinishedLoops.at(-1);
else
currentLoop = psychoJS.experiment; // so we use addData from the experiment
return Scheduler.Event.NEXT;
}
function ReadingLoopLoopEndIteration(scheduler, snapshot) {
// ------Prepare for next entry------
return async function () {
if (typeof snapshot !== 'undefined') {
// ------Check if user ended loop early------
if (snapshot.finished) {
// Check for and save orphaned data
if (psychoJS.experiment.isEntryEmpty()) {
psychoJS.experiment.nextEntry(snapshot);
}
scheduler.stop();
} else {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
};
}
function MW_defRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'MW_def' ---
t = 0;
MW_defClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
MWdefInstr.setImage(chInstrSlide);
MWdefInstr_key_resp.keys = undefined;
MWdefInstr_key_resp.rt = undefined;
_MWdefInstr_key_resp_allKeys = [];
// keep track of which components have finished
MW_defComponents = [];
MW_defComponents.push(MWdefInstr);
MW_defComponents.push(MWdefInstr_key_resp);
MW_defComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function MW_defRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'MW_def' ---
// get current time
t = MW_defClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *MWdefInstr* updates
if (t >= 0.0 && MWdefInstr.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
MWdefInstr.tStart = t; // (not accounting for frame time here)
MWdefInstr.frameNStart = frameN; // exact frame index
MWdefInstr.setAutoDraw(true);
}
// *MWdefInstr_key_resp* updates
if (t >= 0.0 && MWdefInstr_key_resp.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
MWdefInstr_key_resp.tStart = t; // (not accounting for frame time here)
MWdefInstr_key_resp.frameNStart = frameN; // exact frame index
// keyboard checking is just starting
MWdefInstr_key_resp.clock.reset();
MWdefInstr_key_resp.start();
}
if (MWdefInstr_key_resp.status === PsychoJS.Status.STARTED) {
let theseKeys = MWdefInstr_key_resp.getKeys({keyList: ['space'], waitRelease: false});
_MWdefInstr_key_resp_allKeys = _MWdefInstr_key_resp_allKeys.concat(theseKeys);
if (_MWdefInstr_key_resp_allKeys.length > 0) {
MWdefInstr_key_resp.keys = _MWdefInstr_key_resp_allKeys[_MWdefInstr_key_resp_allKeys.length - 1].name; // just the last key pressed
MWdefInstr_key_resp.rt = _MWdefInstr_key_resp_allKeys[_MWdefInstr_key_resp_allKeys.length - 1].rt;
// a response ends the routine
continueRoutine = false;
}
}
// 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
MW_defComponents.forEach( function(thisComponent) {
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
}
});
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function MW_defRoutineEnd(snapshot) {
return async function () {
//--- Ending Routine 'MW_def' ---
MW_defComponents.forEach( function(thisComponent) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
});
MWdefInstr_key_resp.stop();
// the Routine "MW_def" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
// Routines running outside a loop should always advance the datafile row
if (currentLoop === psychoJS.experiment) {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
}
function IntroExpRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'IntroExp' ---
t = 0;
IntroExpClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
IntroExp_key_resp.keys = undefined;
IntroExp_key_resp.rt = undefined;
_IntroExp_key_resp_allKeys = [];
// keep track of which components have finished
IntroExpComponents = [];
IntroExpComponents.push(text);
IntroExpComponents.push(IntroExp_key_resp);
IntroExpComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function IntroExpRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'IntroExp' ---
// get current time
t = IntroExpClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *text* updates
if (t >= 0.0 && text.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
text.tStart = t; // (not accounting for frame time here)
text.frameNStart = frameN; // exact frame index
text.setAutoDraw(true);
}
// *IntroExp_key_resp* updates
if (t >= 0.0 && IntroExp_key_resp.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
IntroExp_key_resp.tStart = t; // (not accounting for frame time here)
IntroExp_key_resp.frameNStart = frameN; // exact frame index
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { IntroExp_key_resp.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { IntroExp_key_resp.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { IntroExp_key_resp.clearEvents(); });
}
if (IntroExp_key_resp.status === PsychoJS.Status.STARTED) {
let theseKeys = IntroExp_key_resp.getKeys({keyList: ['space'], waitRelease: false});
_IntroExp_key_resp_allKeys = _IntroExp_key_resp_allKeys.concat(theseKeys);
if (_IntroExp_key_resp_allKeys.length > 0) {
IntroExp_key_resp.keys = _IntroExp_key_resp_allKeys[_IntroExp_key_resp_allKeys.length - 1].name; // just the last key pressed
IntroExp_key_resp.rt = _IntroExp_key_resp_allKeys[_IntroExp_key_resp_allKeys.length - 1].rt;
// a response ends the routine
continueRoutine = false;
}
}
// 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
IntroExpComponents.forEach( function(thisComponent) {
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
}
});
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function IntroExpRoutineEnd(snapshot) {
return async function () {
//--- Ending Routine 'IntroExp' ---
IntroExpComponents.forEach( function(thisComponent) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
});
// update the trial handler
if (currentLoop instanceof MultiStairHandler) {
currentLoop.addResponse(IntroExp_key_resp.corr, level);
}
psychoJS.experiment.addData('IntroExp_key_resp.keys', IntroExp_key_resp.keys);
if (typeof IntroExp_key_resp.keys !== 'undefined') { // we had a response
psychoJS.experiment.addData('IntroExp_key_resp.rt', IntroExp_key_resp.rt);
routineTimer.reset();
}
IntroExp_key_resp.stop();
// the Routine "IntroExp" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
// Routines running outside a loop should always advance the datafile row
if (currentLoop === psychoJS.experiment) {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
}
function PageSkippingRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'PageSkipping' ---
t = 0;
PageSkippingClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
key_Skip.keys = undefined;
key_Skip.rt = undefined;
_key_Skip_allKeys = [];
// keep track of which components have finished
PageSkippingComponents = [];
PageSkippingComponents.push(NoSkipping);
PageSkippingComponents.push(key_Skip);
PageSkippingComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function PageSkippingRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'PageSkipping' ---
// get current time
t = PageSkippingClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *NoSkipping* updates
if (t >= 0.0 && NoSkipping.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
NoSkipping.tStart = t; // (not accounting for frame time here)
NoSkipping.frameNStart = frameN; // exact frame index
NoSkipping.setAutoDraw(true);
}
// *key_Skip* updates
if (t >= 0.0 && key_Skip.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
key_Skip.tStart = t; // (not accounting for frame time here)
key_Skip.frameNStart = frameN; // exact frame index
// keyboard checking is just starting
psychoJS.window.callOnFlip(function() { key_Skip.clock.reset(); }); // t=0 on next screen flip
psychoJS.window.callOnFlip(function() { key_Skip.start(); }); // start on screen flip
psychoJS.window.callOnFlip(function() { key_Skip.clearEvents(); });
}
if (key_Skip.status === PsychoJS.Status.STARTED) {
let theseKeys = key_Skip.getKeys({keyList: ['space'], waitRelease: false});
_key_Skip_allKeys = _key_Skip_allKeys.concat(theseKeys);
if (_key_Skip_allKeys.length > 0) {
key_Skip.keys = _key_Skip_allKeys[_key_Skip_allKeys.length - 1].name; // just the last key pressed
key_Skip.rt = _key_Skip_allKeys[_key_Skip_allKeys.length - 1].rt;
// a response ends the routine
continueRoutine = false;
}
}
// 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
PageSkippingComponents.forEach( function(thisComponent) {
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
}
});
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function PageSkippingRoutineEnd(snapshot) {
return async function () {
//--- Ending Routine 'PageSkipping' ---
PageSkippingComponents.forEach( function(thisComponent) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
});
// update the trial handler
if (currentLoop instanceof MultiStairHandler) {
currentLoop.addResponse(key_Skip.corr, level);
}
psychoJS.experiment.addData('key_Skip.keys', key_Skip.keys);
if (typeof key_Skip.keys !== 'undefined') { // we had a response
psychoJS.experiment.addData('key_Skip.rt', key_Skip.rt);
routineTimer.reset();
}
key_Skip.stop();
// the Routine "PageSkipping" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
// Routines running outside a loop should always advance the datafile row
if (currentLoop === psychoJS.experiment) {
psychoJS.experiment.nextEntry(snapshot);
}
return Scheduler.Event.NEXT;
}
}
function ReadingRoutineBegin(snapshot) {
return async function () {
TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
//--- Prepare to start Routine 'Reading' ---
t = 0;
ReadingClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
Reading_key_resp.keys = undefined;
Reading_key_resp.rt = undefined;
_Reading_key_resp_allKeys = [];
imagePages.setImage(ChPage);
// keep track of which components have finished
ReadingComponents = [];
ReadingComponents.push(Reading_key_resp);
ReadingComponents.push(imagePages);
ReadingComponents.push(PCProbe);
ReadingComponents.push(SCProbe);
ReadingComponents.forEach( function(thisComponent) {
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
});
return Scheduler.Event.NEXT;
}
}
function ReadingRoutineEachFrame() {
return async function () {
//--- Loop for each frame of Routine 'Reading' ---
// get current time