jalauer commited on
Commit
e7dce60
·
verified ·
1 Parent(s): 69ebf88

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -57,3 +57,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ data/CC_EEG_s180_N.mat filter=lfs diff=lfs merge=lfs -text
61
+ data/Not_used/CC_EEG_s118_P.mat filter=lfs diff=lfs merge=lfs -text
62
+ data/CC_EEG_s105_P.mat filter=lfs diff=lfs merge=lfs -text
63
+ data/CC_EEG_s103_P.mat filter=lfs diff=lfs merge=lfs -text
64
+ data/CC_EEG_s104_P.mat filter=lfs diff=lfs merge=lfs -text
65
+ data/CC_EEG_s107_P.mat filter=lfs diff=lfs merge=lfs -text
66
+ data/CC_EEG_s102_P.mat filter=lfs diff=lfs merge=lfs -text
data/CC_Beh_s143_P.mat ADDED
Binary file (4.18 kB). View file
 
data/CC_Beh_s146_P.mat ADDED
Binary file (4.34 kB). View file
 
data/CC_Beh_s147_P.mat ADDED
Binary file (4.18 kB). View file
 
data/CC_Beh_s148_P.mat ADDED
Binary file (3.98 kB). View file
 
data/CC_Beh_s149_N.mat ADDED
Binary file (4 kB). View file
 
data/CC_Beh_s150_N.mat ADDED
Binary file (5.5 kB). View file
 
data/CC_Beh_s151_N.mat ADDED
Binary file (4.57 kB). View file
 
data/CC_Beh_s152_N.mat ADDED
Binary file (4.82 kB). View file
 
data/CC_Beh_s153_N.mat ADDED
Binary file (4.16 kB). View file
 
data/CC_Beh_s154_N.mat ADDED
Binary file (4.2 kB). View file
 
data/CC_Beh_s155_N.mat ADDED
Binary file (4.25 kB). View file
 
data/CC_Beh_s156_N.mat ADDED
Binary file (3.87 kB). View file
 
data/CC_Beh_s157_N.mat ADDED
Binary file (4.47 kB). View file
 
data/CC_Beh_s158_N.mat ADDED
Binary file (5.06 kB). View file
 
data/CC_Beh_s159_N.mat ADDED
Binary file (3.84 kB). View file
 
data/CC_Beh_s160_N.mat ADDED
Binary file (4.15 kB). View file
 
data/CC_Beh_s161_N.mat ADDED
Binary file (4.17 kB). View file
 
data/CC_Beh_s162_N.mat ADDED
Binary file (4.29 kB). View file
 
data/CC_Beh_s163_N.mat ADDED
Binary file (4.48 kB). View file
 
data/CC_Beh_s164_N.mat ADDED
Binary file (4.64 kB). View file
 
data/CC_Beh_s165_N.mat ADDED
Binary file (4.43 kB). View file
 
data/CC_Beh_s166_N.mat ADDED
Binary file (4.69 kB). View file
 
data/CC_Beh_s167_N.mat ADDED
Binary file (4.28 kB). View file
 
data/CC_Beh_s168_N.mat ADDED
Binary file (4.17 kB). View file
 
data/CC_Beh_s169_N.mat ADDED
Binary file (4.57 kB). View file
 
data/CC_Beh_s170_N.mat ADDED
Binary file (4.37 kB). View file
 
data/CC_Beh_s171_N.mat ADDED
Binary file (4.24 kB). View file
 
data/CC_Beh_s172_N.mat ADDED
Binary file (4.33 kB). View file
 
data/CC_Beh_s173_N.mat ADDED
Binary file (4.99 kB). View file
 
data/CC_Beh_s174_N.mat ADDED
Binary file (4.53 kB). View file
 
data/CC_Beh_s175_N.mat ADDED
Binary file (4.11 kB). View file
 
data/CC_Beh_s176_N.mat ADDED
Binary file (4.1 kB). View file
 
data/CC_Beh_s177_N.mat ADDED
Binary file (4.66 kB). View file
 
data/CC_Beh_s178_N.mat ADDED
Binary file (3.9 kB). View file
 
data/CC_Beh_s179_N.mat ADDED
Binary file (4.15 kB). View file
 
data/CC_Beh_s180_N.mat ADDED
Binary file (4.49 kB). View file
 
data/CC_Beh_s181_P.mat ADDED
Binary file (4.84 kB). View file
 
