-
Notifications
You must be signed in to change notification settings - Fork 2
/
OrientationWheelTask_Exo_v2.asv
1354 lines (1089 loc) · 60.8 KB
/
OrientationWheelTask_Exo_v2.asv
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
% OrientationWheelTask_Exo_v2()
% Runs a color working memory task a la Zhang & Luck (2008). The task
% requires memory for the color of briefly presented squares. Participants
% then report the color of a single probed square using a contnuous report
% task.
%
%
% Fixation appears for one entrainer length instead of a blank screen.
%
% -------------------------------------------------------------------------
% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
% _________________________________________________________________________
%
% /////////////////////////////////////////////////////////////////////////
%
% ==== TRIGGERS ====
%
% Start eye tracker: 199
%
% -- Targets Present --
% Trial start (fixation): 1
% Entrainers: 61-68*
% Cue:
% left: 2
% right: 3
% both: 9
% Target:
% left: 30
% right: 20
% Mask: 90
% Response screen target: 5
% Response target: 80
% Response screen Y/N: 25
% Response Yes: 180
% Response No: 185
% Response invalid: 150
%
% -- Targets Not Present --
% Trial start (fixation): 11
% Entrainers: 61-68
% Cue:
% left: 12
% right: 13
% both: 19
% Target: 40
% Mask: 95
% Response screen target: 15
% Response target: 70
% Response screen Y/N: 35
% Response Yes: 170
% Response No: 175
% Response invalid: 140
%
% /////////////////////////////////////////////////////////////////////////
function OrientationWheelTask_Exo_v2()
ccc
try
prepareEnvironment;
% /////////////////////////////////////////////////////////////////////////
% -------------------------------------------------------------------------
% Input participant's number, name, date of testing, preferences
part_num = input('Participant Number:','s');
Filename = ['M:\Experiments\OrientWheel_Exo\Orient_Data\' part_num '_Orient_Exo.mat'];
% Do you already have a color value or use default?
color_yn = input('Do you want to input the target color? [y or n]:','s');
if strncmpi(color_yn,'y',1)
% If not doing staircasing, input target color (0 black to 128 background grey)
xtarget_gray = input('Target color [0 to 128]:','s');
xtarget_gray = str2num(xtarget_gray); %convert input to number
end
% Is eyetracking going to be used?
% eyetrack_yn = input('Are you using the eye tracker? [y or n]:','s');
eyetrack_yn = 'n'; %eyetracker not working so always no for now
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% /////////////////////////////////////////////////////////////////////////
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
window = openWindow(); %get info for psychtoolbox
prefs = getPreferences(); %get task variable info
% /////////////////////////////////////////////////////////////////////////
% /////////////////////////////////////////////////////////////////////////
%% Instructions for experimenter to start eye tracking
if strncmpi(eyetrack_yn,'y',1)
Screen('FillRect',window.onScreen,window.gray);
DrawFormattedText(window.onScreen,'Calibrated? Start EEG Recording and Press the SPACE BAR','center','center',[]);
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
Screen('Flip',window.onScreen)
KbWait;
Screen('FillRect',window.onScreen,window.gray);
Screen('FillRect',window.onScreen,Vpixx2Vamp(199),prefs.trigger_size);
Screen('Flip',window.onScreen);
% system('C:\Users\user\Downloads\CoreSDK\CoreSDK\samples\Streams\Interaction_Streams_101\bin\Debug\Interaction_Streams_101.exe &');
system('M:\Experiments\micb_eyetrack\CoreSDK\CoreSDK\samples\Streams\Interaction_Streams_101\bin\Debug\Interaction_Streams_101.exe &');
WaitSecs(2);
end
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% /////////////////////////////////////////////////////////////////////////
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% counter of trials per block
nblock = prefs.trials_per_block + 20; %including the first 20 practice trials
% total number of trials including practice trials
ntotaltrial = prefs.nTrials + 20; %add 20 practice trials
% -------------------------------------------------------------------------
% Get presentation timing information
refresh = Screen('GetFlipInterval', window.onScreen); % Get flip refresh rate
slack = refresh/2; % Divide by 2 to get slack
% -------------------------------------------------------------------------
% Get rects for each item.
rects = cell(1, max(prefs.setSizes));
for i = 1:max(prefs.setSizes)
rects{i} = circularArrayRects([0, 0, prefs.squareSize, prefs.squareSize], ...
i, prefs.radius, window.centerX, window.centerY)';
end
% -------------------------------------------------------------------------
% Center the target oval & cues on the centre of the screen
centeredRectresp = CenterRectOnPointd(prefs.baseCircleresp,window.centerX,window.centerY);
centeredRectrespR = CenterRectOnPointd(prefs.baseCircleresp,window.centerXR,window.centerY);
centeredRectrespL = CenterRectOnPointd(prefs.baseCircleresp,window.centerXL,window.centerY);
% -------------------------------------------------------------------------
% Set colors of stimuli
% prefs.mask_gray = window.gray - prefs.mask_thresh; %mask color (77.5)
prefs.mask_gray = 0; %default is black
% Use default stimuli colors if not specified above
if strncmpi(color_yn,'y',1)
% prefs.targ_gray = window.gray - prefs.targ_thresh; %default target color (77.5)
prefs.targ_gray = xtarget_gray;
else
prefs.targ_gray = 0; %default is black
end
% -------------------------------------------------------------------------
% Create offscreen window with the texture of the mask
maskwin = createMasktex(window,prefs);
% -------------------------------------------------------------------------
% Get coordinates of the place holder
placeRect = createPlaceHolder(window,prefs);
% -------------------------------------------------------------------------
% Create offscreen window with the cues
CueL = createCueL(window); %create offscreen window with cue
CueR = createCueR(window); %create offscreen window with cue
CueN = createCueN(window); %create offscreen window with non-informative cue
% -------------------------------------------------------------------------
% Put up instructions and wait for keypress.
instruct(window,prefs);
% -------------------------------------------------------------------------
% Location of orientations on screen
orientWheelLocations = orientwheelLocations(window,prefs);
% -------------------------------------------------------------------------
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% -------------------------------------------------------------------------
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Set up the random mix of lags and target position and cue for each block
%Now to find a lag you pick the next random index between 1:n_lags from i_lags
%Then you find that index in all_lags, it tells you where to look in lags
all_lags = [1:prefs.n_lags];
if prefs.lags_per_block > 1
for i_lag = 2:prefs.lags_per_block
all_lags = [all_lags 1:prefs.n_lags];
end
end
i_lags = randperm(prefs.lags_per_block * (prefs.n_lags));
all_lags = all_lags(i_lags);
clear i_lag
%set up the right/left target location
position = 1;
for i_pos = 2:ntotaltrial
if i_pos <= round(ntotaltrial/2)
position = [position 1]; % 1 is right
else
position = [position 0]; % 0 is left
end
end
position = position(randperm(ntotaltrial));
%set up the valid/invalid cues (1=informative)
valid = 1;
validtrials = ntotaltrial*prefs.p_validity;
for i_valid = 2:ntotaltrial
if i_valid > round(validtrials)
valid = [valid 0];
else
valid = [valid 1];
end
end
clear i_valid
valid = valid(randperm(ntotaltrial));
%set up the catch trials on every n-lagsth trial
p = 1/prefs.p_catchtrials;
q = 1/prefs.p_catchtrials;
present = [1];
for i_pres = 2:ntotaltrial
if i_pres == p
present = [present 0];
p = p + q;
else
present = [present 1];
end
end
rand_pres = randperm(ntotaltrial);
present = present(rand_pres);
clear rand_pres
% Pre-allocate some variables
allCoords_targ = cell(1,ntotaltrial);
trialOrient = cell(1,ntotaltrial);
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% START TASK
for trialIndex = 1:ntotaltrial
lag = prefs.lags(all_lags(trialIndex))/5;
% Determine how many items there are on this trial and the duration (this is left over code from original task)
nItems = 1; %should always be 1 because there will only be 1 target
retentionInterval = prefs.retentionIntervals; %(prefs.fullFactorialDesign(prefs.order(trialIndex), 2));
% Pick an item to test.
% itemToTest(trialIndex) = randsample(1:nItems); %legacy code that no longer works
itemToTest(trialIndex) = nItems; %nItems should always be 1 because there will only be 1 target
% Pick the orientation for this trial.
trialOrient{trialIndex} = prefs.degslocs(prefs.selectorientTrial(trialIndex));
if present(trialIndex) == 1
pause(window);
%Present Fixation
Screen('FillRect', window.onScreen, window.gray);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen, Vpixx2Vamp(1), prefs.trigger_size);
t_fixate_onset = Screen('Flip', window.onScreen);
elseif present(trialIndex) == 0
pause(window);
%Present Fixation
Screen('FillRect', window.onScreen, window.gray);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen, Vpixx2Vamp(11), prefs.trigger_size);
t_fixate_onset = Screen('Flip', window.onScreen);
end
% Interval (refresh screen)
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %keep fixation till target
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
Screen('Flip', window.onScreen);
% =========================================================================
%% Cue
if present(trialIndex) == 1 %two options depending on whether the target is present or absent
if valid(trialIndex) == 0 %non-informative cue
% present the non-informative cue
Screen('DrawTexture', window.onScreen, CueN, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(9),prefs.trigger_size);
else %informative cue
if position(trialIndex) == 0
% present the Left cue
Screen('DrawTexture', window.onScreen, CueL, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(2),prefs.trigger_size);
end
if position(trialIndex) == 1
% present the Right cue
Screen('DrawTexture', window.onScreen, CueR, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(3),prefs.trigger_size);
end
end
elseif present(trialIndex) == 0 %no target
if valid(trialIndex) == 0 %non-informative cue
% present the non-informative cue
Screen('DrawTexture', window.onScreen, CueN, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(19),prefs.trigger_size);
else %informative cue
if position(trialIndex) == 0
% present the Left cue
Screen('DrawTexture', window.onScreen, CueL, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(12),prefs.trigger_size);
end
if position(trialIndex) == 1
% present the Right cue
Screen('DrawTexture', window.onScreen, CueR, [], [], [], 0);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);%draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(13),prefs.trigger_size);
end
end
end
tcue_onset = Screen('Flip',window.onScreen,t_fixate_onset + prefs.fixation_length*refresh - slack);
prefs.fixation_time(trialIndex) = tcue_onset - t_fixate_onset;
% Post-cue interval
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %keep fixation till target
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
tblank_onset = Screen('Flip',window.onScreen,tcue_onset + prefs.cue_length*refresh - slack);
% =========================================================================
%% Entrainers
if prefs.n_entrs > 0
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %keep fixation till target
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(61),prefs.trigger_size);
tentr_onset = Screen(window.onScreen, 'Flip',tblank_onset + prefs.preblank_length*refresh - slack);
if prefs.n_entrs > 1
for i_entr = 2:prefs.n_entrs
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
tblank_onset = Screen(window.onScreen, 'Flip', tentr_onset + prefs.entr_length*refresh - slack);
Screen('FillOval', window.onScreen, (prefs.entr_grey+window.gray),...
[rects{nItems}(1)-prefs.maskwidth, rects{nItems}(2)-prefs.maskwidth,rects{nItems}(3)+prefs.maskwidth,...
rects{nItems}(4)+prefs.maskwidth]);
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(60 + i_entr),prefs.trigger_size);
tentr_onset = Screen(window.onScreen, 'Flip', tblank_onset + prefs.entr_gap_length*refresh - slack);
end
end
end
% =========================================================================
%% Lag
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %keep fixation till target
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
tlag_onset = Screen(window.onScreen, 'Flip', tentr_onset + prefs.entr_length*refresh - slack);
% =========================================================================
% =========================================================================
if present(trialIndex) == 1 %two options depending on whether the target is present or absent
% =========================================================================
%% Draw the target stimulus
%same for left and right targets
yadj = prefs.orientwheel(2,trialOrient{trialIndex}); %adjust lines y position
xadj = prefs.orientwheel(1,trialOrient{trialIndex}); %adjust lines x position
yadj2 = prefs.orientwheel2(2,trialOrient{trialIndex}); %adjust lines y position
xadj2 = prefs.orientwheel2(1,trialOrient{trialIndex}); %adjust lines x position
% Set the coordinates (these are all relative to zero we will let
% the drawing routine center it for us)
xCoords = [xadj -xadj2 xadj xadj2 xadj 0];
yCoords = [yadj yadj2 yadj -yadj2 yadj 0];
allCoords_targ{trialIndex} = [xCoords; yCoords];
% =========================================================================
%% Right Target
if position(trialIndex) == 1 %right target
% Draw the orientation lines, set it to the center of our screen and set good quality antialiasing
Screen('DrawLines', window.onScreen, allCoords_targ{trialIndex}, prefs.lineWidthPix, prefs.targ_gray, [window.centerXR window.centerY], 2);
% Draw the central circle to the screen
Screen('FillOval', window.onScreen, prefs.targ_gray, centeredRectrespR');
% Draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
% Draw trigger
Screen('FillRect',window.onScreen,Vpixx2Vamp(20),prefs.trigger_size);
% =========================================================================
else
%% Left Target
% Draw the orientation lines, set it to the center of our screen and set good quality antialiasing
Screen('DrawLines', window.onScreen, allCoords_targ{trialIndex}, prefs.lineWidthPix, prefs.targ_gray, [window.centerXL window.centerY], 2);
% Draw the central circle to the screen
Screen('FillOval', window.onScreen, prefs.targ_gray, centeredRectrespL');
% Draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
% Draw trigger
Screen('FillRect',window.onScreen,Vpixx2Vamp(30),prefs.trigger_size);
end
% =========================================================================
else
%% present the Missing Target
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
% Draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
% Draw trigger
Screen('FillRect',window.onScreen,Vpixx2Vamp(40),prefs.trigger_size);
end
% =========================================================================
% Post the stimulus
ttarget_onset = Screen('Flip', window.onScreen,tlag_onset + prefs.lagISI(all_lags(trialIndex))*refresh - slack);
% =========================================================================
%% blank Inter stimulus interval
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
%draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
tISI_onset = Screen('Flip', window.onScreen, ttarget_onset + prefs.targ_length*refresh - slack);
% =========================================================================
%% Mask
% Draw the texture
if present(trialIndex) == 1
Screen('DrawTexture', window.onScreen, maskwin, [], [], [], 0);
%draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(90),prefs.trigger_size);
elseif present(trialIndex) == 0
Screen('DrawTexture', window.onScreen, maskwin, [], [], [], 0);
%draw fixation
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(95),prefs.trigger_size);
end
t_maskonset = Screen('Flip', window.onScreen, tISI_onset + prefs.maskISI*refresh - slack);
% Interval
Screen('FillOval', window.onScreen, window.gray, rects{nItems});
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %Draw fixation
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect); %placeholder
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
Screen('Flip', window.onScreen, t_maskonset + prefs.mask_length*refresh - slack);
% Retention interval
WaitSecs(retentionInterval);
% =========================================================================
%% Response Target
% Choose a orientation to test, then display the response screen.
data.presentedOrientRads(trialIndex) = deg2rad(trialOrient{trialIndex});
data.presentedOrientDegrees(trialIndex) = trialOrient{trialIndex};
if present(trialIndex) == 1
Screen('FillRect',window.onScreen, Vpixx2Vamp(5), prefs.trigger_size);
Screen('Flip', window.onScreen);
else
Screen('FillRect',window.onScreen, Vpixx2Vamp(15), prefs.trigger_size);
Screen('Flip', window.onScreen);
end
%------------------------------------------------------------------
% Set-up response stimuli.
%randomize starting location of lines if mouse is not moved
startdeg = prefs.degslocs(randi(length(prefs.degslocs),1));
centeredRectmouse = CenterRectOnPointd([prefs.orientwheel(1,startdeg),prefs.orientwheel(2,startdeg),...
20,20],window.centerX,window.centerY);
SetMouse(centeredRectmouse(1),centeredRectmouse(2)); %mouse start location
ShowCursor('Arrow');
clear centeredRectmouse
%------------------------------------------------------------------
% If mouse button is already down, wait for release.
GetMouse(window.onScreen);
buttons = 0;
while any(buttons)
[x, y, buttons] = GetMouse(window.onScreen);
end
%------------------------------------------------------------------
everMovedFromCenter = false;
while ~any(buttons) % keep track of mouse location if moved
[x,y,buttons] = GetMouse(window.onScreen);
[minDistance, minDistanceIndex] = min(sqrt((orientWheelLocations(1, :) - x).^2 + (orientWheelLocations(2, :) - y).^2));
if(minDistance < 3) %make sure subject moved mouse
everMovedFromCenter = true;
end
if(everMovedFromCenter) %as the mouse is moved, update coords of response stimulus to match
% new coordinates of start and end of lines based on mouse position
yloc = prefs.orientwheel(2,minDistanceIndex); %adjust lines y position
xloc = prefs.orientwheel(1,minDistanceIndex); %adjust lines x position
yloc2 = prefs.orientwheel2(2,minDistanceIndex); %for edge lines
xloc2 = prefs.orientwheel2(1,minDistanceIndex); %for edge lines
else
%starting location of lines if mouse is not moved - randomized
yloc = prefs.orientwheel(2,startdeg); %adjust lines y position
xloc = prefs.orientwheel(1,startdeg); %adjust lines x position
yloc2 = prefs.orientwheel2(2,startdeg); %for edge lines
xloc2 = prefs.orientwheel2(1,startdeg); %for edge lines
% yloc = -30;
% xloc = 0;
% yloc2 = 0;
% xloc2 = 2;
end
% Set the new coordinates
xCoords = [xloc -xloc2 xloc xloc2 xloc 0];
yCoords = [yloc yloc2 yloc -yloc2 yloc 0];
allCoords = [xCoords; yCoords];
% Draw the orient lines, set it to the center of our screen and
% set good quality antialiasing
Screen('DrawLines', window.onScreen, allCoords, prefs.lineWidthPix, prefs.mask_gray, [window.centerX window.centerY], 2);
% Draw the circle part of the stimulus to the screen
Screen('FillOval', window.onScreen, prefs.mask_gray, centeredRectresp');
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
Screen('Flip', window.onScreen);
clear xCoords yCoords allCoords
end
%------------------------------------------------------------------
if present(trialIndex) == 1
Screen('FillRect',window.onScreen,Vpixx2Vamp(80),prefs.trigger_size);
Screen('Flip', window.onScreen);
elseif present(trialIndex) == 0
Screen('FillRect',window.onScreen,Vpixx2Vamp(70),prefs.trigger_size);
Screen('Flip', window.onScreen);
end
% calculate response location
[respDistance, respDistanceIndex] = min(sqrt((orientWheelLocations(1,:) - x).^2 + (orientWheelLocations(2,:) - y).^2));
data.reportedOrientRads(trialIndex) = deg2rad(respDistanceIndex);
data.reportedOrientDegrees(trialIndex) = respDistanceIndex;
data.reportedRespDistance(trialIndex) = respDistance;
% put trial info into data structure
data.lags(trialIndex) = lag;
data.present(trialIndex) = present(trialIndex); %target present or absent
HideCursor
% =========================================================================
% =========================================================================
%% Response Yes/No
% SetMouse(window.centerX, window.centerY); %mouse at center
% ShowCursor('Arrow');
%
% % Create response screen
% answer = BinaryQuestion_OrientWheel(window.onScreen,255,window.black,...
% 'Did you see the target?','Yes','No', prefs.trigger_size, present(trialIndex));
%
% %------------------------------------------------------------------
% %Responded Yes
% if answer == 1
% data.seen_resp(trialIndex) = 1; %record response
% if present(trialIndex) == 1
% Screen('FillRect',window.onScreen,Vpixx2Vamp(180),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% elseif present(trialIndex) == 0
% Screen('FillRect',window.onScreen,Vpixx2Vamp(170),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% end
% % -------------------------------------------------------------------------------------------
% %Responded No
% elseif answer == 2
% data.seen_resp(trialIndex) = 0; %record response
% if present(trialIndex) == 1
% Screen('FillRect',window.onScreen,Vpixx2Vamp(185),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% elseif present(trialIndex) == 0
% Screen('FillRect',window.onScreen,Vpixx2Vamp(175),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% end
% % ------------------------------------------------------------------------------------------
% %Did not click on text
% else
% data.seen_resp(trialIndex) = -2; %record response
% if present(trialIndex) == 1
% Screen('FillRect',window.onScreen,Vpixx2Vamp(150),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% elseif present(trialIndex) == 0
% Screen('FillRect',window.onScreen,Vpixx2Vamp(140),prefs.trigger_size);
% Screen('Flip', window.onScreen);
% end
% end
%
% HideCursor
%
% % =========================================================================
% =========================================================================
if trialIndex == ntotaltrial
finish(window);
elseif trialIndex == nblock
rest(window);
nblock = nblock + prefs.trials_per_block;
elseif trialIndex == 20 % first 20 trials are practice trials
practice(window);
end
% =========================================================================
end %end trials
% =========================================================================
%% Preliminary analysis of results.
%errors
data.errorDegrees = (180/pi) .* (angle(exp(1i*data.reportedOrientRads)./exp(1i*data.presentedOrientRads)));
data.errorRads = deg2rad(data.errorDegrees);
data.error_differenceRads = data.reportedOrientRads - data.presentedOrientRads;
data.error_differenceDegrees = data.reportedOrientDegrees - data.presentedOrientDegrees;
%lags
prefs.all_lags = all_lags;
%cues
data.position = position;
data.valid = valid;
save(Filename, 'data', 'prefs');
postpareEnvironment;
% =========================================================================
% =========================================================================
catch
postpareEnvironment;
psychrethrow(psychlasterror);
end % end try/catch
% =========================================================================
% =========================================================================
end % end whole script
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% #########################################################################
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% =========================================================================
% -------------------------------------------------------------------------
% #########################################################################
% #########################################################################
% -------------------------------------------------------------------------
% =========================================================================
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% #########################################################################
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function prepareEnvironment
ccc
HideCursor; % Comment out when debugging
commandwindow; % Select the command window to avoid typing in open scripts
% Seed the random number generator.
% RandStream.setDefaultStream(RandStream('mt19937ar', 'seed', sum(100*clock)));
RandStream.setGlobalStream(RandStream('mt19937ar', 'seed', sum(100*clock)));
% ListenChar(2); % Don't print to MATLAB command window
Screen('Preference', 'SkipSyncTests', 1); %choose 1 for test on an LCD
% /////////////////////////////////////////////////////////////////////////
%% Set up parallel port (for when triggers are sent with Vpixx2Vamp)
%initialize the inpoutx64 low-level I/O driver
config_io;
%optional step: verify that the inpoutx64 driver was successfully installed
global cogent;
if( cogent.io.status ~= 0 )
error('inp/outp installation failed');
end
%write a value to the default LPT1 printer output port (at 0x378)
address_eeg = hex2dec('B010');
outp(address_eeg,0); %set pins to zero
% /////////////////////////////////////////////////////////////////////////
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
%% End of experiment
function postpareEnvironment
ShowCursor;
% ListenChar(0);
Screen('CloseAll');
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
%% Orientation wheel task instructions
function instruct(window,prefs)
%Screen 1
% prefs = getPreferences();
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'The next few screens will briefly explain the task.',(window.centerX-400),(window.centerY+20), 255);
Screen('DrawText', window.onScreen, 'After the instructions, you will perform several practice trials followed by the experiment.',...
(window.centerX-400),(window.centerY+50), 255); %line every +30
Screen('DrawText', window.onScreen, 'On each screen click the mouse to continue.',(window.centerX-400),(window.centerY+80), 255); %line every +25
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 2
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'A fixation dot will appear. Please remain focused on the white central dot during the ENTIRE task.',...
(window.centerX-600),(window.centerY+50), 255);
Screen('DrawDots', window.onScreen, [window.centerX, window.centerY], prefs.fixationSize, 255); %255 is text color (white)
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 2.2
Screen('TextSize', window.onScreen, window.fontsize);
% CueL = createCueL(window,prefs); %create offscreen window with cue
CueR = createCueR(window); %create offscreen window with cue
Screen('DrawTexture', window.onScreen, CueR, [], [], [], 0);
Screen('DrawText', window.onScreen, 'An arrow will then briefly appear.',...
(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'The arrow may be pointing right...',...
(window.centerX-400),(window.centerY+80), 255); %line every +30
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
%put stimulus and text on screen
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 2.3
Screen('TextSize', window.onScreen, window.fontsize);
CueL = createCueL(window); %create offscreen window with cue
% CueR = createCueR(window,prefs); %create offscreen window with cue
Screen('DrawTexture', window.onScreen, CueL, [], [], [], 0);
Screen('DrawText', window.onScreen, 'Or, the arrow may be pointing left',...
(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'The arrow indicates the side a target stimulus will most likely appear.',...
(window.centerX-400),(window.centerY+80), 255); %line every +30
Screen('DrawText', window.onScreen, 'While keeping your eyes focused on the center,',...
(window.centerX-400),(window.centerY+110), 255); %line every +30
Screen('DrawText', window.onScreen, 'pay attention COVERTLY (without moving your eyes) to the circle on the side the arrow is pointing.',...
(window.centerX-400),(window.centerY+140), 255); %line every +30
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
%put stimulus and text on screen
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 2.4
Screen('TextSize', window.onScreen, window.fontsize);
CueN = createCueN(window); %create offscreen window with non-informative cue
Screen('DrawTexture', window.onScreen, CueN, [], [], [], 0);
Screen('DrawText', window.onScreen, 'Sometimes the arrow will be pointing both left and right.',...
(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'This means the target stimulus can appear to either the left OR right.',...
(window.centerX-400),(window.centerY+80), 255); %line every +30
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
%put stimulus and text on screen
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 3
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'The arrow will disappear and a target pointing in a certain direction will briefly appear inside the circle on the left OR right.',...
(window.centerX-600),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'Your task is to try to detect which direction the target is pointing.',...
(window.centerX-400),(window.centerY+80), 255); %line every +30
Screen('DrawText', window.onScreen, 'It might be difficult to see the target, but still try your best.',...
(window.centerX-400),(window.centerY+110), 255); %line every +30
%---draw target stimulus---
xCoords = [15 1.73 15 -1.73 15 0];
yCoords = [-25.98 1 -25.98 -1 -25.98 0];
allCoords_targ = [xCoords; yCoords];
%right target
Screen('DrawLines', window.onScreen, allCoords_targ, prefs.lineWidthPix, prefs.mask_gray, [window.centerXR window.centerY], 2);
centeredRectresp = CenterRectOnPointd([0,0,10,10], window.centerXR, window.centerY); %location of center for oval
Screen('FillOval', window.onScreen, prefs.mask_gray, centeredRectresp');
%left target
Screen('DrawLines', window.onScreen, allCoords_targ, prefs.lineWidthPix, prefs.mask_gray, [window.centerXL window.centerY], 2);
centeredRectresp = CenterRectOnPointd([0,0,10,10], window.centerXL, window.centerY); %location of center for oval
Screen('FillOval', window.onScreen, prefs.mask_gray, centeredRectresp');
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
%put stimulus and text on screen
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 4
Screen('TextSize', window.onScreen, window.fontsize);
maskwin = createMasktex(window,prefs); %create offscreen window with mask
Screen('DrawTexture', window.onScreen, maskwin, [], [], [], 0);
Screen('DrawText', window.onScreen, 'A star-like shape will then quickly appear and then disappear.',...
(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'Remember that you want to detect the direction of the target, not the star.',...
(window.centerX-400),(window.centerY+80), 255); %line every +30
%place holder
placeRect = createPlaceHolder(window,prefs);
Screen('FrameOval', window.onScreen, prefs.mask_gray, placeRect);
Screen('FillRect',window.onScreen,Vpixx2Vamp(0),prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 5
%draw target stimulus
xCoords = [-21.21 -1.41 -21.21 1.41 -21.21 0];
yCoords = [21.21 -1.41 21.21 1.41 21.21 0];
allCoords_targ = [xCoords; yCoords];
Screen('DrawLines', window.onScreen, allCoords_targ, prefs.lineWidthPix, prefs.mask_gray, [window.centerX window.centerY], 2);
centeredRectresp = CenterRectOnPointd([0,0,10,10], window.centerX, window.centerY);
Screen('FillOval', window.onScreen, prefs.mask_gray, centeredRectresp');
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'Another target will then appear on screen.',(window.centerX-880),(window.centerY-50), 255);
Screen('DrawText', window.onScreen, 'Using the mouse, move the new target until',(window.centerX-880),(window.centerY), 255);
Screen('DrawText', window.onScreen, 'it is pointing in the exact same direction',(window.centerX-880),(window.centerY+30), 255);
Screen('DrawText', window.onScreen, 'of the original target that appeared in the circle.',(window.centerX-880),(window.centerY+60), 255);
Screen('DrawText', window.onScreen, 'If you are unsure of the direction of the target,',(window.centerX-880),(window.centerY+110), 255);
Screen('DrawText', window.onScreen, 'or if you did not see a target, please provide',(window.centerX-880),(window.centerY+140), 255);
Screen('DrawText', window.onScreen, 'your best guess.',(window.centerX-880),(window.centerY+170), 255);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
%Screen 6
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'You will now complete several practice trials so that you become more familiar with the task.',(window.centerX-400),(window.centerY+20), 255);
Screen('DrawText', window.onScreen, 'Remember to remain focused and fixated on the white central dot that will appear.',(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'Click the left mouse button when you are ready to begin the practice trials.',(window.centerX-400),(window.centerY+80), 255);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function pause(window)
prefs = getPreferences();
Screen('FillRect', window.onScreen, window.gray);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
WaitSecs(0.5);
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function practice(window)
prefs = getPreferences();
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'You have now finished the set of practice trials.',(window.centerX-400),(window.centerY+20), 255);
Screen('DrawText', window.onScreen, 'Please let the experimenter know by using the call box.',(window.centerX-400),(window.centerY+50), 255);
Screen('DrawText', window.onScreen, 'Do NOT begin the experiment.',(window.centerX-400),(window.centerY+80), 255);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function rest(window)
prefs = getPreferences();
tot_blcks = prefs.nBlocks;
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'Feel free to take a break at this time. Click the mouse when you are ready to continue.',...
(window.centerX-400),(window.centerY+20), 255);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function finish(window)
prefs = getPreferences();
Screen('TextSize', window.onScreen, window.fontsize);
Screen('DrawText', window.onScreen, 'You are now finished the experiment. Thank you for your time.',...
(window.centerX-400),(window.centerY+20), 255);
Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
Screen('Flip', window.onScreen);
GetClicks(window.onScreen);
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
% function drawFixation(window, fixationX, fixationY, fixationSize)
% prefs = getPreferences();
% Screen('DrawDots', window.onScreen, [fixationX, fixationY], fixationSize, 255);
% Screen('FillRect',window.onScreen, Vpixx2Vamp(0), prefs.trigger_size);
% end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function offsets = circularArrayOffsets(n, centerX, centerY, radius, rotation)
degreeStep = 360/n;
offsets = [sind(0:degreeStep:(360-degreeStep) + rotation)'.* radius, ...
cosd(0:degreeStep:(360-degreeStep) + rotation)'.* radius];
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
function rects = circularArrayRects(rect, nItems, radius, centerX, centerY)
coor = circularArrayOffsets(nItems, centerX, centerY, radius, 0) + repmat([centerX centerY], nItems, 1);
rects = [coor(:, 1)-rect(3)/2 , coor(:, 2)-rect(3)/2, coor(:, 1)+rect(3)/2, coor(:, 2)+rect(3)/2];
end
% -------------------------------------------------------------------------
% #########################################################################
% -------------------------------------------------------------------------
%% ~~~ Open the main window and get dimensions ~~~
function window = openWindow()
window.screenNumber = max(Screen('Screens'));
window.onScreen = Screen('OpenWindow', window.screenNumber, [127.5 127.5 127.5]);
Screen('BlendFunction', window.onScreen, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
[window.screenX, window.screenY] = Screen('WindowSize', window.onScreen); % check resolution
window.screenRect = [0, 0, window.screenX, window.screenY]; % screen rect
window.centerX = window.screenX * 0.5; % center of screen in X direction
window.centerY = window.screenY * 0.5; % center of screen in Y direction
window.centerXL = floor(mean([0, window.centerX])); % center of left half of screen in X direction
window.centerXR = floor(mean([window.centerX, window.screenX])); % center of right half of screen in X direction
% targets need to be closer to the center (~6.3 degrees of arc)
window.centerXL = floor(mean([window.centerXL, window.centerX])); % center of the center left half of screen in X direction
window.centerXR = floor(mean([window.centerXR, window.centerX])); % center of the center right half of screen in X direction
% Basic drawing and screen variables.
window.black = BlackIndex(window.onScreen); % RGB value = 0
window.white = WhiteIndex(window.onScreen); % RGB value = 255
window.gray = mean([window.black window.white]); % RGB value = 127.5
window.fontsize = 26; % size of instruction text
window.bgcolor = window.gray; % set background color