File size: 10,527 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
%% ITPC Plots
clear; clc; close all;
savedir='D:\Project_EEG_CC\CC_Results_step2_AllChannels_NEW\';   % Main Data are here

cd(savedir);

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

load('D:\Project_EEG_CC\mFiles\BV_Chanlocs_60.mat');



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

        ITPC=NaN(size_ITPC); 

    else

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

        size_ITPC=size(ITPC); 

    end

        

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

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

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

        ON.ITPC(floor(row),:,:,:,:,:)=ITPC;

               

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

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

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

        OFF.ITPC(floor(row),:,:,:,:,:)=ITPC;

     end

    row=row+.5;

    clear ITPC;

    

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

        ITPC=NaN(size_ITPC);

    else

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

    end

    

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

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

    CTL.ITPC(floor(row),:,:,:,:,:)=ITPC;

    row=row+1;

    clear ERPs VECTOR Model_Output POWER ITPC;

end

CtlN=row-1;



%% #############################################################################

clearvars -except CTL ON OFF

tx2disp=-500:2:1000;

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

CHANI=21;  % channel Cz

EVENT=1;  % CUE, RESP



%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control



OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT);     OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);

ON_Conf2 =   ON.ITPC(:,CHANI,:,:,2,EVENT);     ON_Conf1 =   ON.ITPC(:,CHANI,:,:,1,EVENT); 

CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT);     CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT); 



OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));

ON_Conf21 =  squeeze( nanmean(ON_Conf2,1))  - squeeze( nanmean(ON_Conf1,1));

CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));    



% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%

 

%%% CTL-PD ON

subplot(331);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between' ) ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Cue:CTL-ON (Cong)');hold off; colormap jet



subplot(332);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Cue:CTL-ON (Incong)');hold off; colormap jet 



subplot(333);

imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.1 0.1],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('Cue:Control - PD ON (Incong-Cong)'); colormap jet

    

% % %%%%%         Response-LOCKED

clearvars -except CTL ON OFF

tx2disp=-500:2:1000;

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

CHANI=21;  % channel Cz

EVENT=2;  % CUE, RESP



%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control



OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT);     OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);

ON_Conf2 =   ON.ITPC(:,CHANI,:,:,2,EVENT);     ON_Conf1 =   ON.ITPC(:,CHANI,:,:,1,EVENT); 

CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT);     CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT); 



OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));

ON_Conf21 =  squeeze( nanmean(ON_Conf2,1))  - squeeze( nanmean(ON_Conf1,1));

CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));    



% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%

  

%%% CTL-PD ON

subplot(334);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between' ) ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Resp:CTL-ON (Correct)');hold off; colormap jet



subplot(335);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('Resp:CTL-ON (Error)');hold off; colormap jet 



subplot(336);

imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('Resp:Control - PD ON (Error-Correct)'); colormap jet





%% for PostCorrect and PostError ITPC Results 

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')

load('D:\Project_EEG_CC\CC_Project_PostError\BV_Chanlocs_60.mat');



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

        ITPC=NaN(size_ITPC); 

    else

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

        size_ITPC=size(ITPC); 

    end

        

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

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

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

        ON.ITPC(floor(row),:,:,:,:,:)=ITPC;

               

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

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

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

        OFF.ITPC(floor(row),:,:,:,:,:)=ITPC;

    end

    row=row+.5;

    clear ITPC;

    

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

        ITPC=NaN(size_ITPC);

    else

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

    end

    

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

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

    CTL.ITPC(floor(row),:,:,:,:,:)=ITPC;

    row=row+1;

    clear ERPs VECTOR Model_Output POWER ITPC;

end

CtlN=row-1;



% ##########################################

tx2disp=-500:2:1000;

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

CHANI=21;  % channel Cz

EVENT=2;  % CUE, RESP



%%%%%%%%%%%%%%%%%%%%%%%%% %%% figure for PD OFF/ON - Control



OFF_Conf2 = OFF.ITPC(:,CHANI,:,:,2,EVENT);     OFF_Conf1 = OFF.ITPC(:,CHANI,:,:,1,EVENT);

ON_Conf2 =   ON.ITPC(:,CHANI,:,:,2,EVENT);     ON_Conf1 =   ON.ITPC(:,CHANI,:,:,1,EVENT); 

CTL_Conf2 = CTL.ITPC(:,CHANI,:,:,2,EVENT);     CTL_Conf1 = CTL.ITPC(:,CHANI,:,:,1,EVENT); 



OFF_Conf21 = squeeze( nanmean(OFF_Conf2,1)) - squeeze( nanmean(OFF_Conf1,1));

ON_Conf21 =  squeeze( nanmean(ON_Conf2,1))  - squeeze( nanmean(ON_Conf1,1));

CTL_Conf21 = squeeze( nanmean(CTL_Conf2,1)) - squeeze( nanmean(CTL_Conf1,1));    





% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTOL and PD ON %%%%%%%%%%%%%%%%%%%%

%%% CTL-PD ON

subplot(337);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf1)) - squeeze(nanmean(ON_Conf1)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D (squeeze(ON_Conf1), squeeze(CTL_Conf1), 'between') ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P ;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('PEC:CTL-ON (Post-Correct)');hold off; colormap jet



subplot(338);

imagesc( tx2disp,[], squeeze(nanmean(CTL_Conf2)) - squeeze(nanmean(ON_Conf2)) ); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D( squeeze(ON_Conf2), squeeze(CTL_Conf2), 'between' ) ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));title('PEC:CTL-ON (Post-Error)');hold off; colormap jet 



subplot(339);

imagesc(tx2disp,[], CTL_Conf21 - ON_Conf21); axis xy; hold on; colormap jet

[Corrected_P] = Run_Thresh_2D(squeeze(ON_Conf2)- squeeze(ON_Conf1), squeeze(CTL_Conf2)- squeeze(CTL_Conf1), 'between') ;

contour(tx2disp,1:50,Corrected_P,'k','linewidth',2); clear Corrected_P;

plot([0 0],[1 50],'k:')

set(gca,'clim',[-0.2 0.2],'xlim',[-500,1000],'ylim',[1 50],'YTick',1:4:length(frex),'YTickLabel',round(frex(1:4:end)));hold off; title('PEC:Control - PD ON (PostError-PostCorrect)'); colormap jet



suptitle ('ITPC: Control - PD ON');