-
Notifications
You must be signed in to change notification settings - Fork 1
/
charybdis-itc2.txt
243 lines (136 loc) · 6.82 KB
/
charybdis-itc2.txt
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
ALLEEG=[];EEG=[];alldat=[];allrtvar=[];rts=[];dats=[];allrtvar2=[];alldat2=[];tics=[];
control={'S 41', 'S 42', 'S 51', 'S 52'}
syn = {'S 71' 'S 80'}
sem = {'S 60' 'S 61'}
buttonpress = {'S196'}
channel = 23
for S = 1:20
filename = [num2str((S),'%02i'),'_char_long.set'];
filepath = '/home/jona/Desktop/charybdis/neufilt/'
EEG = pop_loadset('filename',filename,'filepath',filepath);
%EEG = pop_resample( EEG, 100);
EEG = pop_subcomp( EEG,[EEG.clusters.blink EEG.clusters.saccade], 0);EEG.icasphere = []; EEG.icaweights = []; EEG.icawinv = [];
EEG = pop_reref( EEG, [31 33] );
EEG = pop_epoch( EEG, control, [-4 5], 'epochinfo', 'yes');
%EEG = pop_rmbase( EEG, []);
dat = squeeze(eeg_getdatact(EEG,'channel',channel));
controlerp=mean(dat,2);
EEG = pop_loadset('filename',filename,'filepath',filepath);
%EEG = pop_resample( EEG, 100);
EEG = pop_subcomp( EEG,[EEG.clusters.blink EEG.clusters.saccade], 0);EEG.icasphere = []; EEG.icaweights = []; EEG.icawinv = [];
EEG = pop_reref( EEG, [31 33] );
EEG = pop_epoch( EEG, buttonpress, [-9 10], 'epochinfo', 'yes');
EEG = pop_epoch( EEG, syn, [-4 5], 'epochinfo', 'yes');
%EEG = pop_rmbase( EEG, []);
dat = squeeze(eeg_getdatact(EEG,'channel',channel));
rtvar = eeg_getepochevent( EEG,buttonpress,[],'latency');
for ii=1:length(dat(1,:))
dat(:,ii)=dat(:,ii)-controlerp;
end
allrtvar = [rtvar,allrtvar];
alldat=[dat,alldat];
EEG = pop_loadset('filename',filename,'filepath',filepath);
%EEG = pop_resample( EEG, 100);
EEG = pop_subcomp(EEG,[EEG.clusters.saccade EEG.clusters.blink]);
EEG.icawinv = [];EEG.icasphere = [];EEG.icaweights = [];EEG.icachansind = [];
EEG = pop_reref( EEG, [31 33] );
EEG = pop_epoch( EEG, buttonpress, [-9 10], 'epochinfo', 'yes');
EEG = pop_epoch( EEG, sem, [-4 5], 'epochinfo', 'yes');
% EEG = pop_rmbase( EEG, []);
dat = squeeze(eeg_getdatact(EEG,'channel',channel));
rtvar = eeg_getepochevent( EEG,{'S196'},[],'latency');
for ii=1:length(dat(1,:))
dat(:,ii)=dat(:,ii)-controlerp;
end
allrtvar2 = [rtvar,allrtvar2];
alldat2=[dat,alldat2];
rts{S} = allrtvar;
datas{S} = alldat;
rts2{S} = allrtvar2;
datas2{S} = alldat2;
allrtvar=[];alldat=[];allrtvar2=[];alldat2=[];
end;
%datas=datas2;rts=rts2;
%figure;
%sbplot(2,1,1)
% erpimage(alldat, allrtvar, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 30, 1 ,'erp',1,'avg_type','Gaussian','cbar','on','cbar_title','\muV');
%sbplot(2,1,2)
%erpimage(alldat, allrtvar, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 30, 1 ,'erp',1,'avg_type','Gaussian','cbar','on','cbar_title','\muV','align',inf);
for X = 1:20
[outdata5,outrtvar5,outtrials5,limits,axhndls,erp,amps,cohers,cohsig,ampsig,outamps,phsangls,phsamp,sortidx,erpsig] = erpimage(datas{X}, rts{X}, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 1, 1 ,'erp',1,'cbar','on','cbar_title','\muV','NoShow','on');
[Y(X),I(X)]=max(erp(1:525));
[outdata6,outrtvar6,outtrials6] = erpimage(datas{X}, rts{X}, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 1, 1 ,'erp',1,'cbar','on','cbar_title','\muV','NoShow','on','align',inf);
X
[ersp,itc,powbase,times,freqs,erspboot,itcboot,itcphase] = newtimef( {outdata6 outdata5} ,EEG.pnts,[EEG.xmin EEG.xmax]*1000,EEG.srate,[2 0.5], 'freqs', [0.5 8], 'plotphase', 'off', 'plotersp','off', 'plotitc','off','trialbase','full','timesout',1000,'nfreqs',30,'verbose','on','freqscale', 'linear','verbose','off');
itcs1{X} = itc{1};itcs2{X} = itc{2};itcs{X} = itc{3};ersps{X} = ersp{3};tics(:,:,X) = itcs{X};tics1(:,:,X) = itcs1{X};tics2(:,:,X) = itcs2{X};
X
end;
[outdata,outrtvar,outtrials,limits,axhndls,erp,amps,cohers,cohsig,ampsig,outamps,phsangls,phsamp,sortidx,erpsig] = erpimage(alldat,allrtvar, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 1, 1 ,'erp',1,'cbar','on','cbar_title','\muV','NoShow','on');
[Ys,maxp6]=max(erp((times(1)-EEG.times(1))/10:525));
I = maxp6;
S = 3
for X = 1:20
a(X) = mean(mean(tics(:,I-S:I+S,X),1),2);
end;
stats = mes(a.',0,{'md','hedgesg'},'nBoot',10000);
[BF01, probH0] = bayesTtestOneSample(a)
for X = 1:20
rtallss(X) = nanmean(rts{X});
end;
figure;
for X = 1:20;
sbplot(4,5,X);
tftopo(itcs{X},times,freqs,'limits', [nan nan nan nan nan nan], 'smooth',2,'logfreq','off','vert',[ 0 940],'title',num2str(X));
end;
figure;
for X = 1:20;
sbplot(4,5,X);
tftopo(itcs1{X},times,freqs,'limits', [nan nan nan nan nan nan], 'smooth',2,'logfreq','off','vert',[ 0 940],'title',num2str(X));
end;
figure;
for X = 1:20;
sbplot(4,5,X);
tftopo(itcs2{X},times,freqs,'limits', [nan nan nan nan nan nan], 'smooth',2,'logfreq','off','vert',[ 0 940],'title',num2str(X));
end;
%figure;
for X = 1:20
%sbplot(4,5,X)
%plotcurve(times,itcs{X}(3:6,:),'plotmean','on','vert',[times([265])]);
%plotcurve(times,itcs{X}(4:6,:),'plotmean','on','vert',[700]);
%plotcurve(times,itcs{X}(:,:),'plotmean','on','vert',[940]);
end;
clear out3;
for X = 1:20
out3(X) = mean(mean(tics(:,245:250,X),1),2);
[BF01, probH0] = bayesTtestOneSample(out3);
bfactor(X) = 1/BF01;
[H,P,CI,STATS] = ttest(out3);
tstats(X) = STATS.tstat;
pvalues(X) = P;
end;
plot(tstats)
plot(bfactor);
xlabel('# of participants')
ylabel('bayes factor in favour of the alternative hypothesis')
%figure;
for X = 1:20
tics(:,:,X) = itcs{X};
end;
%figure;tftopo(tics,times,freqs,'limits', [nan nan nan nan nan nan], 'smooth',2,'logfreq','native','mode','ave','vert',[0 943]);
for X = 1:20
out(X) = mean(mean(tics(:,245:250,X),1),2);
out2(X) = mean(mean(tics(3:6,245:250,X),1),2);
end;
[BF01, probH0] = bayesTtestOneSample(out)
[BF01, probH0] = bayesTtestOneSample(out2)
for X = 1:20
[outdata5,outrtvar5,outtrials5] = erpimage(datas{X}, rts{X}, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 1, 1 ,'erp',1,'cbar','on','cbar_title','\muV','NoShow','on');
[outdata6,outrtvar6,outtrials6] = erpimage(datas{X}, rts{X}, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), 'PZ ERP sorted by reaction time', 1, 1 ,'erp',1,'cbar','on','cbar_title','\muV','NoShow','on','align',inf);
X
[ersp,itc,powbase,times,freqs,erspboot,itcboot,itcphase] = newtimef( outdata5 ,EEG.pnts,[EEG.xmin EEG.xmax]*1000,EEG.srate,[2 0.5], 'freqs', [0.5 8], 'plotphase', 'off', 'plotersp','off', 'plotitc','off','trialbase','full','timesout',1000,'nfreqs',30,'verbose','on','freqscale', 'linear','verbose','off');
tics1(:,:,X) = itc;
[ersp,itc,powbase,times,freqs,erspboot,itcboot,itcphase] = newtimef( outdata6 ,EEG.pnts,[EEG.xmin EEG.xmax]*1000,EEG.srate,[2 0.5], 'freqs', [0.5 8], 'plotphase', 'off', 'plotersp','off', 'plotitc','off','trialbase','full','timesout',1000,'nfreqs',30,'verbose','on','freqscale', 'linear','verbose','off');
tics2(:,:,X) = itc;
X
end;
% Mean ITC was higher in response-than in onset-locked data (t(19) = 5, p < 0.0001, 95% CI = 0.036, 0.078).