-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmanuscriptPlottingWrapper.m
372 lines (305 loc) · 12.8 KB
/
manuscriptPlottingWrapper.m
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
%% Figure 1: HighGammaPower IPS/SPL traces and Renderings
cd ~/Documents/ECOG/scripts/
addpath Plotting/
addpath lib/
opts = [];
opts.hem = 'l';
opts.lockType = 'stim';
opts.reference = 'nonLPCleasL1TvalCh';
opts.nRefChans = 10;
opts.type = 'power';
opts.band = 'hgam';
opts.smoother = 'loess';
opts.smootherSpan = 0.15;
opts.yLimits = [-0.6 2];
opts.timeLims = [0 1; -1 0.2]; % statistcs evaluation; first row for stim
opts.aRatio = [500 300];
opts.renderType = 'SmoothCh';%{'SmoothCh','UnSmoothCh', 'SigChans','SignChans'};
opts.limitDw = -4;
opts.limitUp = 4;
opts.absLevel = 1;
opts.Pthr = 0.005;
opts.resolution = 600;
opts.subjects = {'16b','18','24','28','30','17b','19', '29'};
opts.hemId = {'l' ,'l' ,'l' ,'l' , 'l', 'r' ,'r' , 'r'};
opts.measType = 'm'; % {'m','z','c','Zc'}
opts.comparisonType = 'ZStat'; % {ZStat,ZcStat}
opts.baselineType = 'sub';
opts.analysisType = 'logPower';
opts.mainPath = '../Results/' ;
opts.dataPath = [opts.mainPath 'Spectral_Data/group/'];
opts.preFix = ['ERSPs' opts.band];
opts.plotPath = ['~/Google ','Drive/Research/ECoG ','Manuscript/ECoG ',... '
'Manuscript Figures/Fig1/'];
opts.extension1 = [ 'stimLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
opts.extension2 = [ 'RTLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
fileName1 = ['all' opts.preFix 'Group' opts.extension1 '.mat'];
fileName2 = ['all' opts.preFix 'Group' opts.extension2 '.mat'];
load([opts.dataPath fileName1]);
data1 = data;
load([opts.dataPath fileName2]);
data2 = data;
clear data; close all
plotHGPTracesByChan(data1,data2,opts);
%plotHGPTracesBySubj(data1,data2,opts);
addpath Plotting/
addpath lib/
% channels
opts.plotPath = ['~/Google ','Drive/Research/ECoG ','Manuscript/ECoG ',... '
'Manuscript Figures/Fig1/'];
opts.level = 'group'; %{'group','subj'}
opts.cortexType = 'MNI'; %{'Native','MNI'}
opts.chanNumLabel = false; %{true,false}
opts.ROIColor = true; %{true,false}
opts.ROIColors = [[0.9 0.2 0.2];[0.1 0.5 0.8];[0.2 0.6 0.3]];
opts.subROIColor = false; %{true,false}
opts.subROIColors = [[0.7 0.1 0.1]; [0.95 0.4 0.4]; [0.05 0.3 0.7];[0.2 0.6 0.9]];
opts.resolution = 300;
%renderChansFig1(data1,opts)
%% Figure 2: clusters
addpath Plotting/
addpath Analysis/
addpath lib/
close all
opts = [];
opts.smoother = 'loess';
opts.smootherSpan = 0.15;
opts.resolution = 600;
opts.Pthr = 0.01;
opts.timeLims = [0 1; -1 0.2]; % statistcs evaluation; first row for stim
opts.plotPath = ['~/Google ','Drive/Research/ECoG ','Manuscript/ECoG ',...
'Manuscript Figures/Fig2/'];
dataPath= '../Results/Spectral_Data/group/';
pre = 'allERSPshgamGroup';
post = 'LocksublogPowernonLPCleasL1TvalCh10.mat';
load([dataPath 'clusters/K2Clusters' pre 'stim' post]);
clusterSet1 = out;
load([dataPath 'clusters/K2Clusters' pre 'RT' post]);
clusterSet2 = out;
load([dataPath pre 'stim' post]);
data1 = data;
load([dataPath pre 'RT' post]);
data2 = data;
plotHGPclustersFig2(data1,clusterSet1,data2,clusterSet2,opts)
%%
% get descriptive numbers
% number of ROI to cluster overlap
% cluster 1
chans=find(clusterSet1.chans);
nOver =sum([chans(clusterSet1.index)==clusterSet1.ROI_ids]);
nTot = numel(chans);
fprintf('CL1 #overlap / total = %i / %i \n', nOver,nTot)
% cluster 2
chans=find(clusterSet2.chans);
nOver =sum([chans(clusterSet2.index)==clusterSet2.ROI_ids]);
nTot = numel(chans);
fprintf('CL2 #overlap / total = %i / %i \n', nOver,nTot)
% Get Unified Clusters
% get cluster channels
dType = {'stim','RT'};
CLChans = cell(2,1);
for ii = 1:2
CLChans{ii}=union(clusterSet1.subCLChans{ii},clusterSet2.subCLChans{ii});
fprintf(' # of channels for CL1 and CL2 on %s data \n', dType{ii})
disp([numel(clusterSet1.subCLChans{ii}) numel(clusterSet2.subCLChans{ii})])
end
% number of channels in the resulting aggregated cluster
for ii = 1:2
fprintf('number of channels in cluster # %i = %i \n',ii,numel(CLChans{ii}))
end
% number of channels per subjects in the resulting clusters
for ii =1:2
fprintf('For Cluster %i \n',ii)
for jj=1:5
kk= numel(intersect(CLChans{ii},find(data1.subjChans==jj)));
fprintf('number of channels for subject %i = %i \n',jj,kk)
end
end
%
%
%% supplement for cluster 3,4
ClusterSet = cell(4,1);
load([dataPath 'clusters/K3Clusters' pre 'stim' post]);
ClusterSet{1} = out;
load([dataPath 'clusters/K3Clusters' pre 'RT' post]);
ClusterSet{2} = out;
load([dataPath 'clusters/K4Clusters' pre 'stim' post]);
ClusterSet{3} = out;
load([dataPath 'clusters/K4Clusters' pre 'RT' post]);
ClusterSet{4} = out;
plotHGPclustersK3and4(ClusterSet,opts)
%% Figure 3: Channel wise classification accuracy
close all;
opts = [];
opts.lockType1 = 'stim';
opts.dataType1 = 'power'; opts.bands1 = {'hgam'};
opts.lockType2 = 'RT';
opts.dataType2 = 'power'; opts.bands2 = {'hgam'};
opts.subjects = [1:5]; % left subjects
opts.ROIs = [1 2]; % roi 1 and 2, IPS and SPL
opts.ROIids = true; % plot roi colors
opts.ylims = [0.45 0.9];
opts.xlims = [0.45 0.7];
opts.rendLimits = [-0.15 0.15];
opts.resolution = 400;
opts.baseLineY = 0;
opts.timeType = 'Bin';
opts.channelGroupingType = 'channel';
opts.timeFeatures = 'trial';
opts.extStr = 'liblinearS0';%'NNDTW_K5';
opts.timeStr1 = '0msTo1000ms';
opts.timeStr2 = 'n800msTo200ms';
dataPath = ['../Results/Classification/group/'];
fileName1 = [ opts.dataType1 '/' opts.channelGroupingType '/' 'SumallSubjsClassXVB' ...
opts.lockType1 'Lock' opts.timeStr1 opts.dataType1 cell2mat(opts.bands1) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gT' opts.channelGroupingType '_Solver' opts.extStr];
fileName2 = [ opts.dataType2 '/' opts.channelGroupingType '/' 'SumallSubjsClassXVB' ...
opts.lockType2 'Lock' opts.timeStr2 opts.dataType2 cell2mat(opts.bands2) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gT' opts.channelGroupingType '_Solver' opts.extStr];
fileName3 = [ opts.dataType1 '/ROI/' 'allSubjsClassXVB' ...
opts.lockType1 'Lock' opts.timeStr1 opts.dataType1 cell2mat(opts.bands1) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gTROI_Solver' opts.extStr];
fileName4 = [ opts.dataType1 '/ROI/' 'allSubjsClassXVB' ...
opts.lockType2 'Lock' opts.timeStr2 opts.dataType1 cell2mat(opts.bands1) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gTROI_Solver' opts.extStr];
fileName5 = [ opts.dataType1 '/IPS-SPL/' 'allSubjsClassXVB' ...
opts.lockType1 'Lock' opts.timeStr1 opts.dataType1 cell2mat(opts.bands1) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gTIPS-SPL_Solver' opts.extStr];
fileName6 = [ opts.dataType1 '/IPS-SPL/' 'allSubjsClassXVB' ...
opts.lockType2 'Lock' opts.timeStr2 opts.dataType1 cell2mat(opts.bands1) '_tF' opts.timeFeatures ...
'_tT' opts.timeType '_gTIPS-SPL_Solver' opts.extStr];
opts.fileName = fileName1;
opts.fileName = fileName2;
load([dataPath fileName1])
data1 = S; % stimLock by Channel
load([dataPath fileName2])
data2 = S; % RTLock by Channel
load([dataPath fileName3])
data3 = S; % stimLock by ROI
load([dataPath fileName4])
data4 = S; % RTLock by ROI
load([dataPath fileName5])
data5 = S; % stimLock by IPS-SPL
load([dataPath fileName6])
data6 = S; % RTLock by IPS-SPL
opts.savePath = '/Users/alexg8/Google Drive/Research/ECoG Manuscript/ECoG Manuscript Figures/Fig3/';
close all
%plotFigure3_v2(data1,data2,data3,data4,data5,data6,opts)
%% decoding statistics in the paper:
IPSch = data1.ROIid==1 & data1.hemChanId==1;
SPLch = data1.ROIid==2 & data1.hemChanId==1;
disp('Stim-Locked Data Acc across ROI channels Results')
[~,p,~,t]=ttest(data1.mBAC(IPSch),0.5);
fprintf('IPS T-Stat %g, P-Val %g, DF %i \n', t.tstat,p,t.df)
[~,p,~,t]=ttest(data1.mBAC(SPLch),0.5);
fprintf('SPL T-Stat %g, P-Val %g, DF %i \n', t.tstat,p,t.df)
disp('RT-Locked Data Acc across ROI channels Results')
[~,p,~,t]=ttest(data2.mBAC(IPSch),0.5);
fprintf('IPS T-Stat %g, P-Val %g, DF %i \n', t.tstat,p,t.df)
[~,p,~,t]=ttest(data2.mBAC(SPLch),0.5);
fprintf('SPL T-Stat %g, P-Val %g, DF %i \n', t.tstat,p,t.df)
fprintf('\n')
disp('Stim-Locked Data Acc by ROI Results')
X = mean(data3.perf,4);
mX = nanmean(X(1:5,:));
[~,p,~,t]=ttest(X(1:5,:),0.5);
fprintf(' IPS Mean: %.2g, T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(1), t.tstat(1),p(1),t.df(1))
fprintf(' SPL Mean: %.2g T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(2), t.tstat(2),p(2),t.df(2))
fprintf(' AG Mean: %.2g T-Stat %.4g, P-Val %6.2e, DF %i \n',mX(3), t.tstat(3),p(3),t.df(3))
fprintf('\n')
disp('RT-Locked Data Acc by ROI Results')
X = mean(data4.perf,4);
mX = nanmean(X(1:5,:));
[~,p,~,t]=ttest(X(1:5,:),0.5);
fprintf(' IPS Mean: %.2g, T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(1), t.tstat(1),p(1),t.df(1))
fprintf(' SPL Mean: %.2g T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(2), t.tstat(2),p(2),t.df(2))
fprintf(' AG Mean: %.2g T-Stat %.4g, P-Val %6.2e, DF %i \n',mX(3), t.tstat(3),p(3),t.df(3))
fprintf('\n')
disp('Stim-Locked Data Acc by IPS-SPL Results')
X = mean(data5.perf,4);
mX = nanmean(X([1 3 4 5],:));
[~,p,~,t]=ttest(X([1 3 4 5],:),0.5);
fprintf(' Mean: %.2g, T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(1), t.tstat(1),p(1),t.df(1))
fprintf('\n')
disp('RT-Locked Data Acc by IPS-SPL Results')
X = mean(data6.perf,4);
mX = nanmean(X([1 3 4 5],:));
[~,p,~,t]=ttest(X([1 3 4 5],:),0.5);
fprintf(' Mean: %.2g, T-Stat %.3g, P-Val %6.2e, DF %i \n',mX(1), t.tstat(1),p(1),t.df(1))
%% plot ERP figure
cd ~/Documents/ECOG/scripts/
addpath Plotting/
addpath lib/
opts = []; opts.hem = 'l';
opts.nRefChans = 10; opts.type = 'erp';
opts.smoother = 'loess'; opts.smootherSpan = 0.15;
opts.lockType = 'stim'; opts.reference = 'nonLPCleasL1TvalCh';
opts.Pthr = 0.005; opts.timeLims = [0 1; -1 0.2];
opts.subjects = {'16b','18','24','28', '30', '17b','19', '29'};
opts.hemId = {'l' ,'l' ,'l' ,'l' ,'l','r' ,'r' , 'r'};
opts.measType = 'm'; % {'m','z','c','Zc'}
opts.comparisonType = 'ZStat'; % {ZStat,ZcStat}
opts.baselineType = 'sub';
opts.analysisType = 'Amp';
opts.mainPath = '../Results/' ;
opts.dataPath = [opts.mainPath 'ERP_Data/group/'];
opts.preFix = 'ERPs';
opts.plotPath = ['~/Google ','Drive/Research/ECoG ','Manuscript/ECoG ',... '
'Manuscript Figures/supplement/'];
opts.extension1 = [ 'stimLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
opts.extension2 = [ 'RTLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
fileName1 = ['all' opts.preFix 'Group' opts.extension1 '.mat'];
fileName2 = ['all' opts.preFix 'Group' opts.extension2 '.mat'];
load([opts.dataPath fileName1]);
data1 = data;
load([opts.dataPath fileName2]);
data2 = data;
clear data; close all
%plotERPsByChan(data1,data2, opts)
plotERPsBySubj(data1,data2, opts)
%% Rendering of seizure channels.
%% Figure XXX: HGP-RT correlation
addpath Plotting/
opts = [];
opts.hem = 'l';
opts.lockType = 'stim';
opts.reference = 'nonLPCleasL1TvalCh';
opts.nRefChans = 10;
opts.type = 'power';
opts.band = 'hgam';
opts.smoother = 'loess';
opts.smootherSpan = 0.01;
opts.yLimits = [-0.25 0.25];
opts.aRatio = [500 300];
opts.renderType = 'SmoothCh';%{'SmoothCh','UnSmoothCh', 'SigChans','SignChans'};
opts.limitDw = -3;
opts.limitUp = 3;
opts.absLevel = 1;
opts.resolution = 400;
opts.subjects = {'16b','18','24','28','17b','19', '29'};
opts.hemId = {'l' ,'l' ,'l' ,'l' ,'r' ,'r' , 'r'};
opts.measType = 'c'; % {'m','z','c','Zc'}
opts.comparisonType = 'ZStat'; % {ZStat,ZcStat}
opts.baselineType = 'sub';
opts.analysisType = 'logPower';
opts.mainPath = '../Results/' ;
opts.dataPath = [opts.mainPath 'Spectral_Data/group/'];
opts.preFix = ['ERSPs' opts.band];
opts.plotPath = ['~/Google ','Drive/Research/ECoG ','Manuscript/ECoG ',... '
'Manuscript Figures/individualPlotsPDFs/'];
opts.extension1 = [ 'stimLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
opts.extension2 = [ 'RTLock' opts.baselineType opts.analysisType opts.reference ...
num2str(opts.nRefChans)] ;
fileName1 = ['all' opts.preFix 'Group' opts.extension1 '.mat'];
fileName2 = ['all' opts.preFix 'Group' opts.extension2 '.mat'];
load([opts.dataPath fileName1]);
data1 = data;
load([opts.dataPath fileName2]);
data2 = data;
clear data; close all
plotHGP_RTcorr(data1,data2,opts);