-
Notifications
You must be signed in to change notification settings - Fork 1
/
respbinlat.m
180 lines (124 loc) · 4.82 KB
/
respbinlat.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
ALLEEG=[];EEG=[];alldat=[];allrtvar=[];rts=[];dats=[];allrtvar2=[];alldat2=[];
control={'S 41', 'S 42', 'S 51', 'S 52'}
syn = {'S 71' 'S 80' }
sem = {'S 60' 'S 61'}
nsub = 20
channel = 23
for S = 1:nsub
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.saccade EEG.clusters.blink]);
EEG.icawinv = [];EEG.icasphere = [];EEG.icaweights = [];EEG.icachansind = [];
EEG = pop_reref( EEG, [31 33] );
% EEG = pop_eegfiltnew(EEG, 0.5, 0);
EEG = pop_epoch( EEG, control, [-1 3], '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.saccade EEG.clusters.blink]);
EEG.icawinv = [];EEG.icasphere = [];EEG.icaweights = [];EEG.icachansind = [];
EEG = pop_reref( EEG, [31 33] );
% EEG = pop_eegfiltnew(EEG, 0.5, 0);
EEG = pop_epoch( EEG, syn, [-1 3], '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
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_eegfiltnew(EEG, 0.5, 0);
EEG = pop_epoch( EEG, sem, [-1 3], '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;
figure;
for x = 1:20
[outdata,outrtvar] = erpimage(datas2{x}, rts2{x}, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), '', 1, 1 ,'NoShow','on');
ntrials = length(outrtvar);
outdata = outdata(:,ntrials*.05:ntrials*.95);
outrtvar = outrtvar(ntrials*.05:ntrials*.95);
ntrials = length(outrtvar);
sbplot(4,5,x);
plotcurve ( EEG.times, [ mean(outdata(:,1:ntrials*1/4),2) ; mean(outdata(:,ntrials*1/4:ntrials*2/4),2) ; mean(outdata(:,ntrials*2/4:ntrials*3/4),2) ; mean(outdata(:,ntrials*3/4:end),2)])
fasterp(x,:) = mean(outdata(:,1:ntrials*1/4),2);
mod1erp(x,:) = mean(outdata(:,ntrials*1/4:ntrials*2/4),2);
mod2erp(x,:) = mean(outdata(:,ntrials*2/4:ntrials*3/4),2);
slowerp(x,:) = mean(outdata(:,ntrials*3/4:end),2);
fastrt(x,:) = mean(outrtvar(1:ntrials*1/4));
mod1rt(x,:) = mean(outrtvar(ntrials*1/4:ntrials*2/4));
mod2rt(x,:) = mean(outrtvar(ntrials*2/4:ntrials*3/4));
slowrt(x,:) = mean(outrtvar(ntrials*3/4:end));
end;
figure;
for x = 1:20
a = 1:20; a(x) = [];
jackfast(x,:) = mean(fasterp(a,:),1);
jackmod1(x,:) = mean(mod1erp(a,:),1);
jackmod2(x,:) = mean(mod2erp(a,:),1);
jackslow(x,:) = mean(slowerp(a,:),1);
jackfastrt(x) = mean(fastrt(a,:),1);
jackmod1rt(x) = mean(mod1rt(a,:),1);
jackmod2rt(x) = mean(mod2rt(a,:),1);
jackslowrt(x) = mean(slowrt(a,:),1);
sbplot(4,5,x);
plotcurve ( EEG.times, [ jackfast(x,:) ; jackmod1(x,:) ; jackmod2(x,:) ; jackslow(x,:) ] );
end;
jackfast2=jackfast;jackmod12=jackmod1;jackmod22=jackmod2; jackslow2=jackslow;
for y = 1:20
for x = 1:EEG.pnts
if jackfast(y,x) < 0
jackfast2(y,x) = 0;
end;
if jackmod1(y,x) < 0
jackmod12(y,x) = 0;
end;
if jackmod2(y,x) < 0
jackmod22(y,x) = 0;
end;
if jackslow(y,x) < 0
jackslow2(y,x) = 0;
end;
end;
end;
for x = 1:20
erp = jackfast2(x,100:300);
[~,fastlat(x)] = min(abs(cumsum(erp)-sum(erp)/2));
erp = jackmod12(x,100:300);
[~,mod1lat(x)] = min(abs(cumsum(erp)-sum(erp)/2));
erp = jackmod22(x,100:300);
[~,mod2lat(x)] = min(abs(cumsum(erp)-sum(erp)/2));
erp = jackslow2(x,100:300);
[~,slowlat(x)] = min(abs(cumsum(erp)-sum(erp)/2));
end;
a = [mean(jackfastrt), mean(jackmod1rt), mean(jackmod2rt), mean(jackslowrt)]
b = [mean(fastlat) mean(mod1lat) mean(mod2lat) mean(slowlat)]
[r,p] =corr(a.',b.')
statmatrix2 = [fastlat.' mod1lat.' mod2lat.' slowlat.']
[stats,table]=mes1way(statmatrix2,'partialeta2','isdep',1)
round(cell2mat(table(2,5))) / (stats.n(1) -1)^2
% in R: oneWayAOV.Fstat(17.479, 20, 4, rscale = 0.5)
%erp_adjusted = bsxfun(@minus,erp_matrix(samples,:),min(erp_matrix(samples,:)));
%[~,latency_indicies] = min(abs(bsxfun(@minus,cumsum(erp_adjusted),sum(erp_adjusted)/2)));
%latencies = (EEG.xmin + (samples(1)+latency_indicies)/EEG.srate)*1000;