File size: 9,583 Bytes
d7989aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
%% Control and PD OFF: Statistics for POWER ROIs
close all;clear;clc;
%%%% get the data
savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\'; 

cd(savedir);

load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF')

PDsx=[801:811,813:829];        %  824 S2 CC is bad (mange here)

CTLsx=[8010,8070,8060,890:914];  %  911 S1 CC is bad (mange here) 



BigN=size(ONOFF,1)./2;

% load PD OFF and ON data

row=1;

for mi=1:size(ONOFF,1)



    disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==824 && ONOFF(mi,2)==2  % Bad EEG

        POWER=NaN(size_power);

    else

        load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

        size_power=size(POWER); 

    end

     

    if ONOFF(mi,3)==1 % ON

        ON.ID(floor(row))=ONOFF(mi,1);

        ON.Session(floor(row))=ONOFF(mi,2);

        ON.POWER{1}(floor(row),:,:,:,:,:)=POWER;

                      

    elseif ONOFF(mi,3)==0 % OFF

        OFF.ID(floor(row))=ONOFF(mi,1);

        OFF.Session(floor(row))=ONOFF(mi,2);

        OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER;

     end

    row=row+.5;

    clear POWER;

end

% load control data

row=1;

for CTLi=CTLsx

    

    disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==911 && ONOFF(mi,2)==1  % Bad EEG

        POWER=NaN(size_power);POWER_REST=NaN(size_power);

    else

        load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    end

    

    CTL.ID(floor(row))=CTLi;

    CTL.Session(floor(row))=1;

    CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    row=row+1;

    clear POWER;

end

CtlN=row-1;



%% %% Cue-locked Data Correct and Error response: POWER ROI 

%############# get the POWER of region of interest and ANOVA-ResponseLocked

tx2disp=-500:2:1000;

frex=logspace(.01,1.7,50);

CHANI = 21; %%% channel Cz

Bidx=1;   % 1 is pre-cue baseline

EVENT=1;  % cue



% Cue-locked

t1 = find (tx2disp==400); t2 = find (tx2disp==500);

fq1 = min(find(frex>3.8));   fq2 = min(find(frex>7.8));

 

for i = 1:28

    ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    

    ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) )));

    ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); 

    

end



%%% replace NaN with mean value

ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2);

ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1);



% ANOVA

ROI_CTL_CI = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ];

ROI_OFF_CI = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ];



p = anova_rm({ROI_CTL_CI ROI_OFF_CI});

clear p;



%% Response-locked Data Correct and Error response: POWER ROI 

%############# get the POWER of region of interest and ANOVA-ResponseLocked

clearvars -except OFF ON CTL



tx2disp=-500:2:1000;

frex=logspace(.01,1.7,50);

CHANI = 21; %%% channel Cz

Bidx=1;   % 1 is pre-cue baseline

EVENT=2;  % RESP



% %%%%%%%%   RESPONSE-LOCKED

% Response-locked



t1 = find (tx2disp==-200); t2 = find (tx2disp==50);

fq1 = min(find(frex>3.8));   fq2 = min(find(frex>7.8));

 

for i = 1:28

    ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    ROI_Pow_OFF_1(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    

    ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) )));

    ROI_Pow_OFF_2(i,:) = mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); 

end



%%% replace NaN with mean value

ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2);

ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1);



% ANOVA

ROI_CTL_CE = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ];

ROI_OFF_CE =  [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ];

p = anova_rm({ROI_CTL_CE ROI_OFF_CE});

clear p ;



%% CORRECT only : Cong and Incong

close all;clear;clc;

%%%% get the data

savedir='D:\Project_EEG_CC\CC_Results_step2_CORRECT_NEW\'; 

cd(savedir);

load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF')

PDsx=[801:811,813:829];        %  824 S2 CC is bad (mange here)

CTLsx=[8010,8070,8060,890:914];  %  911 S1 CC is bad (mange here) 



BigN=size(ONOFF,1)./2;

% load PD OFF and ON data

row=1;

for mi=1:size(ONOFF,1)



    disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==824 && ONOFF(mi,2)==2  % Bad EEG

        POWER=NaN(size_power);

    else

        load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

        size_power=size(POWER); 

    end

     

    if ONOFF(mi,3)==1 % ON

        ON.ID(floor(row))=ONOFF(mi,1);

        ON.Session(floor(row))=ONOFF(mi,2);

        ON.POWER{1}(floor(row),:,:,:,:,:)=POWER;

                      

    elseif ONOFF(mi,3)==0 % OFF

        OFF.ID(floor(row))=ONOFF(mi,1);

        OFF.Session(floor(row))=ONOFF(mi,2);

        OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    end

    row=row+.5;

    clear POWER;

end

% load control data

row=1;

