forked from psiwex/altaircode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoarPlotter.m
215 lines (164 loc) · 4.12 KB
/
soarPlotter.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
close all;
clear;
clc;
load('ernAccSoar.mat','ernAcc');
load('ernRtCorSoar.mat','ernRtCor');
load('ernRtIncSoar.mat','ernRtInc');
load('meanErnESoar.mat','meanErnE');
load('meanCrnESoar.mat','meanCrnE');
load('meanErnCorSoar.mat','ernCorCells');
load('meanErnIncSoar.mat','ernIncCells');
load('meanLstWinsSoar.mat','meanWins');
load('meanLstLossSoar.mat','meanLoss');
load('meanLstWinCellSoar.mat','listWinCells');
load('meanLstLosCellSoar.mat','listLosCells');
load('OSU-00002-04B-01-ERN.bdf.mat')
%% ern parameters
winLength=.5;
preLength=.5;
chanLim=39;
% channel fcz:
chanSel=38;
totalLength=(EEG.srate*(preLength+winLength))+1;
% accuracy and response time
finalMean=mean(ernAcc);
corRtErn=0;
incRtErn=0;
ernInd=[];
ernInd2=[];
for ji=1:length(ernRtInc)
nBlock=ernRtCor{ji};
nBlock0=ernRtInc{ji};
if isempty(nBlock)==false
vBlock=mean(nBlock);
corRtErn=mean(corRtErn+vBlock);
ernInd=[ernInd; ji];
end
if isempty(nBlock0)==false
vBlock0=mean(nBlock0);
incRtErn=mean(incRtErn+vBlock0);
ernInd2=[ernInd2; ji];
end
end
ernInd0=unique([ernInd; ernInd2]);
conErnEeg=zeros(chanLim,totalLength);
incErnEeg=zeros(chanLim,totalLength);
for ji=1:length(ernInd0)
% for correct
ernCNum=ernInd0(ji);
x=ernCorCells{ernCNum};
[~,numCells]=size(x);
[xx1,yy1]=size(x{1});
recept=zeros(xx1,yy1);
for jj=1:numCells
conv=x{jj};
recept=recept+conv;
end
recept=recept/numCells;
recept=recept(1:chanLim,1:totalLength);
conErnEeg=conErnEeg+recept;
% for incorrect
ernENum=ernInd0(ji);
x=ernIncCells{ernENum};
[~,numCells0]=size(x);
[xx1,yy1]=size(x{1});
recept=zeros(xx1,yy1);
for jj=1:numCells0
conv=x{jj};
recept=recept+conv;
end
recept=recept/numCells0;
recept=recept(1:chanLim,1:totalLength);
incErnEeg=incErnEeg+recept;
end
conErnEeg=conErnEeg/length(ernInd0);
incErnEeg=incErnEeg/length(ernInd0);
%% lst parameters
winLength=1;
totalLengthLst=(EEG.srate*(winLength))+1;
winLstEeg=zeros(chanLim,totalLength);
losLstEeg=zeros(chanLim,totalLength);
lstInd=[];
lstInd1=[];
for ji=1:length(listWinCells)
celTest=listWinCells{ji};
if isempty(celTest)==false
lstInd=ji;
end
celTest=listLosCells{ji};
if isempty(celTest)==false
lstInd1=ji;
end
end
lstInd0=unique([lstInd; lstInd1]);
for ji=1:length(lstInd0)
% wins
ernCNum=lstInd0(ji);
x=listWinCells{ernCNum};
x=x(1:chanLim,1:totalLength);
winLstEeg=winLstEeg+x;
% loss
ernCNum=lstInd0(ji);
x=listLosCells{ernCNum};
x=x(1:chanLim,1:totalLength);
losLstEeg=losLstEeg+x;
end
winLstEeg=winLstEeg/length(lstInd0);
losLstEeg=losLstEeg/length(lstInd0);
%% pretty up each
% ern cleanup
preBaseline=(EEG.srate*(preLength))+1;
x1=conErnEeg(:,1:preBaseline);
x2=incErnEeg(:,1:preBaseline);
for aa=1:chanLim
x1(aa,1:preBaseline)=linspace(x1(aa,1),x1(aa,end),preBaseline);
x2(aa,1:preBaseline)=linspace(x2(aa,1),x2(aa,end),preBaseline);
end
% x1=detrend(x1,1);
% x2=detrend(x2,1);
% x1=x1-mean(x1);
% x2=x2-mean(x2);
% x1=detrend(x1,2);
% x2=detrend(x2,2);
conErnEeg(:,1:preBaseline)=x1;
incErnEeg(:,1:preBaseline)=x2;
crn=conErnEeg(:,preBaseline:end);
ern=incErnEeg(:,preBaseline:end);
% ern=detrend(ern,1);
% crn=detrend(crn,1);
crn=crn/max(max(crn));
ern=ern/max(max(ern));
conErnEeg(:,preBaseline:end)=crn;
incErnEeg(:,preBaseline:end)=ern;
% lst cleanup
winLstEeg=winLstEeg-mean(winLstEeg);
losLstEeg=losLstEeg-mean(losLstEeg);
%% figures
% ern
% channel fcz is 38
figure;
xPnts=linspace(-round(preLength*EEG.srate),round(winLength*EEG.srate),totalLength);
plot(xPnts,conErnEeg(chanSel,:))
ylabel('Voltage (uV)')
xlabel('Time (ms)')
hold on;
plot(xPnts,incErnEeg(chanSel,:))
legend('Correct','Error')
hold off;
xx=EEG.chanlocs;
splName='STUDY_headplot.spl';
xx = readlocs('Standard-10-10-Cap47.ced');
headplot('setup', xx, splName)
figure;
%headplot(EEG.data, splName)
headplot(ern, splName)
% lst
xPnts=linspace(0,round(winLength*EEG.srate),length(winLstEeg));
figure();
plot(xPnts,winLstEeg(chanSel,:))
ylabel('Voltage (uV)')
xlabel('Time (s)')
hold on;
plot(xPnts,losLstEeg(chanSel,:))
legend('Win','Loss')
hold off;