-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtPupilPhase_builder.psyexp
736 lines (736 loc) · 83.6 KB
/
rtPupilPhase_builder.psyexp
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
<?xml version="1.0" ?>
<PsychoPy2experiment encoding="utf-8" version="2023.2.3">
<Settings>
<Param val="3" valType="str" updates="None" name="Audio latency priority"/>
<Param val="ptb" valType="str" updates="None" name="Audio lib"/>
<Param val="" valType="str" updates="None" name="Completed URL"/>
<Param val="auto" valType="str" updates="None" name="Data file delimiter"/>
<Param val="u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])" valType="code" updates="None" name="Data filename"/>
<Param val="True" valType="bool" updates="None" name="Enable Escape"/>
<Param val="" valType="str" updates="None" name="End Message"/>
<Param val="{'participant': 'f"{randint(0, 999999):06.0f}"', 'session': '001'}" valType="code" updates="None" name="Experiment info"/>
<Param val="True" valType="bool" updates="None" name="Force stereo"/>
<Param val="True" valType="bool" updates="None" name="Full-screen window"/>
<Param val="" valType="str" updates="None" name="HTML path"/>
<Param val="" valType="str" updates="None" name="Incomplete URL"/>
<Param val="testMonitor" valType="str" updates="None" name="Monitor"/>
<Param val="[]" valType="list" updates="None" name="Resources"/>
<Param val="False" valType="bool" updates="None" name="Save csv file"/>
<Param val="False" valType="bool" updates="None" name="Save excel file"/>
<Param val="False" valType="bool" updates="None" name="Save hdf5 file"/>
<Param val="True" valType="bool" updates="None" name="Save log file"/>
<Param val="True" valType="bool" updates="None" name="Save psydat file"/>
<Param val="True" valType="bool" updates="None" name="Save wide csv file"/>
<Param val="1" valType="num" updates="None" name="Screen"/>
<Param val="True" valType="bool" updates="None" name="Show info dlg"/>
<Param val="False" valType="bool" updates="None" name="Show mouse"/>
<Param val="height" valType="str" updates="None" name="Units"/>
<Param val="" valType="str" updates="None" name="Use version"/>
<Param val="[1512, 982]" valType="list" updates="None" name="Window size (pixels)"/>
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="avg" valType="str" updates="None" name="blendMode"/>
<Param val="{'thisRow.t': 'priority.CRITICAL', 'expName': 'priority.LOW'}" valType="dict" updates="None" name="colPriority"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="100.1.1.1" valType="str" updates="None" name="elAddress"/>
<Param val="FILTER_LEVEL_2" valType="str" updates="None" name="elDataFiltering"/>
<Param val="FILTER_LEVEL_OFF" valType="str" updates="None" name="elLiveFiltering"/>
<Param val="EYELINK 1000 DESKTOP" valType="str" updates="None" name="elModel"/>
<Param val="ELLIPSE_FIT" valType="str" updates="None" name="elPupilAlgorithm"/>
<Param val="PUPIL_AREA" valType="str" updates="None" name="elPupilMeasure"/>
<Param val="1000" valType="num" updates="None" name="elSampleRate"/>
<Param val="False" valType="bool" updates="None" name="elSimMode"/>
<Param val="RIGHT_EYE" valType="str" updates="None" name="elTrackEyes"/>
<Param val="PUPIL_CR_TRACKING" valType="str" updates="None" name="elTrackingMode"/>
<Param val="rtPupilPhase_builder" valType="str" updates="None" name="expName"/>
<Param val="on Sync" valType="str" updates="None" name="exportHTML"/>
<Param val="None" valType="str" updates="None" name="eyetracker"/>
<Param val="127.0.0.1" valType="str" updates="None" name="gpAddress"/>
<Param val="4242" valType="num" updates="None" name="gpPort"/>
<Param val="ioHub" valType="str" updates="None" name="keyboardBackend"/>
<Param val="exp" valType="code" updates="None" name="logging level"/>
<Param val="('MIDDLE_BUTTON',)" valType="list" updates="None" name="mgBlink"/>
<Param val="CONTINUOUS" valType="str" updates="None" name="mgMove"/>
<Param val="0.5" valType="num" updates="None" name="mgSaccade"/>
<Param val="neon.local" valType="str" updates="None" name="plCompanionAddress"/>
<Param val="scene_camera.json" valType="file" updates="None" name="plCompanionCameraCalibration"/>
<Param val="8080" valType="num" updates="None" name="plCompanionPort"/>
<Param val="True" valType="bool" updates="None" name="plCompanionRecordingEnabled"/>
<Param val="0.6" valType="num" updates="None" name="plConfidenceThreshold"/>
<Param val="True" valType="bool" updates="None" name="plPupilCaptureRecordingEnabled"/>
<Param val="" valType="str" updates="None" name="plPupilCaptureRecordingLocation"/>
<Param val="127.0.0.1" valType="str" updates="None" name="plPupilRemoteAddress"/>
<Param val="50020" valType="num" updates="None" name="plPupilRemotePort"/>
<Param val="1000" valType="num" updates="None" name="plPupilRemoteTimeoutMs"/>
<Param val="False" valType="bool" updates="None" name="plPupillometryOnly"/>
<Param val="psychopy_iohub_surface" valType="str" updates="None" name="plSurfaceName"/>
<Param val="time" valType="str" updates="None" name="sortColumns"/>
<Param val="" valType="str" updates="None" name="tbLicenseFile"/>
<Param val="" valType="str" updates="None" name="tbModel"/>
<Param val="60" valType="num" updates="None" name="tbSampleRate"/>
<Param val="" valType="str" updates="None" name="tbSerialNo"/>
<Param val="pyglet" valType="str" updates="None" name="winBackend"/>
</Settings>
<Routines>
<Routine name="task_instructions">
<RoutineSettingsComponent name="task_instructions" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="task_instructions" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<KeyboardComponent name="key_instruct" plugin="None">
<Param val="'space'" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="key_instruct" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="first key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
<CodeComponent name="text_align" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="# Code components should usually appear at the top&#10;# of the routine. This one has to appear after the&#10;# text component it refers to.&#10;#text_norm_2.alignText= 'left'" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="// Code component set to Both&#10;text_norm.setAlignHoriz('left')" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="text_align" valType="code" updates="None" name="name"/>
</CodeComponent>
<CodeComponent name="initialize_variables" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="sd = new StimulusDecider(block_length, baseline_duration_ms, max_search_window_duration_ms, pupil_sample_duration_ms, num_random_events, IEI_duration_sec, peak_pupil_quantile, trough_pupil_quantile, dilation_quantile, constriction_quantile, {"online": true, "win": psychoJS.window});&#10;" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="sd = StimulusDecider(block_length, baseline_duration_ms, &#10; max_search_window_duration_ms, pupil_sample_duration_ms, &#10; num_random_events, IEI_duration_sec, peak_pupil_quantile,&#10; trough_pupil_quantile, dilation_quantile, constriction_quantile,&#10; online=True, win=win) " valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Auto->JS" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="initialize_variables" valType="code" updates="None" name="name"/>
</CodeComponent>
<TextComponent name="text_norm_2" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="text_norm_2" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="False" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="Please fixate on the cross at all times. &#10;&#10;Press SPACE to begin the task." valType="str" updates="constant" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="1.8" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
</Routine>
<Routine name="start_block">
<RoutineSettingsComponent name="start_block" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="start_block" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<KeyboardComponent name="start_block_key" plugin="None">
<Param val="'space'" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="start_block_key" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="last key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
<TextComponent name="block_start_text" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="block_start_text" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="$"Starting block #" + str(block_idx)" valType="str" updates="set every repeat" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
</Routine>
<Routine name="EyeLinkStart">
<RoutineSettingsComponent name="EyeLinkStart" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="EyeLinkStart" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<CodeComponent name="elStartRecord" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="el_tracker = pylink.getEYELINK();&#10;el_tracker.setOfflineMode();&#10;el_tracker.sendCommand("clear_screen 0");&#10;im = Image.open(((script_path + "/") + trialImage));&#10;im = im.resize([scn_width, scn_height]);&#10;img_pixels = im.load();&#10;pixels = function () {&#10; var _pj_a = [], _pj_b = util.range(scn_height);&#10; for (var _pj_c = 0, _pj_d = _pj_b.length; (_pj_c < _pj_d); _pj_c += 1) {&#10; var j = _pj_b[_pj_c];&#10; _pj_a.push(function () {&#10; var _pj_e = [], _pj_f = util.range(scn_width);&#10; for (var _pj_g = 0, _pj_h = _pj_f.length; (_pj_g < _pj_h); _pj_g += 1) {&#10; var i = _pj_f[_pj_g];&#10; _pj_e.push(img_pixels[[i, j]]);&#10; }&#10; return _pj_e;&#10;}&#10;.call(this));&#10; }&#10; return _pj_a;&#10;}&#10;.call(this);&#10;el_tracker.bitmapBackdrop(scn_width, scn_height, pixels, 0, 0, scn_width, scn_height, 0, 0, pylink.BX_MAXCONTRAST);&#10;time.sleep(0.005);&#10;left = (Number.parseInt((scn_width / 2.0)) - 60);&#10;top = (Number.parseInt((scn_height / 2.0)) - 60);&#10;right = (Number.parseInt((scn_width / 2.0)) + 60);&#10;bottom = (Number.parseInt((scn_height / 2.0)) + 60);&#10;draw_cmd = `draw_filled_box ${left} ${top} ${right} ${bottom}`;&#10;el_tracker.sendCommand(draw_cmd);&#10;el_tracker.sendMessage(`TRIALID ${trial_index}`);&#10;status_msg = `TRIAL number ${trial_index}`;&#10;el_tracker.sendCommand(`record_status_message '${status_msg}`);&#10;while ((! dummy_mode)) {&#10; if (((! el_tracker.isConnected()) || el_tracker.breakPressed())) {&#10; terminate_task(genv, edf_file, session_folder, session_identifier);&#10; }&#10; try {&#10; error = el_tracker.doDriftCorrect(Number.parseInt((scn_width / 2.0)), Number.parseInt((scn_height / 2.0)), 1, 1);&#10; if ((error !== pylink.ESC_KEY)) {&#10; break;&#10; }&#10; } catch(e) {&#10; }&#10;}&#10;el_tracker.setOfflineMode();&#10;try {&#10; el_tracker.startRecording(1, 1, 1, 1);&#10;} catch(error) {&#10; if ((error instanceof RuntimeError)) {&#10; console.log("ERROR:", error);&#10; abort_trial();&#10; } else {&#10; throw error;&#10; }&#10;}&#10;pylink.pumpDelay(100);&#10;eye_used = el_tracker.eyeAvailable();&#10;if ((eye_used === 1)) {&#10; el_tracker.sendMessage("EYE_USED 1 RIGHT");&#10;} else {&#10; if (((eye_used === 0) || (eye_used === 2))) {&#10; el_tracker.sendMessage("EYE_USED 0 LEFT");&#10; eye_used = 0;&#10; } else {&#10; console.log("ERROR: Could not get eye information!");&#10; }&#10;}&#10;" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="# get a reference to the currently active EyeLink connection&#10;el_tracker = pylink.getEYELINK()&#10;&#10;# put the tracker in the offline mode first&#10;el_tracker.setOfflineMode()&#10;&#10;# clear the host screen before we draw the backdrop&#10;el_tracker.sendCommand('clear_screen 0')&#10;&#10;# Start recording&#10;# arguments: sample_to_file, events_to_file, sample_over_link,&#10;# event_over_link (1-yes, 0-no)&#10;try:&#10; el_tracker.startRecording(1, 1, 1, 1)&#10;except RuntimeError as error:&#10; print("ERROR:", error)&#10; abort_trial()&#10;&#10;# Allocate some time for the tracker to cache some samples&#10;pylink.pumpDelay(100)&#10;&#10;# determine which eye(s) is/are available&#10;# 0-left, 1-right, 2-binocular&#10;eye_used = el_tracker.eyeAvailable()&#10;if eye_used == 1:&#10; el_tracker.sendMessage("EYE_USED 1 RIGHT")&#10;elif eye_used == 0 or eye_used == 2:&#10; el_tracker.sendMessage("EYE_USED 0 LEFT")&#10; eye_used = 0&#10;else:&#10; print("ERROR: Could not get eye information!")&#10;" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="elStartRecord" valType="code" updates="None" name="name"/>
</CodeComponent>
</Routine>
<Routine name="end_block">
<RoutineSettingsComponent name="end_block" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="end_block" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<KeyboardComponent name="end_block_key" plugin="None">
<Param val="'space'" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="end_block_key" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="last key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
<TextComponent name="end_block_text" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="end_block_text" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="$"Finished block #" + str(block_idx)" valType="str" updates="set every repeat" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
</Routine>
<Routine name="EyeLinkSetup">
<RoutineSettingsComponent name="EyeLinkSetup" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="EyeLinkSetup" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<CodeComponent name="elConnect" plugin="None">
<Param val="import pylink&#10;import time&#10;import platform&#10;from PIL import Image # for preparing the Host backdrop image&#10;from EyeLinkCoreGraphicsPsychoPy import EyeLinkCoreGraphicsPsychoPy&#10;from string import ascii_letters, digits&#10;from psychopy import gui&#10;&#10;&#10;# Switch to the script folder&#10;script_path = os.path.dirname(sys.argv[0])&#10;if len(script_path) != 0:&#10; os.chdir(script_path)&#10;&#10;# Set this variable to True if you use the built-in retina screen as your&#10;# primary display device on macOS. If have an external monitor, set this&#10;# variable True if you choose to "Optimize for Built-in Retina Display"&#10;# in the Displays preference settings.&#10;use_retina = False&#10;&#10;# Set this variable to True to run the script in "Dummy Mode"&#10;dummy_mode = True &#10;&#10;# Set up EDF data file name and local data folder&#10;#&#10;# The EDF data filename should not exceed 8 alphanumeric characters&#10;# use ONLY number 0-9, letters, & _ (underscore) in the filename&#10;edf_fname = 'TEST'&#10;&#10;# Prompt user to specify an EDF data filename&#10;# before we open a fullscreen window&#10;dlg_title = 'Enter EDF File Name'&#10;dlg_prompt = 'Please enter a file name with 8 or fewer characters\n' + \&#10; '[letters, numbers, and underscore].'&#10;# loop until we get a valid filename&#10;while True:&#10; dlg = gui.Dlg(dlg_title)&#10; dlg.addText(dlg_prompt)&#10; dlg.addField('File Name:', edf_fname)&#10; # show dialog and wait for OK or Cancel&#10; ok_data = dlg.show()&#10; if dlg.OK: # if ok_data is not None&#10; print('EDF data filename: {}'.format(ok_data[0]))&#10; else:&#10; print('user cancelled')&#10; core.quit()&#10; sys.exit()&#10;&#10; # get the string entered by the experimenter&#10; tmp_str = dlg.data[0]&#10; # strip trailing characters, ignore the ".edf" extension&#10; edf_fname = tmp_str.rstrip().split('.')[0]&#10;&#10; # check if the filename is valid (length <= 8 & no special char)&#10; allowed_char = ascii_letters + digits + '_'&#10; if not all([c in allowed_char for c in edf_fname]):&#10; print('ERROR: Invalid EDF filename')&#10; elif len(edf_fname) > 8:&#10; print('ERROR: EDF filename should not exceed 8 characters')&#10; else:&#10; break&#10; &#10;# Set up a folder to store the EDF data files and the associated resources&#10;# e.g., files defining the interest areas used in each trial&#10;results_folder = 'results'&#10;if not os.path.exists(results_folder):&#10; os.makedirs(results_folder)&#10;&#10;# We download EDF data file from the EyeLink Host PC to the local hard&#10;# drive at the end of each testing session, here we rename the EDF to&#10;# include session start date/time&#10;time_str = time.strftime("_%Y_%m_%d_%H_%M", time.localtime())&#10;session_identifier = edf_fname + time_str&#10;&#10;# create a folder for the current testing session in the "results" folder&#10;session_folder = os.path.join(results_folder, session_identifier)&#10;if not os.path.exists(session_folder):&#10; os.makedirs(session_folder)&#10;&#10;# For macOS users check if they have a retina screen&#10;if 'Darwin' in platform.system():&#10; dlg = gui.Dlg("Retina Screen?")&#10; dlg.addText("Will the task run on a Retina or a non-Retina screen?")&#10; dlg.addField("Screen Type:", choices=["Not Retina","Retina"])&#10; # show dialog and wait for OK or Cancel&#10; ok_data = dlg.show()&#10; if dlg.OK:&#10; if dlg.data[0] == "Retina": &#10; use_retina = True&#10; else:&#10; use_retina = False&#10; else:&#10; print('user cancelled')&#10; core.quit()&#10; sys.exit()&#10;&#10;# Step 1: Connect to the EyeLink Host PC&#10;#&#10;# The Host IP address, by default, is "100.1.1.1".&#10;# the "el_tracker" objected created here can be accessed through the Pylink&#10;# Set the Host PC address to "None" (without quotes) to run the script&#10;# in "Dummy Mode"&#10;if dummy_mode:&#10; el_tracker = pylink.EyeLink(None)&#10;else:&#10; try:&#10; el_tracker = pylink.EyeLink("100.1.1.1")&#10; except RuntimeError as error:&#10; dlg = gui.Dlg("Dummy Mode?")&#10; dlg.addText("Couldn't connect to tracker at 100.1.1.1 -- continue in Dummy Mode?")&#10; # show dialog and wait for OK or Cancel&#10; ok_data = dlg.show()&#10; if dlg.OK: # if ok_data is not None&#10; dummy_mode = True&#10; el_tracker = pylink.EyeLink(None)&#10; else:&#10; print('user cancelled')&#10; core.quit()&#10; sys.exit()&#10;&#10;# Define some helper functions for screen drawing &#10;# and exiting trials/sessions early&#10;def clear_screen(win,genv):&#10; """ clear up the PsychoPy window"""&#10; win.fillColor = genv.getBackgroundColor()&#10; win.flip()&#10;&#10;def show_msg(win, genv, text, wait_for_keypress=True):&#10; """ Show task instructions on screen"""&#10; scn_width, scn_height = win.size&#10; msg = visual.TextStim(win, text,&#10; color=genv.getForegroundColor(),&#10; wrapWidth=scn_width/2)&#10; clear_screen(win,genv)&#10; msg.draw()&#10; win.flip()&#10;&#10; # wait indefinitely, terminates upon any key press&#10; if wait_for_keypress:&#10; kb = keyboard.Keyboard()&#10; #keys = kb.getKeys(['Enter'], waitRelease=False)&#10; waitKeys = kb.waitKeys(keyList=None, waitRelease=True, clear=True)&#10; clear_screen(win,genv)&#10;&#10;def terminate_task(genv,edf_file,session_folder,session_identifier):&#10; """ Terminate the task gracefully and retrieve the EDF data file&#10; """&#10; el_tracker = pylink.getEYELINK()&#10;&#10; if el_tracker.isConnected():&#10; # Terminate the current trial first if the task terminated prematurely&#10; error = el_tracker.isRecording()&#10; if error == pylink.TRIAL_OK:&#10; abort_trial()&#10;&#10; # Put tracker in Offline mode&#10; el_tracker.setOfflineMode()&#10;&#10; # Clear the Host PC screen and wait for 500 ms&#10; el_tracker.sendCommand('clear_screen 0')&#10; pylink.msecDelay(500)&#10;&#10; # Close the edf data file on the Host&#10; el_tracker.closeDataFile()&#10;&#10; # Show a file transfer message on the screen&#10; # msg = 'EDF data is transferring from EyeLink Host PC...'&#10; #show_msg(win, genv, msg, wait_for_keypress=False)&#10;&#10; # Download the EDF data file from the Host PC to a local data folder&#10; # parameters: source_file_on_the_host, destination_file_on_local_drive&#10; local_edf = os.path.join(session_folder, session_identifier + '.EDF')&#10; # try:&#10; # el_tracker.receiveDataFile(edf_file, local_edf)&#10; #except RuntimeError as error:&#10; # print('ERROR:', error)&#10;&#10; # Close the link to the tracker.&#10; el_tracker.close()&#10;&#10; # close the PsychoPy window&#10; win.close()&#10;&#10; # quit PsychoPy&#10; core.quit()&#10; sys.exit()&#10;&#10;def abort_trial():&#10; """Ends recording """&#10; el_tracker = pylink.getEYELINK()&#10;&#10; # Stop recording&#10; if el_tracker.isRecording():&#10; # add 100 ms to catch final trial events&#10; pylink.pumpDelay(100)&#10; el_tracker.stopRecording()&#10; &#10; # Send a message to clear the Data Viewer screen&#10; bgcolor_RGB = (128, 128, 128)&#10; el_tracker.sendMessage('!V CLEAR %d %d %d' % bgcolor_RGB)&#10;&#10; # send a message to mark trial end&#10; el_tracker.sendMessage('TRIAL_RESULT %d' % pylink.TRIAL_ERROR)&#10;&#10; return pylink.TRIAL_ERROR&#10;" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="/* Syntax Error: Fix Python code */" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="el_tracker = pylink.getEYELINK()&#10;# Step 2: Open an EDF data file on the Host PC&#10;global edf_fname&#10;edf_file = edf_fname + ".EDF"&#10;try:&#10; print("opened edf")&#10; el_tracker.openDataFile(edf_file)&#10;except RuntimeError as err:&#10; print("couldn't open EDF")&#10; print('ERROR:', err)&#10; # close the link if we have one open&#10; if el_tracker.isConnected():&#10; el_tracker.close()&#10; core.quit()&#10; sys.exit()&#10;&#10;# Add a header text to the EDF file to identify the current experiment name&#10;# This is OPTIONAL. If your text starts with "RECORDED BY " it will be&#10;# available in DataViewer's Inspector window by clicking&#10;# the EDF session node in the top panel and looking for the "Recorded By:"&#10;# field in the bottom panel of the Inspector.&#10;preamble_text = 'RECORDED BY %s' % os.path.basename(__file__)&#10;el_tracker.sendCommand("add_file_preamble_text '%s'" % preamble_text)&#10;&#10;# Step 3: Configure the tracker&#10;#&#10;# Put the tracker in offline mode before we change tracking parameters&#10;el_tracker.setOfflineMode()&#10;&#10;# Get the software version: 1-EyeLink I, 2-EyeLink II, 3/4-EyeLink 1000,&#10;# 5-EyeLink 1000 Plus, 6-Portable DUO&#10;eyelink_ver = 0 # set version to 0, in case running in Dummy mode&#10;if not dummy_mode:&#10; vstr = el_tracker.getTrackerVersionString()&#10; eyelink_ver = int(vstr.split()[-1].split('.')[0])&#10; # print out some version info in the shell&#10; print('Running experiment on %s, version %d' % (vstr, eyelink_ver))&#10;&#10;# File and Link data control&#10;# what eye events to save in the EDF file, include everything by default&#10;file_event_flags = 'LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON,INPUT'&#10;# what eye events to make available over the link, include everything by default&#10;link_event_flags = 'LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON,FIXUPDATE,INPUT'&#10;# what sample data to save in the EDF data file and to make available&#10;# over the link, include the 'HTARGET' flag to save head target sticker&#10;# data for supported eye trackers&#10;if eyelink_ver > 3:&#10; file_sample_flags = 'LEFT,RIGHT,GAZE,HREF,RAW,AREA,HTARGET,GAZERES,BUTTON,STATUS,INPUT'&#10; link_sample_flags = 'LEFT,RIGHT,GAZE,GAZERES,AREA,HTARGET,STATUS,INPUT'&#10;else:&#10; file_sample_flags = 'LEFT,RIGHT,GAZE,HREF,PUPIL,AREA,GAZERES,BUTTON,STATUS,INPUT'&#10; link_sample_flags = 'LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS,INPUT'&#10;el_tracker.sendCommand("file_event_filter = %s" % file_event_flags)&#10;el_tracker.sendCommand("file_sample_data = %s" % file_sample_flags)&#10;el_tracker.sendCommand("link_event_filter = %s" % link_event_flags)&#10;el_tracker.sendCommand("link_sample_data = %s" % link_sample_flags)&#10;&#10;# Optional tracking parameters&#10;# Sample rate, 250, 500, 1000, or 2000, check your tracker specification&#10;# if eyelink_ver > 2:&#10;# el_tracker.sendCommand("sample_rate 1000")&#10;# Choose a calibration type, H3, HV3, HV5, HV13 (HV = horizontal/vertical),&#10;el_tracker.sendCommand("calibration_type = HV9")&#10;# Set a gamepad button to accept calibration/drift check target&#10;# You need a supported gamepad/button box that is connected to the Host PC&#10;el_tracker.sendCommand("button_function 5 'accept_target_fixation'")&#10;&#10;# get the native screen resolution used by PsychoPy&#10;scn_width, scn_height = win.size&#10;# resolution fix for Mac retina displays&#10;if 'Darwin' in platform.system():&#10; if use_retina:&#10; scn_width = int(scn_width/2.0)&#10; scn_height = int(scn_height/2.0)&#10;&#10;# Pass the display pixel coordinates (left, top, right, bottom) to the tracker&#10;# see the EyeLink Installation Guide, "Customizing Screen Settings"&#10;el_coords = "screen_pixel_coords = 0 0 %d %d" % (scn_width - 1, scn_height - 1)&#10;el_tracker.sendCommand(el_coords)&#10;&#10;# Write a DISPLAY_COORDS message to the EDF file&#10;# Data Viewer needs this piece of info for proper visualization, see Data&#10;# Viewer User Manual, "Protocol for EyeLink Data to Viewer Integration"&#10;dv_coords = "DISPLAY_COORDS 0 0 %d %d" % (scn_width - 1, scn_height - 1)&#10;el_tracker.sendMessage(dv_coords) &#10; &#10;# Configure a graphics environment (genv) for tracker calibration&#10;genv = EyeLinkCoreGraphicsPsychoPy(el_tracker, win)&#10;print(genv) # print out the version number of the CoreGraphics library" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="/* Syntax Error: Fix Python code */" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="# This End Experiment tab of the elConnect component calls the &#10;# terminate_task helper function to get the EDF file and close the connection&#10;# to the Host PC&#10;&#10;# Disconnect, download the EDF file, then terminate the task&#10;terminate_task(genv,edf_file,session_folder,session_identifier)" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="terminate_task(genv, edf_file, session_folder, session_identifier);&#10;" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="/* Syntax Error: Fix Python code */" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="# This End Routine tab of the elConnect component configures some&#10;# graphics options for calibration, and then performs a camera setup&#10;# so that you can set up the eye tracker and calibrate/validate the participant&#10;&#10;# Set background and foreground colors for the calibration target&#10;# in PsychoPy, (-1, -1, -1)=black, (1, 1, 1)=white, (0, 0, 0)=mid-gray&#10;foreground_color = (-1, -1, -1)&#10;background_color = tuple(win.color)&#10;genv.setCalibrationColors(foreground_color, background_color)&#10;&#10;# Set up the calibration target&#10;#&#10;# The target could be a "circle" (default), a "picture", a "movie" clip,&#10;# or a rotating "spiral". To configure the type of calibration target, set&#10;# genv.setTargetType to "circle", "picture", "movie", or "spiral", e.g.,&#10;# genv.setTargetType('picture')&#10;#&#10;# Use genv.setMovieTarget() to set a "movie" target&#10;# genv.setMovieTarget(os.path.join('videos', 'calibVid.mov'))&#10;&#10;# Use a picture as the calibration target&#10;genv.setTargetType('circle')&#10;genv.setTargetSize(24)&#10;&#10;# Configure the size of the calibration target (in pixels)&#10;# this option applies only to "circle" and "spiral" targets&#10;# genv.setTargetSize(24)&#10;&#10;# Beeps to play during calibration, validation and drift correction&#10;# parameters: target, good, error&#10;# target -- sound to play when target moves&#10;# good -- sound to play on successful operation&#10;# error -- sound to play on failure or interruption&#10;# Each parameter could be ''--default sound, 'off'--no sound, or a wav file&#10;genv.setCalibrationSounds('off', 'off', 'off')&#10;&#10;# resolution fix for macOS retina display issues&#10;if use_retina:&#10; genv.fixMacRetinaDisplay()&#10;&#10;#clear the screen before we begin Camera Setup mode&#10;clear_screen(win,genv)&#10;&#10;# Request Pylink to use the PsychoPy window we opened above for calibration&#10;pylink.openGraphicsEx(genv)&#10;&#10;# Peform a Camera Setup (eye tracker calibration)&#10;# skip this step if running the script in Dummy Mode&#10;if not dummy_mode:&#10; try:&#10; el_tracker.doTrackerSetup()&#10; except RuntimeError as err:&#10; print('ERROR:', err)&#10; el_tracker.exitCalibration()&#10;clear_screen(win,genv)&#10;" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="elConnect" valType="code" updates="None" name="name"/>
</CodeComponent>
<TextComponent name="elInstructions" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="elInstructions" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="Please press 'o' to begin EyeLink setup." valType="str" updates="constant" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
<KeyboardComponent name="key_resp" plugin="None">
<Param val="" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="key_resp" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="last key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
</Routine>
<Routine name="EyeLinkStop">
<RoutineSettingsComponent name="EyeLinkStop" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="EyeLinkStop" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<CodeComponent name="elStopRecord" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="clear_screen(psychoJS.window, genv);&#10;el_tracker.sendMessage("blank_screen");&#10;el_tracker.sendMessage("!V CLEAR 128 128 128");&#10;pylink.pumpDelay(100);&#10;el_tracker.stopRecording();&#10;el_tracker.sendMessage(`TRIAL_RESULT ${0}`);&#10;trial_index = (trial_index + 1);&#10;" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="# This End Routine tab of the elStopRecord component clears the &#10;# screen (and sends a message to mark the clearing), stops recording, sends&#10;# a trial end message, and increments a trial counter variable&#10;&#10;# clear the screen&#10;clear_screen(win,genv)&#10;el_tracker.sendMessage('blank_screen')&#10;# send a message to clear the Data Viewer screen as well&#10;el_tracker.sendMessage('!V CLEAR 128 128 128')&#10;&#10;# stop recording; add 100 msec to catch final events before stopping&#10;pylink.pumpDelay(100)&#10;el_tracker.stopRecording()&#10; &#10;# send a 'TRIAL_RESULT' message to mark the end of trial, see Data&#10;# Viewer User Manual, "Protocol for EyeLink Data to Viewer Integration"&#10;el_tracker.sendMessage('TRIAL_RESULT %d' % 0)&#10;" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="elStopRecord" valType="code" updates="None" name="name"/>
</CodeComponent>
</Routine>
<Routine name="fixation_routine">
<RoutineSettingsComponent name="fixation_routine" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="True" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="fixation_routine" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<TextComponent name="fixation" plugin="None">
<Param val="-1.0000, -1.0000, -1.0000" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Open Sans" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.05" valType="num" updates="constant" name="letterHeight"/>
<Param val="fixation" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="$block_length" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="+" valType="str" updates="set every frame" name="text"/>
<Param val="from exp settings" valType="str" updates="None" name="units"/>
<Param val="" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
<CodeComponent name="StimulusDecider" plugin="None">
<Param val="from StimulusDecider import StimulusDecider&#10;import rtPupil_config&#10;&#10;# note that these parameters will partially determine the number of accepted&#10;# events. If you have too many random events in too short a block, enough &#10;# time will never pass to get an accepted pupil phase event. &#10;block_length = 30# in seconds &#10;# max_num_blocks = 1 &#10;num_random_events = 2&#10;IEI_duration_sec = 3 &#10;&#10;# rtPupilPhase algorithm parameters - Please see Table 1 in Kronemer et al., &#10;# 2024 for more information. These reflect the defaults used in Kronemer et&#10;# al., 2024.&#10;baseline_duration_ms = 5000&#10;max_search_window_duration_ms = 5000&#10;pupil_sample_duration_ms = 100&#10;peak_pupil_quantile = 0.75&#10;trough_pupil_quantile = 0.25&#10;dilation_quantile = 0.99&#10;constriction_quantile = 0.01" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="import * as random from 'random';&#10;temp = [];&#10;" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="# log information about parameters &#10;param_log_message = "Input Parameters: block length: "+str(block_length)+\&#10;", baseline_duration_ms: "+str(baseline_duration_ms)+", max_search_window_duration_ms: "+str(max_search_window_duration_ms)+\&#10;", num_random_events: "+str(num_random_events)+", IEI_duration_sec: "+str(IEI_duration_sec)+", pupil_sample_duration_ms: "+\&#10;str(pupil_sample_duration_ms)+", peak_pupil_quantile: "+str(peak_pupil_quantile)+", trough_pupil_quantile: "+str(trough_pupil_quantile)+\&#10;", dilation_quantile: "+str(dilation_quantile)+", constriction_quantile: "+str(constriction_quantile)&#10;logging.log(level=logging.EXP,msg=param_log_message)&#10;&#10;# save parameters in CSV as well &#10;thisExp.addData('baseline_duration', baseline_duration_ms)&#10;thisExp.addData('search_window_max_duration', max_search_window_duration_ms)&#10;thisExp.addData('IEI_duration', IEI_duration_sec)&#10;thisExp.addData('pupil_sample_duration_ms', pupil_sample_duration_ms)&#10;thisExp.addData('peak_pupil_quantile', peak_pupil_quantile)&#10;thisExp.addData('trough_pupil_quantile', trough_pupil_quantile)&#10;thisExp.addData('dilation_quantile', dilation_quantile)&#10;thisExp.addData('constriction_quantile', constriction_quantile)&#10;" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="# will keep track of accepted events&#10;decision_array = []&#10;" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="sd.build_search_window() # build the search window &#10;event_idx = sd.detect_events_online() # determine whether there was an event&#10;# 1 = peak, -1 = trough, 2 = dilation, -2 = contriction, 3 = random, 0 = no event&#10;decision_array.append(event_idx) # add event code to decision array &#10;&#10;# NOTE: here is where you might want to write custom code to have closed-loop&#10;# functionality - if the event is not 0 or 3, do something. &#10;&#10;# do some logging of each frame in the output CSV file: &#10;#time of event, event index, search window (and times associated)&#10;thisExp.addData('current_time',globalClock.getTime())&#10;thisExp.addData('event',event_idx)&#10;# demean search window to match log file &#10;search_window = sd.get_search_window()&#10;demeaned_window = list(search_window - np.nanmean(search_window))&#10;thisExp.addData('demeaned_search_window', demeaned_window)&#10;thisExp.addData('search_window_times', sd.get_search_window_times())&#10;thisExp.nextEntry() # get next frame on new line&#10;" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="# append final decision array to end of CSV &#10;thisExp.addData('decision_array',decision_array) " valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="StimulusDecider" valType="code" updates="None" name="name"/>
</CodeComponent>
</Routine>
<Routine name="end_experiment">
<RoutineSettingsComponent name="end_experiment" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="end_experiment" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<TextComponent name="exp_end" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="exp_end" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="You have completed this experiment! &#10;&#10;Please wait for experimenter instructions." valType="str" updates="constant" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
<KeyboardComponent name="exp_end_resp" plugin="None">
<Param val="'space'" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="exp_end_resp" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="last key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
</Routine>
<Routine name="task_instructions2">
<RoutineSettingsComponent name="task_instructions2" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="task_instructions2" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<TextComponent name="text_norm" plugin="None">
<Param val="white" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="text_norm" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="False" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="Any text&#10;&#10;including line breaks&#10;&#10;This text component is white, so change the colour if you have a white background. It does not save the onset and offset time, but has been left justified with a wrap width of 1.8 norm units.&#10;&#10;Press the spacebar to continue" valType="str" updates="constant" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="1.8" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
<KeyboardComponent name="key_instruct_2" plugin="None">
<Param val="'space'" valType="list" updates="constant" name="allowedKeys"/>
<Param val="" valType="str" updates="constant" name="correctAns"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="True" valType="bool" updates="constant" name="discard previous"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="True" valType="bool" updates="constant" name="forceEndRoutine"/>
<Param val="key_instruct_2" valType="code" updates="None" name="name"/>
<Param val="press" valType="str" updates="constant" name="registerOn"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="first key" valType="str" updates="constant" name="store"/>
<Param val="False" valType="bool" updates="constant" name="storeCorrect"/>
<Param val="True" valType="bool" updates="constant" name="syncScreenRefresh"/>
</KeyboardComponent>
<CodeComponent name="text_align_2" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="# Code components should usually appear at the top&#10;# of the routine. This one has to appear after the&#10;# text component it refers to.&#10;text_norm.alignText= 'left'" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="// Code component set to Both&#10;text_norm.setAlignHoriz('left')" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Both" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="text_align_2" valType="code" updates="None" name="name"/>
</CodeComponent>
</Routine>
<Routine name="fixation_routine2">
<RoutineSettingsComponent name="fixation_routine2" plugin="None">
<Param val="none" valType="str" updates="None" name="backgroundFit"/>
<Param val="" valType="str" updates="None" name="backgroundImg"/>
<Param val="$[0,0,0]" valType="color" updates="None" name="color"/>
<Param val="rgb" valType="str" updates="None" name="colorSpace"/>
<Param val="" valType="str" updates="constant" name="desc"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="fixation_routine2" valType="code" updates="None" name="name"/>
<Param val="True" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="constant" name="skipIf"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="" valType="code" updates="constant" name="stopVal"/>
<Param val="False" valType="bool" updates="None" name="useWindowParams"/>
</RoutineSettingsComponent>
<TextComponent name="text_norm_3" plugin="None">
<Param val="black" valType="color" updates="constant" name="color"/>
<Param val="rgb" valType="str" updates="constant" name="colorSpace"/>
<Param val="1" valType="num" updates="constant" name="contrast"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="" valType="code" updates="None" name="durationEstim"/>
<Param val="None" valType="str" updates="constant" name="flip"/>
<Param val="Arial" valType="str" updates="constant" name="font"/>
<Param val="LTR" valType="str" updates="None" name="languageStyle"/>
<Param val="0.1" valType="num" updates="constant" name="letterHeight"/>
<Param val="text_norm_3" valType="code" updates="None" name="name"/>
<Param val="" valType="num" updates="constant" name="opacity"/>
<Param val="0" valType="num" updates="constant" name="ori"/>
<Param val="(0, 0)" valType="list" updates="constant" name="pos"/>
<Param val="False" valType="bool" updates="None" name="saveStartStop"/>
<Param val="" valType="code" updates="None" name="startEstim"/>
<Param val="time (s)" valType="str" updates="None" name="startType"/>
<Param val="0.0" valType="code" updates="None" name="startVal"/>
<Param val="duration (s)" valType="str" updates="None" name="stopType"/>
<Param val="$block_length" valType="code" updates="constant" name="stopVal"/>
<Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
<Param val="+" valType="str" updates="set every frame" name="text"/>
<Param val="norm" valType="str" updates="None" name="units"/>
<Param val="1.8" valType="num" updates="constant" name="wrapWidth"/>
</TextComponent>
<CodeComponent name="text_align_3" plugin="None">
<Param val="" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="# Code components should usually appear at the top&#10;# of the routine. This one has to appear after the&#10;# text component it refers to.&#10;#text_norm_3.alignText= 'left'" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="// Code component set to Both&#10;text_norm.setAlignHoriz('left')" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Both" valType="str" updates="None" name="Code Type"/>
<Param val="" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="" valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="text_align_3" valType="code" updates="None" name="name"/>
</CodeComponent>
<CodeComponent name="StimulusDecider_2" plugin="None">
<Param val="from StimulusDecider import StimulusDecider&#10;import rtPupil_config&#10;&#10;# note that these parameters will partially determine the number of accepted&#10;# events. If you have too many random events in too short a block, enough &#10;# time will never pass to get an accepted pupil phase event. &#10;block_length = 30# in seconds &#10;num_random_events = 2&#10;IEI_duration_sec = 3 &#10;&#10;# rtPupilPhase algorithm parameters - Please see Table 1 in Kronemer et al., &#10;# 2024 for more information. These reflect the defaults used in Kronemer et&#10;# al., 2024.&#10;baseline_duration_ms = 5000&#10;max_search_window_duration_ms = 5000&#10;pupil_sample_duration_ms = 100&#10;peak_pupil_quantile = 0.75&#10;trough_pupil_quantile = 0.25&#10;dilation_quantile = 0.99&#10;constriction_quantile = 0.01" valType="extendedCode" updates="constant" name="Before Experiment"/>
<Param val="import * as random from 'random';&#10;temp = [];&#10;" valType="extendedCode" updates="constant" name="Before JS Experiment"/>
<Param val="# log information about parameters &#10;param_log_message = "Input Parameters: block length: "+str(block_length)+\&#10;", baseline_duration_ms: "+str(baseline_duration_ms)+", max_search_window_duration_ms: "+str(max_search_window_duration_ms)+\&#10;", num_random_events: "+str(num_random_events)+", IEI_duration_sec: "+str(IEI_duration_sec)+", pupil_sample_duration_ms: "+\&#10;str(pupil_sample_duration_ms)+", peak_pupil_quantile: "+str(peak_pupil_quantile)+", trough_pupil_quantile: "+str(trough_pupil_quantile)+\&#10;", dilation_quantile: "+str(dilation_quantile)+", constriction_quantile: "+str(constriction_quantile)&#10;logging.log(level=logging.EXP,msg=param_log_message)&#10;&#10;# save parameters in CSV as well &#10;thisExp.addData('baseline_duration', baseline_duration_ms)&#10;thisExp.addData('search_window_max_duration', max_search_window_duration_ms)&#10;thisExp.addData('IEI_duration', IEI_duration_sec)&#10;thisExp.addData('pupil_sample_duration_ms', pupil_sample_duration_ms)&#10;thisExp.addData('peak_pupil_quantile', peak_pupil_quantile)&#10;thisExp.addData('trough_pupil_quantile', trough_pupil_quantile)&#10;thisExp.addData('dilation_quantile', dilation_quantile)&#10;thisExp.addData('constriction_quantile', constriction_quantile)&#10;" valType="extendedCode" updates="constant" name="Begin Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="Begin JS Routine"/>
<Param val="# will keep track of accepted events&#10;decision_array = []&#10;" valType="extendedCode" updates="constant" name="Begin Routine"/>
<Param val="Py" valType="str" updates="None" name="Code Type"/>
<Param val="sd.build_search_window() # build the search window &#10;event_idx = sd.detect_events_online() # determine whether there was an event&#10;# 1 = peak, -1 = trough, 2 = dilation, -2 = contriction, 3 = random, 0 = no event&#10;decision_array.append(event_idx) # add event code to decision array &#10;&#10;# NOTE: here is where you might want to write custom code to have closed-loop&#10;# functionality - if the event is not 0 or 3, do something. &#10;&#10;# do some logging of each frame in the output CSV file: &#10;#time of event, event index, search window (and times associated)&#10;thisExp.addData('current_time',globalClock.getTime())&#10;thisExp.addData('event',event_idx)&#10;# demean search window to match log file &#10;search_window = sd.get_search_window()&#10;demeaned_window = list(search_window - np.nanmean(search_window))&#10;thisExp.addData('demeaned_search_window', demeaned_window)&#10;thisExp.addData('search_window_times', sd.get_search_window_times())&#10;thisExp.nextEntry() # get next frame on new line&#10;" valType="extendedCode" updates="constant" name="Each Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="Each JS Frame"/>
<Param val="" valType="extendedCode" updates="constant" name="End Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Experiment"/>
<Param val="" valType="extendedCode" updates="constant" name="End JS Routine"/>
<Param val="# append final decision array to end of CSV &#10;thisExp.addData('decision_array',decision_array) " valType="extendedCode" updates="constant" name="End Routine"/>
<Param val="False" valType="bool" updates="None" name="disabled"/>
<Param val="StimulusDecider_2" valType="code" updates="None" name="name"/>
</CodeComponent>
</Routine>
</Routines>
<Flow>
<Routine name="EyeLinkSetup"/>
<Routine name="task_instructions"/>
<Routine name="EyeLinkStart"/>
<LoopInitiator loopType="TrialHandler" name="trials">
<Param name="Selected rows" updates="None" val="0:1" valType="str"/>
<Param name="conditions" updates="None" val="[OrderedDict([('block_idx', 1)]), OrderedDict([('block_idx', 2)])]" valType="str"/>
<Param name="conditionsFile" updates="None" val="BlockData.csv" valType="file"/>
<Param name="endPoints" updates="None" val="[0, 1]" valType="num"/>
<Param name="isTrials" updates="None" val="True" valType="bool"/>
<Param name="loopType" updates="None" val="sequential" valType="str"/>
<Param name="nReps" updates="None" val="1" valType="num"/>
<Param name="name" updates="None" val="trials" valType="code"/>
<Param name="random seed" updates="None" val="" valType="code"/>
</LoopInitiator>
<Routine name="start_block"/>
<Routine name="fixation_routine2"/>
<Routine name="end_block"/>
<LoopTerminator name="trials"/>
<Routine name="EyeLinkStop"/>
<Routine name="end_experiment"/>
</Flow>
</PsychoPy2experiment>