for CTLi=CTLsx

    

    disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==911 && ONOFF(mi,2)==1  % Bad EEG

        POWER=NaN(size_power);

    else

        load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    end

    

    CTL.ID(floor(row))=CTLi;

    CTL.Session(floor(row))=1;

    CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    row=row+1;

    clear POWER

end

CtlN=row-1;

% %

tx2disp=-500:2:1000;

frex=logspace(.01,1.7,50);

CHANI = 21; %%% channel Cz

Bidx=1;   % 1 is pre-cue baseline



% %%%%%%%%   RESPONSE-LOCKED

% Response-locked

t1 = find (tx2disp==-200); t2 = find (tx2disp==50);

fq1 = min(find(frex>3.8));   fq2 = min(find(frex>7.8));

 

for i = 1:28

    ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1) )));

    ROI_Pow_OFF_1(i,:) =  mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1) )));

    

    ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2) )));

    ROI_Pow_OFF_2(i,:) =  mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2) ))); 

end



%%% replace NaN with mean value

ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2);

ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1);



% ANOVA

ROI_CTL_CI = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ];

ROI_OFF_CI = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ];

p = anova_rm({ROI_CTL_CI ROI_OFF_CI});

clear p;



%% Post Correct and Post Error Data: POWER ROI 

close all; clear; clc;

%%%% get the data

savedir='D:\Project_EEG_CC\CC_Project_PostError\PostError_step2_Data_NEW\';   % Main Data are here

cd(savedir);

load('D:\Project_EEG_CC\CC_Project_PostError\ONOFF.mat','ONOFF')

PDsx=[801:811,813:829];        %  824 S2 CC is bad (mange here)

CTLsx=[8010,8070,8060,890:914];  %  911 S1 CC is bad (mange here) 



BigN=size(ONOFF,1)./2;

% load PD OFF and ON data

row=1;

for mi=1:size(ONOFF,1)



    disp([num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==824 && ONOFF(mi,2)==2  % Bad EEG

        POWER=NaN(size_power);

    else

        load([savedir,num2str(ONOFF(mi,1)),'_Session_',num2str(ONOFF(mi,2)),'_PDDys_CC_ALL_GOODS.mat']);

        size_power=size(POWER); 

    end

     

    if ONOFF(mi,3)==1 % ON

        ON.ID(floor(row))=ONOFF(mi,1);

        ON.Session(floor(row))=ONOFF(mi,2);

        ON.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    elseif ONOFF(mi,3)==0 % OFF

        OFF.ID(floor(row))=ONOFF(mi,1);

        OFF.Session(floor(row))=ONOFF(mi,2);

        OFF.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    end

    row=row+.5;

    clear POWER

end

% load control data

row=1;

for CTLi=CTLsx

    

    disp([num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    

    if ONOFF(mi,1)==911 && ONOFF(mi,2)==1  % Bad EEG

        POWER=NaN(size_power);POWER_REST=NaN(size_power);

    else

        load([savedir,num2str(CTLi),'_Session_1_PDDys_CC_ALL_GOODS.mat']);

    end

    

    CTL.ID(floor(row))=CTLi;

    CTL.Session(floor(row))=1;

    CTL.POWER{1}(floor(row),:,:,:,:,:)=POWER;

    row=row+1;

    clear POWER

end

CtlN=row-1;



% % ############# get the POWER of region of interest and ANOVA-ResponseLocked



tx2disp=-500:2:1000;

frex=logspace(.01,1.7,50);

CHANI = 21; %%% channel Cz

Bidx=1;   % 1 is pre-cue baseline

EVENT=2;  % RESP



% %%%%%%%%   RESPONSE-LOCKED

% Response-locked

t1 = find (tx2disp==-200); t2 = find (tx2disp==50);

fq1 = min(find(frex>3.8));   fq2 = min(find(frex>7.8));



for i = 1:28

    ROI_Pow_CTL_1(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    ROI_Pow_OFF_1(i,:) =  mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,1,EVENT) )));

    

    ROI_Pow_CTL_2(i,:) = mean( squeeze(nanmean(CTL.POWER{Bidx}(i,CHANI,fq1:fq2,t1:t2,2,EVENT) )));

    ROI_Pow_OFF_2(i,:) =  mean( squeeze(nanmean(OFF.POWER{Bidx} (i,CHANI,fq1:fq2,t1:t2,2,EVENT) ))); 

end



%%% replace NaN with mean value

ROI_Pow_OFF_2(isnan(ROI_Pow_OFF_2))=nanmean(ROI_Pow_OFF_2);

ROI_Pow_OFF_1(isnan(ROI_Pow_OFF_1))=nanmean(ROI_Pow_OFF_1);



% ANOVA

ROI_CTL_PCE = [ROI_Pow_CTL_1 ROI_Pow_CTL_2 ];

ROI_OFF_PCE = [ROI_Pow_OFF_1 ROI_Pow_OFF_2 ];

 

p = anova_rm({ROI_CTL_PCE ROI_OFF_PCE});

clear p ;