data/CC_EEG_s102_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab9d165f12c4d98add9ea7fd6f8e4e78e2fb493459ba7747e29a8cbf3ff3cc1f
3
+ size 339797736
data/CC_EEG_s103_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c4119aa3923e2fee0620801480ac69dc58adfef87dfabcbf61ec0aa0017bead
3
+ size 315133216
data/CC_EEG_s104_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf421e383489f0c6106dfc341400225dc151a09a8ac8670d85baa11dc7a56b70
3
+ size 346190084
data/CC_EEG_s105_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d65b848cf96ed6b42546f234cec00c80ecb400a26941c6438e1ee1e6a2be2354
3
+ size 318726903
data/CC_EEG_s107_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:666516575883767acc8625eb13fb6930d1687c9272c0a720bff080a32d0bd9d0
3
+ size 354101980
data/CC_EEG_s180_N.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23d3630a5e78ca52a729c67d187079c8959e3d924d69dbf0e8b45546cf891c3e
3
+ size 357866376
data/Not_used/CC_EEG_s118_P.mat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4605434bc172f48c3e4ab9a24a56380fc4f1f9fa2a920acc793cef62a05d1b33
3
+ size 385206892
scripts/Instructions.m ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %Experimenter instructions
2
+ Screen('TextSize',wPtr,70);
3
+ Screen('TextFont',wPtr,'Times');
4
+ Screen('TextStyle',wPtr,0);
5
+ Screen('TextColor',wPtr,[255 255 255]);
6
+ beginningText1 = 'Experimenter: [SPACE] to Continue';
7
+ DrawFormattedText(wPtr,beginningText1,'center','center');
8
+ Screen(wPtr, 'Flip');
9
+ KbWait([],3); %Waits for keyboard(any) press
10
+
11
+ % %****BEGINNING OF INSTRUCTIONS****
12
+ % %Instructions 1
13
+ Screen('TextSize',wPtr,50);
14
+ Screen('TextFont',wPtr,'Times');
15
+ Screen('TextStyle',wPtr,0);
16
+ Screen('TextColor',wPtr,[255 255 255]);
17
+ instructionText1 = 'Welcome and thank you for participating in our study. \n\n\nPlease use the spacebar to move through the instructions.';
18
+ DrawFormattedText(wPtr,instructionText1,'center','center');
19
+ Screen(wPtr, 'Flip');
20
+ KbWait([],3); %Waits for keyboard(any) press
21
+
22
+ repeat = 1;
23
+ while repeat == 1
24
+
25
+ %Instructions 2
26
+ instructionText2 = 'In the task that follows, \n\n\nA picture will appear on the LEFT or RIGHT of the screen. \n\n\nIf the picture is YELLOW, press the LEFT button.\n\n\nIf the picture is BLUE, press the RIGHT button.';
27
+ DrawFormattedText(wPtr,instructionText2,'center','center')
28
+ Screen(wPtr, 'Flip');
29
+
30
+ KbWait([],3); %Waits for keyboard(any) press
31
+
32
+ %Instruction 3
33
+ instructionText3 = 'Lets try a quick practice session... \n\n\nTry to respond as accurately as possible within the time limit.';
34
+ DrawFormattedText(wPtr,instructionText3,'center','center')
35
+ Screen(wPtr, 'Flip');
36
+
37
+ KbWait([],3); %Waits for keyboard(any)
38
+
39
+ % ####################### Do Pre-Practice
40
+ PrePractice
41
+ Screen('TextSize',wPtr,50);
42
+ Screen('TextFont',wPtr,'Times');
43
+ Screen('TextStyle',wPtr,0);
44
+ Screen('TextColor',wPtr,[255 255 255]);
45
+
46
+ %Instruction 4
47
+ instructionText4 = 'Great! \n\n\nYou noticed that it is hard when the YELLOW picture \n\n\nis on the RIGHT side of the screen, for example. \n\n\nTricky! \n\n\nBut there is one more thing to know...';
48
+ DrawFormattedText(wPtr,instructionText4,'center','center')
49
+ Screen(wPtr, 'Flip');
50
+
51
+ KbWait([],3); %Waits for keyboard(any) press
52
+
53
+ %%%
54
+ instructionTextR1 = 'But before that \n\n\nWould you like to practice that again? \n\n\nPress [r] to repeat that practice \n\n\n Or press [SPACE] to continue';
55
+ DrawFormattedText(wPtr,instructionTextR1,'center','center')
56
+ Screen(wPtr, 'Flip');
57
+
58
+ [secs, keyCode, deltaSecs] = KbWait([],3);
59
+
60
+ repeat = find(keyCode) == 21;
61
+ end
62
+
63
+ repeat = 1;
64
+ while repeat == 1
65
+ %Instruction 5
66
+ instructionText5 = 'You will get rewards (+1) or not (0) after answering correctly. \n\n\n But you will LOSE points (-3) for errors and no-responses';
67
+ DrawFormattedText(wPtr,instructionText5,'center','center')
68
+ Screen(wPtr, 'Flip');
69
+
70
+ KbWait([],3); %Waits for keyboard(any) press
71
+
72
+ %Instruction 6
73
+ instructionText6 = 'Some pictures will be rewarding MORE OFTEN than others. \n\n\nTry to score as many points as possible. \n\n\nYou will be TESTED on the pictures after each block. ';
74
+ DrawFormattedText(wPtr,instructionText6,'center','center')
75
+ Screen(wPtr, 'Flip');
76
+
77
+ KbWait([],3); %Waits for keyboard(any) press
78
+
79
+ %Instruction 7
80
+ instructionText7 = 'Lets try that practice again, \n\n\nbut with REWARDS (+1)';
81
+ DrawFormattedText(wPtr,instructionText7,'center','center')
82
+ Screen(wPtr, 'Flip');
83
+
84
+ KbWait([],3); %Waits for keyboard(any) press
85
+
86
+ % ####################### Do Practice
87
+ Practice
88
+ Screen('TextSize',wPtr,50);
89
+ Screen('TextFont',wPtr,'Times');
90
+ Screen('TextStyle',wPtr,0);
91
+ Screen('TextColor',wPtr,[255 255 255]);
92
+
93
+ %Instruction 8
94
+ instructionText8 = 'Here is a practice TEST phase. \n\n\nDuring this phase you will see two black & white pictures side-by-side.\n\n\nThere is no feedback, \n\n\nyou simply have to select the better picture.';
95
+ DrawFormattedText(wPtr,instructionText8,'center','center')
96
+ Screen(wPtr, 'Flip');
97
+
98
+ KbWait([],3); %Waits for keyboard(any) press
99
+
100
+ %Instruction 8b
101
+ instructionText8b = 'For example, in that practice STARS were more rewarding \n\n\nthan SQUARES.';
102
+ DrawFormattedText(wPtr,instructionText8b,'center','center')
103
+ Screen(wPtr, 'Flip');
104
+
105
+ KbWait([],3); %Waits for keyboard(any) press
106
+
107
+
108
+ %Instruction 8b2
109
+ instructionText8b2 = 'Just select the BETTER picture out of the two. \n\n\n Remember, you will not receive feedback.\n\n\n GO WITH YOUR GUT INSTINCT!';
110
+ DrawFormattedText(wPtr,instructionText8b2,'center','center')
111
+ Screen(wPtr, 'Flip');
112
+
113
+ KbWait([],3); %Waits for keyboard(any) press
114
+
115
+
116
+ % ####################### Do Practice
117
+ Practice_test
118
+ Screen('TextSize',wPtr,50);
119
+ Screen('TextFont',wPtr,'Times');
120
+ Screen('TextStyle',wPtr,0);
121
+ Screen('TextColor',wPtr,[255 255 255]);
122
+
123
+ %Instruction 8b2
124
+ instructionText8b2 = 'There are some important things to remember: \n\n\n\n 1) The color of the picture does not affect the reward \n\n 2) Nor does the side of the screen the picture is on. \n\n 3) The only thing that matters is remembering \n\n which picture was more rewarding';
125
+ DrawFormattedText(wPtr,instructionText8b2,'center','center')
126
+ Screen(wPtr, 'Flip');
127
+ KbWait([],3); %Waits for keyboard(any) press
128
+
129
+ instructionText8b2 = 'There are some important things to remember: \n\n\n\n 4) Many pictures will only be rewarded a certain \n\n percent of the time. \n\n\n This can be hard - so try your hardest to observe each shape!';
130
+ DrawFormattedText(wPtr,instructionText8b2,'center','center')
131
+ Screen(wPtr, 'Flip');
132
+ KbWait([],3); %Waits for keyboard(any) press
133
+
134
+ %%%
135
+ instructionTextR2 = 'Great! Do you have any questions? \n\n Or would you like to practice that again? \n\n\nPress [r] to repeat that practice \n\n\n Or press [SPACE] to continue';
136
+ DrawFormattedText(wPtr,instructionTextR2,'center','center')
137
+ Screen(wPtr, 'Flip');
138
+
139
+ [secs, keyCode, deltaSecs] = KbWait([],3);
140
+
141
+ repeat = find(keyCode) == 21;
142
+ end
143
+
144
+
145
+ %Instruction 9
146
+ instructionText9 = 'Are you ready for the first block? \n\n (There are 4 train/test blocks total) \n\n\n - Experimenter, please press [P] to continue - ';
147
+ DrawFormattedText(wPtr,instructionText9,'center','center')
148
+ Screen(wPtr, 'Flip');
149
+
150
+ % wait for a response (should be for 6 seconds)
151
+ [keyIsDown, RT, keyCode] = KbCheck();
152
+ while true
153
+ if keyIsDown && keyCode(KbName('P'))
154
+ break;
155
+ end % if next key detected
156
+ [keyIsDown, RT, keyCode] = KbCheck();
157
+ end % endless loop
158
+
159
+
160
+ % KbWait([],3); %Waits for keyboard(any) press
161
+
162
+ %****END OF INSTRUCTIONS****
scripts/Practice.m ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %*****PRACTICE STIM SETUP****
2
+
3
+ % the number of trials of each stim pairing
4
+ practrials_perType = 2;
5
+
6
+
7
+ % build the practice trial list
8
+ Ayi_trials = repmat([ A,y,i ], practrials_perType, 1);
9
+ Ayc_trials = repmat([ A,y,c ], practrials_perType, 1);
10
+ Abi_trials = repmat([ A,b,i ], practrials_perType, 1);
11
+ Abc_trials = repmat([ A,b,c ], practrials_perType, 1);
12
+ Byi_trials = repmat([ B,y,i ], practrials_perType, 1);
13
+ Byc_trials = repmat([ B,y,c ], practrials_perType, 1);
14
+ Bbi_trials = repmat([ B,b,i ], practrials_perType, 1);
15
+ Bbc_trials = repmat([ B,b,c ], practrials_perType, 1);
16
+
17
+ % bind all the trial types to define the block's trials
18
+ practice_trialList = [Ayi_trials; Ayc_trials; Abi_trials; Abc_trials; Byi_trials; Byc_trials; Bbi_trials; Bbc_trials];
19
+
20
+ % read in the images and create the required textures: {A,B}{y,b}
21
+ prac_images = [];
22
+ prac_images{1}{1} = imread('./images/1_Y.bmp');
23
+ prac_images{1}{2} = imread('./images/1_B.bmp');
24
+ prac_images{1}{3} = imread('./images/1_1.bmp');
25
+ prac_images{1}{4} = imread('./images/1_0.bmp');
26
+ prac_images{1}{5} = imread('./images/1.bmp');
27
+ prac_images{2}{1} = imread('./images/2_Y.bmp');
28
+ prac_images{2}{2} = imread('./images/2_B.bmp');
29
+ prac_images{2}{3} = imread('./images/2_1.bmp');
30
+ prac_images{2}{4} = imread('./images/2_0.bmp');
31
+ prac_images{2}{5} = imread('./images/2.bmp');
32
+
33
+ % % % randomize the images - No keep them known for practice.
34
+ % % randx_i=randperm(size(prac_images,2));
35
+ % % count=1;
36
+ % % for randx=1:size(prac_images)
37
+ % % prac_images{count} = prac_images{randx_i(randx)};
38
+ % % count=count+1;
39
+ % % end
40
+
41
+ % load all the textures
42
+ prac_textures = [];
43
+ for pracTexture_index = 1 : size(prac_images, 2) % Number of stims
44
+ for color_index = 1 : size(prac_images{pracTexture_index}, 2) %1=Y, 2=B, 3=1, 4=0, 5=k
45
+ prac_textures{pracTexture_index}{color_index} = Screen('MakeTexture', wPtr, prac_images{pracTexture_index}{color_index});
46
+ end
47
+ end
48
+
49
+ % load the textures into an array mapping onto corresponding choice ids
50
+ textures = [];
51
+ textures(A,y,i) = prac_textures{1}{1}; % {A,B}{y,b}
52
+ textures(A,y,c) = prac_textures{1}{1};
53
+ textures(A,b,i) = prac_textures{1}{2};
54
+ textures(A,b,c) = prac_textures{1}{2};
55
+ textures(B,y,i) = prac_textures{2}{1};
56
+ textures(B,y,c) = prac_textures{2}{1};
57
+ textures(B,b,i) = prac_textures{2}{2};
58
+ textures(B,b,c) = prac_textures{2}{2};
59
+
60
+ FBtextures(A,1) = prac_textures{1}{3}; % {A,B}{rew,norew}
61
+ FBtextures(A,2) = prac_textures{1}{4};
62
+ FBtextures(B,1) = prac_textures{2}{3};
63
+ FBtextures(B,2) = prac_textures{2}{4};
64
+
65
+ % define the practice stim reward contingencies - equal for c or i in practice
66
+ prac_contingencies = [];
67
+ prac_contingencies(A,y,i) = 0.9;
68
+ prac_contingencies(A,y,c) = 0.9;
69
+ prac_contingencies(A,b,i) = 0.9;
70
+ prac_contingencies(A,b,c) = 0.9;
71
+ prac_contingencies(B,y,i) = 0.1;
72
+ prac_contingencies(B,y,c) = 0.1;
73
+ prac_contingencies(B,b,i) = 0.1;
74
+ prac_contingencies(B,b,c) = 0.1;
75
+
76
+ %****BEGIN PRACTICE*****
77
+
78
+ practiceComplete = false;
79
+ numPracticeBlocks = 1; %*******Determines # of Blocks*******
80
+ pracblock_index = 0;
81
+ no_response = false;
82
+
83
+ % loop through the pracitce phase
84
+ while ~practiceComplete
85
+
86
+ % track trial ids
87
+ trial_ids = [];
88
+ % track trial type
89
+ trial_stimuli = [];
90
+ %track response
91
+ trial_response = [];
92
+ % track which stim was choosen
93
+ trial_selectedStim = [];
94
+ % track the rt
95
+ trial_RT = [];
96
+ % track the accuracy
97
+ trial_accuracy = [];
98
+ % track the feedback
99
+ trial_feedback = [];
100
+
101
+ % increment the block index
102
+ pracblock_index = pracblock_index + 1;
103
+
104
+ random_index = randperm(size(practice_trialList, 1));
105
+ randomized_trialList = practice_trialList(random_index,:);
106
+
107
+ trial_index = 1;
108
+ while trial_index <= size(randomized_trialList, 1)
109
+
110
+ % Fixation
111
+ fixation_text = '+';
112
+ Screen('TextFont',wPtr,'Times');
113
+ Screen('TextStyle',wPtr,0);
114
+ Screen('TextColor',wPtr,[255 255 255]);
115
+ Screen('TextSize',wPtr,80);
116
+ DrawFormattedText(wPtr,fixation_text,'center','center');
117
+ Screen(wPtr, 'Flip');
118
+ % show the fixation for 1 sec
119
+ WaitSecs(1);
120
+
121
+ % get the current trial's info
122
+ type = randomized_trialList(trial_index, 1);
123
+ color = randomized_trialList(trial_index, 2);
124
+ congru = randomized_trialList(trial_index, 3);
125
+
126
+ % NetStation('Event',trial_pair,EventTime+offset - (1.81e-05)*(EventTime -
127
+ % Synchtime)););
128
+
129
+ % define the correct choice
130
+ if color==1
131
+ correct_choice = left_button;
132
+ elseif color==2
133
+ correct_choice = right_button;
134
+ end
135
+ % define the window side based on congruency
136
+ if color==1 && congru==1 %(yellow-congruent==left)
137
+ rect = left_rect;
138
+ elseif color==1 && congru==2 %(yellow-incongruent==right)
139
+ rect = right_rect;
140
+ elseif color==2 && congru==1 %(blue-congruent==right)
141
+ rect = right_rect;
142
+ elseif color==2 && congru==2 %(blue-incongruent==left)
143
+ rect = left_rect;
144
+ end
145
+
146
+ % now draw the stim
147
+ Screen('DrawTexture', wPtr, textures(type,color,congru), [], rect);
148
+ Screen(wPtr, 'Flip');
149
+
150
+ % start the trial timer;
151
+ startTime = GetSecs();
152
+
153
+ wait_stamp=GetSecs;
154
+ while 1
155
+ % [a ab] = JoyMEX(0);
156
+ [ keyIsDown, seconds, keyCode ] = KbCheck(GPindx);
157
+ if keyIsDown
158
+ %if keyCode(left_key) && left_key==correct_choice
159
+ if keyCode(left_button) && left_button==correct_choice
160
+ subject_choice = left_button;
161
+ no_response = false;
162
+ trlResponse = 1;
163
+ trlAccuracy = 1;
164
+ break;
165
+ %elseif keyCode(right_key) && right_key==correct_choice
166
+ elseif keyCode(right_button) && right_button==correct_choice
167
+ subject_choice = right_button;
168
+ no_response = false;
169
+ trlResponse = 1;
170
+ trlAccuracy = 1;
171
+ break;
172
+ %elseif keyCode(left_key) && left_key~=correct_choice % ERROR!
173
+ elseif keyCode(left_button) && left_button~=correct_choice % ERROR!
174
+ subject_choice = left_button;
175
+ no_response = false;
176
+ trlResponse = 1;
177
+ trlAccuracy = 0;
178
+ break;
179
+ %elseif keyCode(right_key) && right_key~=correct_choice % ERROR!
180
+ elseif keyCode(right_button) && right_button~=correct_choice % ERROR!
181
+ subject_choice = right_button;
182
+ no_response = false;
183
+ trlResponse = 1;
184
+ trlAccuracy = 0;
185
+ break;
186
+ end
187
+ elseif(GetSecs-wait_stamp) > PREPRACT_RESPDEADLINE,
188
+ subject_choice = no_response;
189
+ no_response = true;
190
+ trlResponse = -1;
191
+ trlAccuracy = -1;
192
+ break;
193
+ end
194
+ end
195
+
196
+ % stop the trial timer
197
+ RT = GetSecs() - startTime;
198
+
199
+ % determine if they selected the right or left stim
200
+ if subject_choice == correct_choice
201
+ trlselectedStim = 1;
202
+ % get the selected stim's reward contingency
203
+ reward_contingency = prac_contingencies(type,color,congru);
204
+ else
205
+ trlselectedStim = 0;
206
+ end
207
+
208
+ % determine the reward feedback
209
+ Screen('TextSize',wPtr,70);
210
+ Screen('TextFont',wPtr,'Times');
211
+ Screen('TextStyle',wPtr,1);
212
+ if no_response == true
213
+ Screen('TextColor',wPtr,[255 0 0]);
214
+ reward_text = 'No Response. -3';
215
+ trlFeedback = -3;
216
+ % NetStation('Event', '115',EventTime+offset - (1.81e-05)*(EventTime -
217
+ % Synchtime)););
218
+ elseif no_response == false
219
+ if trlAccuracy == 0
220
+ Screen('TextColor',wPtr,[255 0 0]);
221
+ reward_text = 'ERROR! -3';
222
+ trlFeedback = -3;
223
+ % NetStation('Event', '95',EventTime+offset - (1.81e-05)*(EventTime -
224
+ % Synchtime)););
225
+ else
226
+ if rand(1) < reward_contingency % REWARD
227
+ Screen('TextColor',wPtr,[0 255 0]);
228
+ % reward_text = '+1';
229
+ FB=FBtextures(type,1);
230
+ trlFeedback = 1;
231
+ % NetStation('Event', '95',EventTime+offset - (1.81e-05)*(EventTime -
232
+ % Synchtime)););
233
+ else
234
+ reward = 0; % NO REWARD
235
+ Screen('TextColor',wPtr,[0 0 255]);
236
+ %reward_text = '~~~';
237
+ FB=FBtextures(type,2);
238
+ trlFeedback = 0;
239
+ % NetStation('Event', '105',EventTime+offset - (1.81e-05)*(EventTime -
240
+ % Synchtime)););
241
+ end
242
+ end
243
+ end
244
+
245
+ % now show feedback based on response and stim contingencies
246
+ if trlAccuracy ~= 1
247
+ DrawFormattedText(wPtr,reward_text,'center','center');
248
+ Screen(wPtr, 'Flip');
249
+ elseif trlAccuracy == 1
250
+ Screen('DrawTexture', wPtr, FB, [], rect); %center_rect
251
+ Screen(wPtr, 'Flip');
252
+ end
253
+
254
+ % show the feedback for 1 sec
255
+ WaitSecs(1);
256
+
257
+ % Store the trial data
258
+ %
259
+ % update the trial number list
260
+ trial_ids = [trial_ids; trial_index];
261
+ % store the trial stimuli
262
+ trial_stimuli = [trial_stimuli; randomized_trialList(trial_index,:)];
263
+ %store response
264
+ trial_response = [trial_response; trlResponse];
265
+ % store the RT
266
+ trial_RT = [trial_RT; RT];
267
+ % store the subject's choice
268
+ trial_selectedStim = [trial_selectedStim; trlselectedStim];
269
+ % store accuracy independent of feedback
270
+ trial_accuracy = [trial_accuracy; trlAccuracy];
271
+ % store the feedback
272
+ trial_feedback = [trial_feedback; trlFeedback];
273
+
274
+ % increment the trial index
275
+ trial_index = trial_index + 1;
276
+
277
+ end
278
+
279
+ % check to see if practice is done
280
+ if pracblock_index >= numPracticeBlocks
281
+ practiceComplete = true;
282
+ end
283
+ end
284
+
285
+ % *****END OF PRACTICE*****
scripts/Practice_test.m ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %*****Block1 STIM SETUP****
2
+
3
+ % the number of trials of each stim pairing
4
+ B1trials_perType = 2;
5
+
6
+ % build the B1 trial list
7
+ AB_trials = repmat([ A,B ], B1trials_perType, 1);
8
+ BA_trials = repmat([ B,A ], B1trials_perType, 1);
9
+
10
+ % bind all the trial types to define the block's trials
11
+ B1_trialList = [AB_trials; BA_trials;];
12
+
13
+ % read in the images and create the required textures: {A,B}
14
+ B1_images = [];
15
+ B1_images{1} = imread('./images/1.bmp');
16
+ B1_images{2} = imread('./images/2.bmp');
17
+
18
+ % load all the textures
19
+ B1_textures = [];
20
+ for B1Texture_index = 1 : size(B1_images, 2) % Number of stims
21
+ B1_textures{B1Texture_index}= Screen('MakeTexture', wPtr, B1_images{B1Texture_index});
22
+ end
23
+
24
+ % load the textures into an array mapping onto corresponding choice ids
25
+ textures = [];
26
+ textures(A) = B1_textures{1}; % {A,B}
27
+ textures(B) = B1_textures{2};
28
+
29
+ %****BEGIN B1_test*****
30
+
31
+ B1Complete = false;
32
+ numB1Blocks = 1; %*******Determines # of Blocks*******
33
+ B1block_index = 0;
34
+ no_response = false;
35
+
36
+ % loop through the B1 phase
37
+ while ~B1Complete
38
+
39
+ % track trial ids
40
+ trial_ids = [];
41
+ % track trial type
42
+ trial_stimuli = [];
43
+ %track response
44
+ trial_response = [];
45
+ % track which stim was choosen
46
+ trial_selectedStim = [];
47
+ % track the rt
48
+ trial_RT = [];
49
+ % track the accuracy
50
+ trial_accuracy = [];
51
+
52
+ % increment the block index
53
+ B1block_index = B1block_index + 1;
54
+
55
+ % random_index = randperm(size(B1_trialList, 1));
56
+ randomized_trialList = B1_trialList([1,3,2,4],:); %(random_index,:);
57
+
58
+ trial_index = 1;
59
+ while trial_index <= size(randomized_trialList, 1)
60
+
61
+ % Fixation
62
+ fixation_text = '+';
63
+ Screen('TextFont',wPtr,'Times');
64
+ Screen('TextStyle',wPtr,0);
65
+ Screen('TextColor',wPtr,[255 255 255]);
66
+ Screen('TextSize',wPtr,80);
67
+ DrawFormattedText(wPtr,fixation_text,'center','center');
68
+ Screen(wPtr, 'Flip');
69
+ % show the fixation for 1 sec
70
+ WaitSecs(1);
71
+
72
+ % get the current trial's info
73
+ L = randomized_trialList(trial_index, 1);
74
+ R = randomized_trialList(trial_index, 2);
75
+
76
+ % NetStation('Event',trial_pair,EventTime+offset - (1.81e-05)*(EventTime -
77
+ % Synchtime)););
78
+
79
+ % define the correct choice
80
+ if L==1 || L==3 % A or C
81
+ correct_choice = left_button;
82
+ % correct_choice = up_key;
83
+ elseif L==2 || L==4 % B or D
84
+ correct_choice = right_button;
85
+ % correct_choice = down_key;
86
+ end
87
+
88
+ %rect=[left_rect_test',right_rect_test'];
89
+ %rect=[down_rect',up_rect']; % For some reason need to be reversed
90
+
91
+ % now draw the stim
92
+ Screen('DrawTexture', wPtr, textures(L), [], left_rect_test);
93
+ Screen('DrawTexture', wPtr, textures(R), [], right_rect_test);
94
+ Screen(wPtr, 'Flip');
95
+
96
+ % start the trial timer;
97
+ startTime = GetSecs();
98
+
99
+ wait_stamp=GetSecs;
100
+ % display "tmp"
101
+ while 1
102
+ % [a ab] = JoyMEX(0);
103
+ [ keyIsDown, seconds, keyCode ] = KbCheck(GPindx);
104
+ if keyIsDown
105
+ if keyCode(left_button) && left_button==correct_choice
106
+ subject_choice = left_button;
107
+ no_response = false;
108
+ trlResponse = 1;
109
+ trlAccuracy = 1;
110
+ break;
111
+ elseif keyCode(right_button) && right_button==correct_choice
112
+ subject_choice = right_button;
113
+ no_response = false;
114
+ trlResponse = 1;
115
+ trlAccuracy = 1;
116
+ break;
117
+ elseif keyCode(left_button) && left_button~=correct_choice % supoptimal
118
+ subject_choice = left_button;
119
+ no_response = false;
120
+ trlResponse = 1;
121
+ trlAccuracy = 0;
122
+ break;
123
+ elseif keyCode(right_button) && right_button~=correct_choice % supoptimal
124
+ subject_choice = right_button;
125
+ no_response = false;
126
+ trlResponse = 1;
127
+ trlAccuracy = 0;
128
+ break;
129
+ end
130
+ elseif(GetSecs-wait_stamp) > TSTDEADLINE,
131
+ subject_choice = 9999;
132
+ no_response = true;
133
+ trlResponse = -1;
134
+ trlAccuracy = -1;
135
+ break;
136
+ end
137
+ end
138
+
139
+ % stop the trial timer
140
+ RT = GetSecs() - startTime;
141
+
142
+ % determine if they selected the right or left stim
143
+ if subject_choice == correct_choice
144
+ trlselectedStim = 1;
145
+ else
146
+ trlselectedStim = 0;
147
+ end
148
+
149
+ % determine the reward feedback
150
+ Screen('TextSize',wPtr,70);
151
+ Screen('TextFont',wPtr,'Times');
152
+ Screen('TextStyle',wPtr,1);
153
+
154
+ % Store the trial data
155
+ %
156
+ % update the trial number list
157
+ trial_ids = [trial_ids; trial_index];
158
+ % store the trial stimuli
159
+ trial_stimuli = [trial_stimuli; randomized_trialList(trial_index,:)];
160
+ %store response
161
+ trial_response = [trial_response; trlResponse];
162
+ % store the RT
163
+ trial_RT = [trial_RT; RT];
164
+ % store the subject's choice
165
+ trial_selectedStim = [trial_selectedStim; trlselectedStim];
166
+ % store accuracy independent of feedback
167
+ trial_accuracy = [trial_accuracy; trlAccuracy];
168
+
169
+ % increment the trial index
170
+ trial_index = trial_index + 1;
171
+
172
+ end
173
+
174
+ % check to see if B1 is done
175
+ if B1block_index >= numB1Blocks
176
+ B1Complete = true;
177
+ end
178
+ end
179
+
180
+
181
+ % *****END OF B1_test*****
scripts/PrePractice.m ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %*****PRACTICE STIM SETUP****
2
+
3
+ % the number of trials of each stim pairing
4
+ practrials_perType = 2;
5
+
6
+
7
+ % build the practice trial list
8
+ Ayi_trials = repmat([ A,y,i ], practrials_perType, 1);
9
+ Ayc_trials = repmat([ A,y,c ], practrials_perType, 1);
10
+ Abi_trials = repmat([ A,b,i ], practrials_perType, 1);
11
+ Abc_trials = repmat([ A,b,c ], practrials_perType, 1);
12
+ Byi_trials = repmat([ B,y,i ], practrials_perType, 1);
13
+ Byc_trials = repmat([ B,y,c ], practrials_perType, 1);
14
+ Bbi_trials = repmat([ B,b,i ], practrials_perType, 1);
15
+ Bbc_trials = repmat([ B,b,c ], practrials_perType, 1);
16
+
17
+ % bind all the trial types to define the block's trials
18
+ practice_trialList = [Ayi_trials; Ayc_trials; Abi_trials; Abc_trials; Byi_trials; Byc_trials; Bbi_trials; Bbc_trials];
19
+
20
+ % read in the images and create the required textures: {A,B}{y,b}
21
+ prac_images = [];
22
+ prac_images{1}{1} = imread('./images/1_Y.bmp');
23
+ prac_images{1}{2} = imread('./images/1_B.bmp');
24
+ prac_images{1}{3} = imread('./images/1_1.bmp');
25
+ prac_images{1}{4} = imread('./images/1_0.bmp');
26
+ prac_images{1}{5} = imread('./images/1.bmp');
27
+ prac_images{2}{1} = imread('./images/2_Y.bmp');
28
+ prac_images{2}{2} = imread('./images/2_B.bmp');
29
+ prac_images{2}{3} = imread('./images/2_1.bmp');
30
+ prac_images{2}{4} = imread('./images/2_0.bmp');
31
+ prac_images{2}{5} = imread('./images/2.bmp');
32
+
33
+ % % % randomize the images - No keep them known for practice.
34
+ % % randx_i=randperm(size(prac_images,2));
35
+ % % count=1;
36
+ % % for randx=1:size(prac_images)
37
+ % % prac_images{count} = prac_images{randx_i(randx)};
38
+ % % count=count+1;
39
+ % % end
40
+
41
+ % load all the textures
42
+ prac_textures = [];
43
+ for pracTexture_index = 1 : size(prac_images, 2) % Number of stims
44
+ for color_index = 1 : size(prac_images{pracTexture_index}, 2) %1=Y, 2=B, 3=1, 4=0, 5=k
45
+ prac_textures{pracTexture_index}{color_index} = Screen('MakeTexture', wPtr, prac_images{pracTexture_index}{color_index});
46
+ end
47
+ end
48
+
49
+ % load the textures into an array mapping onto corresponding choice ids
50
+ textures = [];
51
+ textures(A,y,i) = prac_textures{1}{1}; % {A,B}{y,b}
52
+ textures(A,y,c) = prac_textures{1}{1};
53
+ textures(A,b,i) = prac_textures{1}{2};
54
+ textures(A,b,c) = prac_textures{1}{2};
55
+ textures(B,y,i) = prac_textures{2}{1};
56
+ textures(B,y,c) = prac_textures{2}{1};
57
+ textures(B,b,i) = prac_textures{2}{2};
58
+ textures(B,b,c) = prac_textures{2}{2};
59
+
60
+ FBtextures(A,1) = prac_textures{1}{3}; % {A,B}{rew,norew}
61
+ FBtextures(A,2) = prac_textures{1}{4};
62
+ FBtextures(B,1) = prac_textures{2}{3};
63
+ FBtextures(B,2) = prac_textures{2}{4};
64
+
65
+ %****BEGIN PRE-PRACTICE*****
66
+
67
+ practiceComplete = false;
68
+ numPracticeBlocks = 1; %*******Determines # of Blocks*******
69
+ pracblock_index = 0;
70
+ no_response = false;
71
+
72
+ % loop through the pracitce phase
73
+ while ~practiceComplete
74
+
75
+ % track trial ids
76
+ trial_ids = [];
77
+ % track trial type
78
+ trial_stimuli = [];
79
+ %track response
80
+ trial_response = [];
81
+ % track which stim was choosen
82
+ trial_selectedStim = [];
83
+ % track the rt
84
+ trial_RT = [];
85
+ % track the accuracy
86
+ trial_accuracy = [];
87
+ % track the feedback
88
+ trial_feedback = [];
89
+ no_response = [] ;
90
+
91
+ % increment the block index
92
+ pracblock_index = pracblock_index + 1;
93
+
94
+ random_index = randperm(size(practice_trialList, 1));
95
+ randomized_trialList = practice_trialList(random_index,:);
96
+
97
+ trial_index = 1;
98
+ while trial_index <= size(randomized_trialList, 1)
99
+
100
+ % Fixation
101
+ fixation_text = '+';
102
+ Screen('TextFont',wPtr,'Times');
103
+ Screen('TextStyle',wPtr,0);
104
+ Screen('TextColor',wPtr,[255 255 255]);
105
+ Screen('TextSize',wPtr,80);
106
+ DrawFormattedText(wPtr,fixation_text,'center','center');
107
+ Screen(wPtr, 'Flip');
108
+ % show the fixation for 1 sec
109
+ WaitSecs(1);
110
+
111
+ % get the current trial's info
112
+ type = randomized_trialList(trial_index, 1);
113
+ color = randomized_trialList(trial_index, 2);
114
+ congru = randomized_trialList(trial_index, 3);
115
+
116
+ % NetStation('Event',trial_pair,EventTime+offset - (1.81e-05)*(EventTime -
117
+ % Synchtime)););
118
+
119
+ % define the correct choice
120
+ if color==1
121
+ correct_choice = left_button;
122
+ elseif color==2
123
+ correct_choice = right_button;
124
+ end
125
+ % define the window side based on congruency
126
+ if color==1 && congru==1 %(yellow-congruent==left)
127
+ rect = left_rect;
128
+ elseif color==1 && congru==2 %(yellow-incongruent==right)
129
+ rect = right_rect;
130
+ elseif color==2 && congru==1 %(blue-congruent==right)
131
+ rect = right_rect;
132
+ elseif color==2 && congru==2 %(blue-incongruent==left)
133
+ rect = left_rect;
134
+ end
135
+
136
+ % now draw the stim
137
+ Screen('DrawTexture', wPtr, textures(type,color,congru), [], rect);
138
+ Screen(wPtr, 'Flip');
139
+
140
+ % start the trial timer;
141
+ startTime = GetSecs();
142
+
143
+ wait_stamp=GetSecs;
144
+ while 1
145
+ [ keyIsDown, seconds, keyCode ] = KbCheck(GPindx);
146
+ if keyIsDown
147
+ if keyCode(left_button) && left_button==correct_choice
148
+ subject_choice = left_button;
149
+ no_response = false;
150
+ trlResponse = 1;
151
+ trlAccuracy = 1;
152
+ break;
153
+ elseif keyCode(right_button) && right_button==correct_choice
154
+ subject_choice = right_button;
155
+ no_response = false;
156
+ trlResponse = 1;
157
+ trlAccuracy = 1;
158
+ break;
159
+ elseif keyCode(left_button) && left_button~=correct_choice % ERROR!
160
+ subject_choice = left_button;
161
+ no_response = false;
162
+ trlResponse = 1;
163
+ trlAccuracy = 0;
164
+ break;
165
+ elseif keyCode(right_button) && right_button~=correct_choice % ERROR!
166
+ subject_choice = right_button;
167
+ no_response = false;
168
+ trlResponse = 1;
169
+ trlAccuracy = 0;
170
+ break;
171
+ end
172
+ elseif(GetSecs-wait_stamp) > PREPRACT_RESPDEADLINE,
173
+ subject_choice = no_response;
174
+ no_response = true;
175
+ trlResponse = -1;
176
+ trlAccuracy = -1;
177
+ break;
178
+ end
179
+ end
180
+
181
+ % stop the trial timer
182
+ RT = GetSecs() - startTime;
183
+
184
+ % determine if they selected the right or left stim
185
+ if subject_choice == correct_choice
186
+ trlselectedStim = 1;
187
+ else
188
+ trlselectedStim = 0;
189
+ end
190
+
191
+ % determine the reward feedback
192
+ Screen('TextSize',wPtr,70);
193
+ Screen('TextFont',wPtr,'Times');
194
+ Screen('TextStyle',wPtr,1);
195
+ if no_response == true
196
+ Screen('TextColor',wPtr,[255 0 0]);
197
+ reward_text = 'Respond Faster';
198
+ elseif no_response == false
199
+ if trlAccuracy == 0
200
+ Screen('TextColor',wPtr,[255 0 0]);
201
+ reward_text = 'ERROR!';
202
+ elseif trlAccuracy == 1
203
+ Screen('TextColor',wPtr,[0 255 0]);
204
+ reward_text = 'Good';
205
+ end
206
+ end
207
+
208
+ % now show feedback based on response and stim contingencies
209
+ DrawFormattedText(wPtr,reward_text,'center','center');
210
+ Screen(wPtr, 'Flip');
211
+
212
+ % show the feedback for 1 sec
213
+ WaitSecs(1);
214
+
215
+ % increment the trial index
216
+ trial_index = trial_index + 1;
217
+
218
+ end
219
+
220
+ % check to see if practice is done
221
+ if pracblock_index >= numPracticeBlocks
222
+ practiceComplete = true;
223
+ end
224
+ end
225
+
226
+ % *****END OF PRE-PRACTICE*****
scripts/RUN_CC_Main.m ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %% Cost Confict adapted for Joystick and Brain Vision: JFC 12/13/11
2
+ % Re-adapted for Beh for PdDys: JFC 02/11/15
3
+
4
+ clear all;
5
+ close all;
6
+ command = 'echo orp | sudo -S ifconfig en0 down';
7
+ system(command);
8
+
9
+ fprintf('\n\nShutting down internet to protect timing\n\n');
10
+
11
+ % Find Gamepad and USB-FS2019
12
+ devs = PsychHID('Devices');
13
+ DAQindx = DaqDeviceIndex();
14
+ err0 = DaqDConfigPort(DAQindx, 0, 0); % Port A
15
+ GPindx = find(strcmp('Logitech(R) Precision(TM) Gamepad', {devs.product}));
16
+
17
+ if isempty(GPindx)
18
+ error('No Gamepad attached! Stick one in me so we can play. Then restart Matlab')
19
+ end
20
+
21
+ if isempty(DAQindx)
22
+ error('No DAQ attached! Stick one in me or the EEG will be lonely. Then restart Matlab')
23
+ end
24
+
25
+ % Test fire?
26
+ DaqDOut(DAQindx, 0, 69); WaitSecs(0.2);
27
+ DaqDOut(DAQindx, 0, 0);
28
+ fprintf('\n\n\n')
29
+ TriggerYN = input('Did you see a trigger? And was it a lonely 69\n','s'); %
30
+ if any(strcmp(TriggerYN, {'N' 'n' 'No' 'no'}))
31
+ error('Ahhhhhhh!!!! No triggers. Please fix so people know when I am stimulated')
32
+ end
33
+
34
+ % Get directories
35
+ taskdir = pwd;
36
+
37
+ % Change directory to this script's dir
38
+ p = pwd;
39
+
40
+ subject_number = input('Enter the subject number :','s');
41
+ subject_group = input('Patient, Control or Pilot ("SZ", "NC", anything else) :\n', 's');
42
+
43
+ if length(subject_group) == 0
44
+ subject_group = 'Pilots';
45
+ end
46
+ if any(strcmp(subject_group, {'SZ', 'sz', 's', 'S', 'Patient', 'patient', 'pat', 'Pat', 'scz', 'schz', 'SCZ', 'SCHZ', 'Schz', 'Scz'}))
47
+ subject_group = 'Patients';
48
+ elseif any(strcmp(subject_group, {'NC', 'c', 'C', 'HC', 'nc', 'hc', 'control', 'Control', 'healthy', 'healthy control', 'Healthy Control'}))
49
+ subject_group = 'Normal Controls';
50
+ else
51
+ subject_group = 'Pilots';
52
+ end
53
+
54
+ run_resting = input('\nDo you need to run the resting state?\n(This is a part of the cost conflict experiment):','s');
55
+ contacts = input('\nDoes the participant wear contacts?', 's');
56
+
57
+ datadir = [taskdir '/Data/' subject_group '/M' subject_number '/Cost Conflict/'];
58
+ mkdir(datadir);
59
+
60
+ % $$$$$$$$$$$$ $$$$$$$$$$$$ $$$$$$$$$$$$ $$$$$$$$$$$$
61
+ % % % % PREPRACT_RESPDEADLINE=3;
62
+ % % % % RESPDEADLINE=1.5;
63
+ % % % % TSTDEADLINE=5;
64
+ PREPRACT_RESPDEADLINE=1;
65
+ RESPDEADLINE=0.85;
66
+ TSTDEADLINE=3;
67
+ FUDGE = 10; % fraction of a second to jitter feedback and response, i.e. = 0.17 + rand/FUDGE
68
+
69
+ % This version adds error/missed trials to the END of the TRN run.
70
+ % And 'D' is 0% reward
71
+ % Remember there is some odd coding in the beh for condi - use old beh analysis scripts!
72
+ % $$$$$$$$$$$$ $$$$$$$$$$$$ $$$$$$$$$$$$ $$$$$$$$$$$$
73
+
74
+ % hide the cursor
75
+ HideCursor();
76
+ % disable user responses from being displayed
77
+ ListenChar(2);
78
+
79
+ % Stim
80
+ A=1; B=2;
81
+ C=3; D=4;
82
+ % Color
83
+ y=1; b=2;
84
+ % Congru
85
+ c=1; i=2;
86
+
87
+ % Set up the screen display
88
+ % get the screen pointer
89
+ screens = Screen('Screens');
90
+ screen = max(screens); % Stimuli will be drawn on the highest screen number
91
+ % #####################
92
+ % screenRect = [0,0,1000,800]; % screen for debugging
93
+ screenRect = []; % full screen
94
+ % #####################
95
+ [wPtr,rect] = Screen('OpenWindow',screen, [], screenRect);
96
+ black=BlackIndex(wPtr);
97
+ Screen('FillRect',wPtr,black);
98
+ Screen(wPtr, 'Flip');
99
+
100
+ % get the center point for presentation purposes
101
+ X_center = rect(3)/2;
102
+ Y_center = rect(4)/2;
103
+ % define the boundries of the right and left stims
104
+ image_width = 200;
105
+ image_height = 200;
106
+ % a pixel buffer from the center point
107
+ pixel_buffer = 325;
108
+ pixel_buffer_test = 75;
109
+ pixel_buffer_up = 100;
110
+ % define center rect
111
+ x_Right = X_center - image_width/2;
112
+ X_Left = X_center + image_width/2;
113
+ Y_Top = Y_center - image_height/2;
114
+ left_Ybottom = Y_Top + image_height;
115
+ center_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
116
+ % define the left image rect
117
+ x_Right = X_center - image_width - pixel_buffer;
118
+ X_Left = x_Right + image_width;
119
+ Y_Top = Y_center - image_height/2;
120
+ left_Ybottom = Y_Top + image_height;
121
+ left_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
122
+ % and the right image rect
123
+ x_Right = X_center + pixel_buffer;
124
+ X_Left = x_Right + image_width;
125
+ Y_Top = Y_center - image_height/2;
126
+ left_Ybottom = Y_Top + image_height;
127
+ right_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
128
+ % TEST: left image rect
129
+ x_Right = X_center - image_width - pixel_buffer_test;
130
+ X_Left = x_Right + image_width;
131
+ Y_Top = Y_center - image_height/2;
132
+ left_Ybottom = Y_Top + image_height;
133
+ left_rect_test = [x_Right, Y_Top, X_Left, left_Ybottom];
134
+ % TEST: right image rect
135
+ x_Right = X_center + pixel_buffer_test;
136
+ X_Left = x_Right + image_width;
137
+ Y_Top = Y_center - image_height/2;
138
+ left_Ybottom = Y_Top + image_height;
139
+ right_rect_test = [x_Right, Y_Top, X_Left, left_Ybottom];
140
+
141
+
142
+ % input keys
143
+ left_key = KbName('d');
144
+ right_key = KbName('k');
145
+
146
+ left_button = 5;
147
+ right_button = 6;
148
+ up_button = 4;
149
+ down_button = 2;
150
+
151
+ %**********************************************************************
152
+ % RESTING STATE for eye blinks for dopamine
153
+ if any(strcmp(run_resting, {'yes' 'y' 'Y' 'Yes' 'YE' 'ye' 'YES' 'Ye'}))
154
+ save([datadir 'contacts.mat'], 'contacts')
155
+ restopentext = 'Experimenter: Prepare for 2 minutes resting state EEG';
156
+ reststarttext = 'Experimenter: Start EEG data saving.\nNew EEG file label = REST######\n\n###### = Participant Code\n\n\nThen press any key to continue.';
157
+ restparttext = 'Participant: Please relax while focussing gently on the cross hair for two minutes\n\n\n\nExperimenter: press any key to start.';
158
+ restendtext = 'Finished Resting State\nGet ready for Cost Conflict.\n\nHave fun!\n\n\nExperimenter: Press any key to go onto cost conflict';
159
+
160
+ Screen('TextSize',wPtr,50);
161
+ Screen('TextFont',wPtr,'Times');
162
+ Screen('TextStyle',wPtr,0);
163
+ Screen('TextColor',wPtr,[255 255 255]);
164
+ DrawFormattedText(wPtr,restopentext,'center','center');
165
+ Screen(wPtr, 'Flip');
166
+ KbWait([],3); %Waits for keyboard(any) press
167
+
168
+ DrawFormattedText(wPtr,reststarttext,'center','center');
169
+ Screen(wPtr, 'Flip');
170
+ KbWait([],3); %Waits for keyboard(any) press
171
+
172
+ DrawFormattedText(wPtr,restparttext,'center','center');
173
+ Screen(wPtr, 'Flip');
174
+ KbWait([],3); %Waits for keyboard(any) press
175
+
176
+ DrawFormattedText(wPtr,'+','center','center');
177
+ Screen(wPtr, 'Flip');
178
+ WaitSecs(2);
179
+ for tl = 1:62
180
+ DaqDOut(DAQindx, 0, tl); WaitSecs(1);
181
+ DaqDOut(DAQindx, 0, 0); WaitSecs(1);
182
+ end
183
+ WaitSecs(1);
184
+
185
+ DrawFormattedText(wPtr, restendtext,'center','center');
186
+ Screen(wPtr, 'Flip');
187
+ KbWait([],3); %Waits for keyboard(any) press
188
+ end
189
+
190
+ %********************************************************************
191
+ Instructions; % Pract were stims 1,2
192
+ session = round(rand+1);
193
+ if session==1
194
+ STIMS{1}=[4,8,15,17];
195
+ STIMS{2}=[11,5,3,10];
196
+ STIMS{3}=[7,12,13,18];
197
+ STIMS{4}=[16,21,19,20];
198
+ elseif session==2
199
+ STIMS{1}=[14,22,23,25];
200
+ STIMS{2}=[24,29,27,28];
201
+ STIMS{3}=[30,6,9,26];
202
+ STIMS{4}=[31,32,33,34];
203
+ end
204
+
205
+ starttext = 'Experimenter: Start EEG data saving.\nNew EEG file label = CC######_B1\n\n\nThen press any key to begin experiment';
206
+ Screen('TextSize',wPtr,50);
207
+ Screen('TextFont',wPtr,'Times');
208
+ Screen('TextStyle',wPtr,0);
209
+ Screen('TextColor',wPtr,[255 255 255]);
210
+ DrawFormattedText(wPtr,starttext,'center','center');
211
+ Screen(wPtr, 'Flip');
212
+ KbWait([],3); %Waits for keyboard(any) press
213
+
214
+ setNum = 0;
215
+ sets=randperm(4);
216
+ for Block=sets
217
+
218
+ setNum = setNum + 1;
219
+
220
+ % Set Stims
221
+ S1=num2str(STIMS{Block}(1));
222
+ S2=num2str(STIMS{Block}(2));
223
+ S3=num2str(STIMS{Block}(3));
224
+ S4=num2str(STIMS{Block}(4));
225
+
226
+ data_block = [];
227
+ TRAINING;
228
+
229
+ load([datadir 'M' num2str(subject_number),'_B',num2str(Block),'_CC_train.mat']);
230
+ points = sum(data_block(:,11));
231
+ fprintf(['#########################################\n\n\Points for that block = '...
232
+ num2str(points) '\n\n\n'...
233
+ '#########################################\n\n\n']);
234
+
235
+ % ########################
236
+ Screen('TextSize',wPtr,50);
237
+ Screen('TextFont',wPtr,'Times');
238
+ Screen('TextStyle',wPtr,0);
239
+ Screen('TextColor',wPtr,[255 255 255]);
240
+ beginningText1 = 'Good Job. \n\n\nGet Ready For the test phase. \n\n\n\n\n Experimenter: Press [Space] to continue ';
241
+ DrawFormattedText(wPtr,beginningText1,'center','center');
242
+ Screen(wPtr, 'Flip');
243
+ KbWait([],3); %Waits for keyboard(any) press
244
+ beginningText1 = 'The pictures will be presented in pairs again. \n\n\nPick the picture that was MOST REWARDING during the task \n\n\n\n\n Experimenter: Press space to continue ';
245
+ DrawFormattedText(wPtr,beginningText1,'center','center');
246
+ Screen(wPtr, 'Flip');
247
+ KbWait([],3); %Waits for keyboard(any) press
248
+ % ########################
249
+
250
+ data_test = [];
251
+ TESTING;
252
+
253
+ clear global B_textures;
254
+ clear S1 S2 S3 S4;
255
+
256
+ if any(Block == sets(1:3))
257
+ Screen('TextSize',wPtr,50);
258
+ Screen('TextFont',wPtr,'Times');
259
+ Screen('TextStyle',wPtr,0);
260
+ Screen('TextColor',wPtr,[255 255 255]);
261
+ beginningText1 = 'Great! Get ready for a new training phase...\n\n\n\n\nExperimenter: Press [Space] to continue';
262
+ DrawFormattedText(wPtr,beginningText1,'center','center');
263
+ Screen(wPtr, 'Flip');
264
+ KbWait([],3); %Waits for keyboard(any) press
265
+ end
266
+
267
+ if Block==sets(2)
268
+ breaktext = 'Please have a short break while the experimenter \n starts a new EEG file \n\n\n\n New file label = CC######_B2';
269
+ DrawFormattedText(wPtr, breaktext,'center','center');
270
+ Screen(wPtr, 'Flip');
271
+ KbWait([],3); %Waits for keyboard(any) press
272
+ end
273
+
274
+ blocknumbertext = num2str(find(Block==sets)+1);
275
+ if any(Block == sets(1:3))
276
+ startblocktext = ['Experimenter, press any key to start new block\n\n\n Block ' blocknumbertext ' of/4'];
277
+ DrawFormattedText(wPtr, startblocktext,'center','center');
278
+ Screen(wPtr, 'Flip');
279
+ KbWait([],3); %Waits for keyboard(any) press
280
+ end
281
+ % ########################
282
+
283
+ end
284
+
285
+ %*******FORCE STOP**********
286
+ wait_text = 'Done!\n\nThank you for participating!\n\n\nPlease wait for the experimenter.';
287
+ Screen('TextFont',wPtr,'Times New Roman');
288
+ Screen('TextStyle',wPtr,0);
289
+ Screen('TextColor',wPtr,[255 255 255]);
290
+ Screen('TextSize',wPtr,80);
291
+ DrawFormattedText(wPtr,wait_text,'center','center');
292
+ Screen(wPtr, 'Flip');
293
+ KbWait([],3); %Waits for keyboard(any) press
294
+
295
+ %*******FORCE STOP**********
296
+
297
+ sca;
298
+ ShowCursor;
299
+ fprintf('\nEnd of Task.\n');
300
+ close all;
301
+
302
+ fprintf('\n\nStarting up internet to sync data\n');
303
+ command = 'echo orp | sudo -S ifconfig en0 up';
304
+ system(command);
305
+ WaitSecs(1);
306
+ fprintf('\n\nConnecting to the mothership......\n');
307
+ WaitSecs(1);
308
+ fprintf('\nConnection probably established......\n');
309
+ WaitSecs(2);
310
+ fprintf('\nI think I just touched E.T.\n\n\n\n');
311
+ WaitSecs(1);
312
+ command = 'rsync -avzhe ssh /Users/orp/Documents/MATLAB/REEG2/\!Cost\ Conflict_4/data/ malbrecht@orp-12212-MAPC\:/local/Dropbox/REEG_Data/REEG2_BehaviorBySub/';
313
+ system(command);
314
+
315
+ fprintf('\n\n\nOoooooohhhhh YEAH!!!! Synchronicity!.......\n');
316
+
317
+ ListenChar(0);
318
+
319
+ % Calculate total points
320
+ load([datadir 'M' num2str(subject_number),'_B',num2str(1),'_CC_train.mat']);
321
+ points = sum(data_block(:,11));
322
+ load([datadir 'M' num2str(subject_number),'_B',num2str(2),'_CC_train.mat']);
323
+ points = points + sum(data_block(:,11));
324
+ load([datadir 'M' num2str(subject_number),'_B',num2str(3),'_CC_train.mat']);
325
+ points = points + sum(data_block(:,11));
326
+ load([datadir 'M' num2str(subject_number),'_B',num2str(4),'_CC_train.mat']);
327
+ points = points + sum(data_block(:,11));
328
+
329
+ winnings = points*5/100;
330
+ if winnings < 2
331
+ winnings = 2;
332
+ elseif winnings > 8
333
+ winnings = 8;
334
+ end
335
+ fprintf(['#########################################\n\n\nTotal Points = '...
336
+ num2str(points) '\n\n\nParticipant won $' num2str(winnings) '\n\n\n'...
337
+ '#########################################\n\n\n']);
338
+
339
+
340
+
341
+