-
Notifications
You must be signed in to change notification settings - Fork 0
/
fish-task_lastrun.py
2968 lines (2637 loc) · 125 KB
/
fish-task_lastrun.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy3 Experiment Builder (v2023.1.3),
on Mon Jul 24 16:00:39 2023
If you publish work using this script the most relevant publication is:
Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019)
PsychoPy2: Experiments in behavior made easy Behav Res 51: 195.
https://doi.org/10.3758/s13428-018-01193-y
"""
# --- Import packages ---
from psychopy import locale_setup
from psychopy import prefs
from psychopy import plugins
plugins.activatePlugins()
from psychopy import sound, gui, visual, core, data, event, logging, clock, colors, layout
from psychopy.tools import environmenttools
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)
import numpy as np # whole numpy lib is available, prepend 'np.'
from numpy import (sin, cos, tan, log, log10, pi, average,
sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle, choice as randchoice
import os # handy system and path functions
import sys # to get file system encoding
import psychopy.iohub as io
from psychopy.hardware import keyboard
# Run 'Before Experiment' code from mainCode
import random
#stimuli locations
pond_loc = [0,0.25]
boy_loc = [0.75,-0.30]
arrow_loc = [0.50,-0.30]
fish_loc = [[0.2,-0.30],[0,-0.30],[-0.2,-0.30],[-0.4,-0.30],[-0.6,-0.30]]
box_loc = [[-0.32,0.25],[0,0.25],[0.32,0.25]]
#stimuli onset time
fish_interval = [0.5,1.0,1.5]
block_correct = []
msg='doh!'#if this comes up we forgot to update the msg!
#condition folder directory
conditionfolder = ''
# Ensure that relative paths start from the same directory as this script
_thisDir = os.path.dirname(os.path.abspath(__file__))
os.chdir(_thisDir)
# Store info about the experiment session
psychopyVersion = '2023.1.3'
expName = 'FishGame' # from the Builder filename that created this script
expInfo = {
'participant': '99',
}
# --- Show participant info dialog --
dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)
if dlg.OK == False:
core.quit() # user pressed cancel
expInfo['date'] = data.getDateStr() # add a simple timestamp
expInfo['expName'] = expName
expInfo['psychopyVersion'] = psychopyVersion
# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])
# An ExperimentHandler isn't essential but helps with data saving
thisExp = data.ExperimentHandler(name=expName, version='',
extraInfo=expInfo, runtimeInfo=None,
originPath='/Users/janet/Desktop/Sinai_Projects/Code/fish-task-6B20T/FG-6B20T_updated_main_lastrun.py',
savePickle=True, saveWideText=True,
dataFileName=filename)
# save a log file for detail verbose info
logFile = logging.LogFile(filename+'.log', level=logging.DEBUG)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file
endExpNow = False # flag for 'escape' or other condition => quit the exp
frameTolerance = 0.001 # how close to onset before 'same' frame
# Start Code - component code to be run after the window creation
# --- Setup the Window ---
win = visual.Window(
size=[1536, 864], fullscr=True, screen=0,
winType='pyglet', allowStencil=False,
monitor='testMonitor', color=(1.0000, 1.0000, 1.0000), colorSpace='rgb',
backgroundImage='', backgroundFit='none',
blendMode='avg', useFBO=True,
units='height')
win.mouseVisible = False
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
frameDur = 1.0 / round(expInfo['frameRate'])
else:
frameDur = 1.0 / 60.0 # could not measure, so guess
# --- Setup input devices ---
ioConfig = {}
# Setup iohub keyboard
ioConfig['Keyboard'] = dict(use_keymap='psychopy')
ioSession = '1'
if 'session' in expInfo:
ioSession = str(expInfo['session'])
ioServer = io.launchHubServer(window=win, **ioConfig)
eyetracker = None
# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard(backend='iohub')
# --- Initialize components for Routine "ins1" ---
text_1a = visual.TextStim(win=win, name='text_1a',
text='The Fishing Game\n\nImagine a boy that goes fishing for 6 days. There are three ponds, each containing fish of different colors: blue, yellow, and green. In each pond the majority of the fish are of a single color.',
font='Open Sans',
pos=(0, 0.35), height=0.035, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=0.0);
ins1_key = keyboard.Keyboard()
ins1_image = visual.ImageStim(
win=win,
name='ins1_image',
image='stimuli/instruction_image.png', mask=None, anchor='center',
ori=0.0, pos=(0, 0.05), size=(0.6, 0.35),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-2.0)
text_1b = visual.TextStim(win=win, name='text_1b',
text='Each day, the boy catches 20 fish. He will show you the fish he catches one by one, shown in the black square. Each turn, you will guess from which pond he is fishing. \n\nThe boy will pick a different pond at the beginning of a new day, and he may or may not change ponds within the same day.\n\nPress any key to continue',
font='Open Sans',
pos=(0, -0.3), height=0.035, wrapWidth=None, ori=0.0,
color=[-1.0000, -1.0000, -1.0000], colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=-3.0);
# --- Initialize components for Routine "ins2" ---
text_2 = visual.TextStim(win=win, name='text_2',
text='A correct guess is rewarded with $0.50, while an incorrect guess earns $0. \n\nAt the end of the game, you will receive the total bonus from one randomly selected session. The maximum bonus you can receive from this game is $10.\n\nPress any key to continue',
font='Open Sans',
pos=(0, -0.2), height=0.05, wrapWidth=None, ori=0.0,
color=[-1.0000, -1.0000, -1.0000], colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=0.0);
ins2_key = keyboard.Keyboard()
inst2_image = visual.ImageStim(
win=win,
name='inst2_image',
image='stimuli/instruction_image.png', mask=None, anchor='center',
ori=0.0, pos=(0, 0.25), size=(0.6, 0.35),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-2.0)
# --- Initialize components for Routine "ins3" ---
text_3 = visual.TextStim(win=win, name='text_3',
text='Press LEFT, UP or RIGHT arrows to select your pond.\n\nThe game will start with a quick practice. During the practice, you will see whether you chose the right pond or not. But during the actual game, you will not get this feedback. The game takes approximately 10 minutes to complete.\n\nPress any key to start the practice',
font='Open Sans',
pos=(0, -0.2), height=0.045, wrapWidth=None, ori=0.0,
color=[-1.0000, -1.0000, -1.0000], colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=0.0);
ins3_key = keyboard.Keyboard()
inst3_image = visual.ImageStim(
win=win,
name='inst3_image',
image='stimuli/instruction_image.png', mask=None, anchor='center',
ori=0.0, pos=(0, 0.25), size=(0.6, 0.35),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-2.0)
# --- Initialize components for Routine "option_practice" ---
pond_label_2 = visual.TextStim(win=win, name='pond_label_2',
text='',
font='Open Sans',
pos=(0, -0.1), height=0.1, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=-1.0);
jars_2 = visual.ImageStim(
win=win,
name='jars_2',
image='stimuli/jars.PNG', mask=None, anchor='center',
ori=0.0, pos=pond_loc, size=(1, 0.5),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=False, depth=-2.0)
arrow_2 = visual.ImageStim(
win=win,
name='arrow_2',
image='stimuli/arrow.png', mask=None, anchor='center',
ori=0.0, pos=arrow_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-3.0)
boy_2 = visual.ImageStim(
win=win,
name='boy_2',
image='stimuli/clear-jar.PNG', mask=None, anchor='center',
ori=0.0, pos=boy_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-4.0)
F1_2 = visual.ImageStim(
win=win,
name='F1_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[0]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-5.0)
F2_2 = visual.ImageStim(
win=win,
name='F2_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[1]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-6.0)
F3_2 = visual.ImageStim(
win=win,
name='F3_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[2]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-7.0)
F4_2 = visual.ImageStim(
win=win,
name='F4_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[3]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-8.0)
F5_2 = visual.ImageStim(
win=win,
name='F5_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[4]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-9.0)
box_outline_2 = visual.Rect(
win=win, name='box_outline_2',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor=None,
opacity=None, depth=-10.0, interpolate=True)
box_show_2 = visual.Rect(
win=win, name='box_show_2',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor='black',
opacity=None, depth=-11.0, interpolate=True)
key_resp_2 = keyboard.Keyboard()
# --- Initialize components for Routine "response_practice" ---
pond_label2_2 = visual.TextStim(win=win, name='pond_label2_2',
text='',
font='Open Sans',
pos=(0, -0.1), height=0.1, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=-1.0);
jars2_2 = visual.ImageStim(
win=win,
name='jars2_2',
image='stimuli/jars.PNG', mask=None, anchor='center',
ori=0.0, pos=pond_loc, size=(1, 0.5),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=False, depth=-2.0)
arrow2_2 = visual.ImageStim(
win=win,
name='arrow2_2',
image='stimuli/arrow.png', mask=None, anchor='center',
ori=0.0, pos=arrow_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-3.0)
boy2_2 = visual.ImageStim(
win=win,
name='boy2_2',
image='stimuli/clear-jar.PNG', mask=None, anchor='center',
ori=0.0, pos=boy_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-4.0)
f1_2 = visual.ImageStim(
win=win,
name='f1_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[0]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-5.0)
f2_2 = visual.ImageStim(
win=win,
name='f2_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[1]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-6.0)
f3_2 = visual.ImageStim(
win=win,
name='f3_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[2]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-7.0)
f4_2 = visual.ImageStim(
win=win,
name='f4_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[3]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-8.0)
f5_2 = visual.ImageStim(
win=win,
name='f5_2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[4]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-9.0)
boxB_2 = visual.Rect(
win=win, name='boxB_2',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-10.0, interpolate=True)
boxY_2 = visual.Rect(
win=win, name='boxY_2',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[1]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-11.0, interpolate=True)
boxG_2 = visual.Rect(
win=win, name='boxG_2',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[2]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-12.0, interpolate=True)
box_outline2_2 = visual.Rect(
win=win, name='box_outline2_2',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor='black',
opacity=None, depth=-13.0, interpolate=True)
# --- Initialize components for Routine "wait" ---
Begin_txt = visual.TextStim(win=win, name='Begin_txt',
text='You have successfully completed the practice.\n\nNow you are ready to start the game.\n\nPress SPACE key to continue. ',
font='Open Sans',
pos=(0, 0), height=0.07, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=0.0);
ExpStart_key = keyboard.Keyboard()
# --- Initialize components for Routine "reward_reset" ---
# --- Initialize components for Routine "option_fish" ---
# Run 'Begin Experiment' code from mainCode
#if expInfo.get('condition') == '1':
# conditionfolder = '1condition/Blocks.xlsx'
#
#if expInfo.get('condition') == '2':
# conditionfolder = '2condition/Blocks.xlsx'
pond_label = visual.TextStim(win=win, name='pond_label',
text='',
font='Open Sans',
pos=(0, -0.1), height=0.1, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=-1.0);
jars = visual.ImageStim(
win=win,
name='jars',
image='stimuli/jars.PNG', mask=None, anchor='center',
ori=0.0, pos=pond_loc, size=(1, 0.5),
color=(1.0000, 1.0000, 1.0000), colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=False, depth=-2.0)
arrow = visual.ImageStim(
win=win,
name='arrow',
image='stimuli/arrow.png', mask=None, anchor='center',
ori=0.0, pos=arrow_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-3.0)
boy = visual.ImageStim(
win=win,
name='boy',
image='stimuli/clear-jar.PNG', mask=None, anchor='center',
ori=0.0, pos=boy_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-4.0)
F1 = visual.ImageStim(
win=win,
name='F1',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[0]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-5.0)
F2 = visual.ImageStim(
win=win,
name='F2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[1]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-6.0)
F3 = visual.ImageStim(
win=win,
name='F3',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[2]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-7.0)
F4 = visual.ImageStim(
win=win,
name='F4',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[3]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-8.0)
F5 = visual.ImageStim(
win=win,
name='F5',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[4]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-9.0)
box_outline = visual.Rect(
win=win, name='box_outline',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor=None,
opacity=None, depth=-10.0, interpolate=True)
box_show = visual.Rect(
win=win, name='box_show',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor='black',
opacity=None, depth=-11.0, interpolate=True)
fish_key_button = keyboard.Keyboard()
# --- Initialize components for Routine "response_fish" ---
jars2 = visual.ImageStim(
win=win,
name='jars2',
image='stimuli/jars.PNG', mask=None, anchor='center',
ori=0.0, pos=pond_loc, size=(1, 0.5),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=False, depth=-1.0)
arrow2 = visual.ImageStim(
win=win,
name='arrow2',
image='stimuli/arrow.png', mask=None, anchor='center',
ori=0.0, pos=arrow_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-2.0)
boy2 = visual.ImageStim(
win=win,
name='boy2',
image='stimuli/clear-jar.PNG', mask=None, anchor='center',
ori=0.0, pos=boy_loc, size=(0.20, 0.20),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-3.0)
f1 = visual.ImageStim(
win=win,
name='f1',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[0]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-4.0)
f2 = visual.ImageStim(
win=win,
name='f2',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[1]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-5.0)
f3 = visual.ImageStim(
win=win,
name='f3',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[2]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-6.0)
f4 = visual.ImageStim(
win=win,
name='f4',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[3]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-7.0)
f5 = visual.ImageStim(
win=win,
name='f5',
image='default.png', mask=None, anchor='center',
ori=0.0, pos=[fish_loc[4]], size=(0.15, 0.15),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-8.0)
boxB = visual.Rect(
win=win, name='boxB',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-9.0, interpolate=True)
boxY = visual.Rect(
win=win, name='boxY',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[1]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-10.0, interpolate=True)
boxG = visual.Rect(
win=win, name='boxG',
width=(0.30, 0.45)[0], height=(0.30, 0.45)[1],
ori=0.0, pos=[box_loc[2]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor=None, fillColor=None,
opacity=None, depth=-11.0, interpolate=True)
box_outline2 = visual.Rect(
win=win, name='box_outline2',
width=(0.20,0.20)[0], height=(0.20,0.20)[1],
ori=0.0, pos=[fish_loc[0]], anchor='center',
lineWidth=5.0, colorSpace='rgb', lineColor='black', fillColor='black',
opacity=None, depth=-12.0, interpolate=True)
# --- Initialize components for Routine "block_break" ---
breakStart_txt = visual.TextStim(win=win, name='breakStart_txt',
text='End of the day.\n\nNew day starts soon.',
font='Open Sans',
pos=(0, 0), height=0.07, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=-1.0);
# --- Initialize components for Routine "reward" ---
reward_txt = visual.TextStim(win=win, name='reward_txt',
text='Thank you!',
font='Open Sans',
pos=(0, 0), height=0.07, wrapWidth=None, ori=0.0,
color='black', colorSpace='rgb', opacity=None,
languageStyle='LTR',
depth=0.0);
# Create some handy timers
globalClock = core.Clock() # to track the time since experiment started
routineTimer = core.Clock() # to track time remaining of each (possibly non-slip) routine
# --- Prepare to start Routine "ins1" ---
continueRoutine = True
# update component parameters for each repeat
ins1_key.keys = []
ins1_key.rt = []
_ins1_key_allKeys = []
# keep track of which components have finished
ins1Components = [text_1a, ins1_key, ins1_image, text_1b]
for thisComponent in ins1Components:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
frameN = -1
# --- Run Routine "ins1" ---
routineForceEnded = not continueRoutine
while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *text_1a* updates
# if text_1a is starting this frame...
if text_1a.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
text_1a.frameNStart = frameN # exact frame index
text_1a.tStart = t # local t and not account for scr refresh
text_1a.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(text_1a, 'tStartRefresh') # time at next scr refresh
# update status
text_1a.status = STARTED
text_1a.setAutoDraw(True)
# if text_1a is active this frame...
if text_1a.status == STARTED:
# update params
pass
# *ins1_key* updates
waitOnFlip = False
# if ins1_key is starting this frame...
if ins1_key.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
ins1_key.frameNStart = frameN # exact frame index
ins1_key.tStart = t # local t and not account for scr refresh
ins1_key.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(ins1_key, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'ins1_key.started')
# update status
ins1_key.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(ins1_key.clock.reset) # t=0 on next screen flip
win.callOnFlip(ins1_key.clearEvents, eventType='keyboard') # clear events on next screen flip
if ins1_key.status == STARTED and not waitOnFlip:
theseKeys = ins1_key.getKeys(keyList=None, waitRelease=False)
_ins1_key_allKeys.extend(theseKeys)
if len(_ins1_key_allKeys):
ins1_key.keys = _ins1_key_allKeys[-1].name # just the last key pressed
ins1_key.rt = _ins1_key_allKeys[-1].rt
ins1_key.duration = _ins1_key_allKeys[-1].duration
# a response ends the routine
continueRoutine = False
# *ins1_image* updates
# if ins1_image is starting this frame...
if ins1_image.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
ins1_image.frameNStart = frameN # exact frame index
ins1_image.tStart = t # local t and not account for scr refresh
ins1_image.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(ins1_image, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'ins1_image.started')
# update status
ins1_image.status = STARTED
ins1_image.setAutoDraw(True)
# if ins1_image is active this frame...
if ins1_image.status == STARTED:
# update params
pass
# *text_1b* updates
# if text_1b is starting this frame...
if text_1b.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
text_1b.frameNStart = frameN # exact frame index
text_1b.tStart = t # local t and not account for scr refresh
text_1b.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(text_1b, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'text_1b.started')
# update status
text_1b.status = STARTED
text_1b.setAutoDraw(True)
# if text_1b is active this frame...
if text_1b.status == STARTED:
# update params
pass
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
if eyetracker:
eyetracker.setConnectionState(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineForceEnded = True
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in ins1Components:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# --- Ending Routine "ins1" ---
for thisComponent in ins1Components:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# check responses
if ins1_key.keys in ['', [], None]: # No response was made
ins1_key.keys = None
thisExp.addData('ins1_key.keys',ins1_key.keys)
if ins1_key.keys != None: # we had a response
thisExp.addData('ins1_key.rt', ins1_key.rt)
thisExp.addData('ins1_key.duration', ins1_key.duration)
thisExp.nextEntry()
# the Routine "ins1" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
# --- Prepare to start Routine "ins2" ---
continueRoutine = True
# update component parameters for each repeat
ins2_key.keys = []
ins2_key.rt = []
_ins2_key_allKeys = []
# keep track of which components have finished
ins2Components = [text_2, ins2_key, inst2_image]
for thisComponent in ins2Components:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
frameN = -1
# --- Run Routine "ins2" ---
routineForceEnded = not continueRoutine
while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *text_2* updates
# if text_2 is starting this frame...
if text_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
text_2.frameNStart = frameN # exact frame index
text_2.tStart = t # local t and not account for scr refresh
text_2.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(text_2, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'text_2.started')
# update status
text_2.status = STARTED
text_2.setAutoDraw(True)
# if text_2 is active this frame...
if text_2.status == STARTED:
# update params
pass
# *ins2_key* updates
waitOnFlip = False
# if ins2_key is starting this frame...
if ins2_key.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
ins2_key.frameNStart = frameN # exact frame index
ins2_key.tStart = t # local t and not account for scr refresh
ins2_key.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(ins2_key, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'ins2_key.started')
# update status
ins2_key.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(ins2_key.clock.reset) # t=0 on next screen flip
win.callOnFlip(ins2_key.clearEvents, eventType='keyboard') # clear events on next screen flip
if ins2_key.status == STARTED and not waitOnFlip:
theseKeys = ins2_key.getKeys(keyList=None, waitRelease=False)
_ins2_key_allKeys.extend(theseKeys)
if len(_ins2_key_allKeys):
ins2_key.keys = _ins2_key_allKeys[-1].name # just the last key pressed
ins2_key.rt = _ins2_key_allKeys[-1].rt
ins2_key.duration = _ins2_key_allKeys[-1].duration
# a response ends the routine
continueRoutine = False
# *inst2_image* updates
# if inst2_image is starting this frame...
if inst2_image.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
inst2_image.frameNStart = frameN # exact frame index
inst2_image.tStart = t # local t and not account for scr refresh
inst2_image.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(inst2_image, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'inst2_image.started')
# update status
inst2_image.status = STARTED
inst2_image.setAutoDraw(True)
# if inst2_image is active this frame...
if inst2_image.status == STARTED:
# update params
pass
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
if eyetracker:
eyetracker.setConnectionState(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineForceEnded = True
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in ins2Components:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# --- Ending Routine "ins2" ---
for thisComponent in ins2Components:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# the Routine "ins2" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
# --- Prepare to start Routine "ins3" ---
continueRoutine = True
# update component parameters for each repeat
ins3_key.keys = []
ins3_key.rt = []
_ins3_key_allKeys = []
# keep track of which components have finished
ins3Components = [text_3, ins3_key, inst3_image]
for thisComponent in ins3Components:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
frameN = -1
# --- Run Routine "ins3" ---
routineForceEnded = not continueRoutine
while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *text_3* updates
# if text_3 is starting this frame...
if text_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
text_3.frameNStart = frameN # exact frame index
text_3.tStart = t # local t and not account for scr refresh
text_3.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(text_3, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'text_3.started')
# update status
text_3.status = STARTED
text_3.setAutoDraw(True)
# if text_3 is active this frame...
if text_3.status == STARTED:
# update params
pass
# *ins3_key* updates
waitOnFlip = False
# if ins3_key is starting this frame...
if ins3_key.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
ins3_key.frameNStart = frameN # exact frame index
ins3_key.tStart = t # local t and not account for scr refresh
ins3_key.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(ins3_key, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'ins3_key.started')
# update status
ins3_key.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(ins3_key.clock.reset) # t=0 on next screen flip
win.callOnFlip(ins3_key.clearEvents, eventType='keyboard') # clear events on next screen flip
if ins3_key.status == STARTED and not waitOnFlip:
theseKeys = ins3_key.getKeys(keyList=None, waitRelease=False)
_ins3_key_allKeys.extend(theseKeys)
if len(_ins3_key_allKeys):
ins3_key.keys = _ins3_key_allKeys[-1].name # just the last key pressed
ins3_key.rt = _ins3_key_allKeys[-1].rt
ins3_key.duration = _ins3_key_allKeys[-1].duration
# a response ends the routine
continueRoutine = False
# *inst3_image* updates
# if inst3_image is starting this frame...
if inst3_image.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
inst3_image.frameNStart = frameN # exact frame index
inst3_image.tStart = t # local t and not account for scr refresh
inst3_image.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(inst3_image, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'inst3_image.started')
# update status
inst3_image.status = STARTED
inst3_image.setAutoDraw(True)
# if inst3_image is active this frame...
if inst3_image.status == STARTED:
# update params
pass
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
if eyetracker:
eyetracker.setConnectionState(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineForceEnded = True
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in ins3Components:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# --- Ending Routine "ins3" ---
for thisComponent in ins3Components:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# the Routine "ins3" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
# set up handler to look after randomisation of conditions etc
prac_trials = data.TrialHandler(nReps=1.0, method='sequential',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('1condition/practice.xlsx'),
seed=None, name='prac_trials')
thisExp.addLoop(prac_trials) # add the loop to the experiment
thisPrac_trial = prac_trials.trialList[0] # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisPrac_trial.rgb)
if thisPrac_trial != None:
for paramName in thisPrac_trial:
exec('{} = thisPrac_trial[paramName]'.format(paramName))
for thisPrac_trial in prac_trials:
currentLoop = prac_trials
# abbreviate parameter names if possible (e.g. rgb = thisPrac_trial.rgb)
if thisPrac_trial != None:
for paramName in thisPrac_trial:
exec('{} = thisPrac_trial[paramName]'.format(paramName))
# --- Prepare to start Routine "option_practice" ---
continueRoutine = True
# update component parameters for each repeat
# Run 'Begin Routine' code from code_2