-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaltairErnPlotterThresher.m
More file actions
197 lines (159 loc) · 3.51 KB
/
altairErnPlotterThresher.m
File metadata and controls
197 lines (159 loc) · 3.51 KB
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
%close all;
clear;
clc;
plotChan='FCz';
load('ernArtRejection.mat','ernArtRep');
mainVec=ernArtRep(:,3);
rejThres=.8;
vals=find(mainVec>rejThres);
mainVals=mainVec(vals);
%load('lstArtRejection.mat','lstArtRep');
% Bin 1
% Incorrect Response
% .{9;10}
%
% Bin 2
% Correct Response
% .{3;4}
%
% Bin 3
% Congruent Stimulus
% .{1}
%
% Bin 4
% Incongruent Stimulus
% .{2}
% % bin1
load('ernN1.mat','e1');
load('ernN2.mat','e2');
load('ernN3.mat','e3');
load('ernN4.mat','e4');
load('ernFileNames.mat','filzList');
load('ernFileNums.mat','fileNums');
load('erperns.mat','erperns')
load('erpernNames.mat','erpernNames');
%load('OSU-00002-04B-01-ERN.bdf_kukri_ern.mat')
%x=EEG.data;
% ern1=squeeze(x(:,:,1));
% ern2=squeeze(x(:,:,2));
% ern3=squeeze(x(:,:,3));
% ern4=squeeze(x(:,:,4));
ern=[];
crn=[];
winLength=1;
preLength=.5;
chanLim=48;
% channel fcz:
chanSel=41;
chanSel=31;
%chanSel=38;
outEx2='_kukri_ern_erp.mat';
%chanSel=1;
%chanSel=21;
EEG.srate=256;
totalLength=(EEG.srate*(preLength+winLength))+1;
subSelTrue=1;
% if any(subSel == vals )
% disp('There is at least one value here.')
% else
% disp('All values are not here.')
% end
for subSel=1:length(erpernNames)
if any(subSel == vals )
fName=erpernNames{(subSel)};
strLoad=append(fName,outEx2);
try
load(strLoad)
x=EEG.data;
las=EEG.chanlocs;
%ERPS=erperns(subSel);
%x=ERPS{1}.bindata;
%las=ERPS{1}.chanlocs;
%labs=las.labels;
chanValues={};
myfield=squeeze(struct2cell(las));
for i=1:length(las)
chanValues{i}=myfield{1,i};
end
idx = strfind(chanValues,plotChan);
for iss=1:length(las)
y1=idx{iss};
if y1==1
chanSel=iss;
end
end
%firstabc = find( plotChan, 1 );
index = strfind(fName, '\');
fName=fName((index(end)+1):end);
ern1=squeeze(x(:,:,1));
ern2=squeeze(x(:,:,2));
ern3=squeeze(x(:,:,3));
ern4=squeeze(x(:,:,4));
% ern1=e1{subSel};
% ern2=e2{subSel};
% ern3=e3{subSel};
% ern4=e4{subSel};
%fName=filzList{subSel};
% ern1=mean(ern1);
% ern2=mean(ern2);
% ern3=mean(ern3);
% ern4=mean(ern4);
%% ern parameters
% accuracy and response time
%finalMean=mean(ernAcc);
corRtErn=0;
incRtErn=0;
lwrBnd=round(preLength*EEG.srate);
searchBnd=round(1.1*EEG.srate);
means=mean(ern1(:,lwrBnd:searchBnd),2);
maxs=max(abs(ern1(:,lwrBnd:searchBnd))')';
stds=std(ern1(:,lwrBnd:searchBnd)')';
%% figures
% ern
% channel fcz is 38
subSelTrue=subSelTrue+1;
ern(subSelTrue,:)=ern1(chanSel,:);
crn(subSelTrue,:)=ern2(chanSel,:);
catch
end
end
end
ee1=ern;
ee2=crn;
ern=mean(ern);
crn=mean(crn);
figureHandle=figure;
xPnts=linspace(-(preLength),(winLength),length(ern));
plot(xPnts,(crn))
ylabel('Voltage (uV)')
xlabel('Time (ms)')
hold on;
plot(xPnts,(ern))
legend('Correct','Error')
hold off;
%saveas(figureHandle,[fName 'ernChan' num2str(chanSel) 'FromSub' num2str(subSel) '.jpg']);
% ern=mean(ern1);
% crn=mean(ern2);
% figureHandle2=figure;
% xPnts=linspace(-(preLength),(winLength),length(ern));
% plot(xPnts,(crn))
% ylabel('Voltage (uV)')
% xlabel('Time (ms)')
% hold on;
% plot(xPnts,(ern))
% legend('Correct','Error')
% hold off;
%saveas(figureHandle2,[fName 'ernChanAveragedFromSub' num2str(subSel) '.jpg']);
%close all;
rawData=ern-crn;
splName='STUDY_headplot.spl';
%xx = readlocs('testFile.ced');
%timeArt=[8,2,7,6,5,1,4];
%x=xx(timeArt);
%x=chanLocs;
x=EEG.chanlocs;
headplot('setup', x, splName)
%close;
figure;
headplot(rawData', splName)
%headplot(rawData, splName)