-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoarLstLoop.m
167 lines (131 loc) · 3.97 KB
/
soarLstLoop.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
clear;
clc;
tic;
bnds=[.1,40];
winLen=1;
chanPercent=[];
fName='OSU-00001-04B-01-LST.bdf';
subst='.bdf';
outEx='.mat';
dirName = 'C:\Users\John\Documents\MATLAB\soarData\';
[sub] = subdir(dirName);
metaData=struct2table(sub);
fileList=metaData.name;
ii=fileList(1);
for ij=1:length(fileList)
ij/length(fileList);
ii=fileList(ij);
fName=ii{1};
tf = endsWith(fName,subst);
if tf ~= (0)
try
outName=append(fName,outEx);
outName
%load(outName,'EEG')
%EEG = eeg_checkset(EEG); clc;
catch
chanPer=1;
end
end
%chanPercent=[chanPercent; chanPer];
%save('soarSnrResample5.mat','chanPercent');
end
%finalMean=mean(chanPercent);
%truPer=chanPercent(find(chanPercent~=1));
%trueMean=mean(truPer);
% Flanker/ERN Task:
% ERROR TRIALS = 9 and 10
% CORRECT TRIALS = 3 and 4
%
% LST/Doors Task:
% WIN TRIAL = 7
% LOSS TRIAL = 6
toc;
load('OSU-00002-04B-01-ERN.bdf.mat')
% lst and ern
%npu load
f2='OSU_00001_01_01-ERN.log';
ern = readtable(f2,'NumHeaderLines',5,ReadRowNames=true);
f3='OSU_00001_01_01-LST.log';
lst = readtable(f3,'NumHeaderLines',5,ReadRowNames=true);
f4='OSU_00001_01_01-NPU.log';
npu = readtable(f4,'NumHeaderLines',7,ReadRowNames=true);
lern=table2cell(ern);
llst=table2cell(lst);
lnpu=table2cell(npu);
eventCodes=[3, 4];
[ernCorIndexPnts,corErnTimes,~,~,corErnRts]=soarEventFinder(EEG,eventCodes,lern);
eventCodes=[10, 11];
[ernIncIndexPnts,incErnTimes,~,~,incErnRts]=soarEventFinder(EEG,eventCodes,lern);
totalErnEvents=length(ernIncIndexPnts)+length(ernCorIndexPnts);
totalErnAccuracy=length(ernCorIndexPnts)./totalErnEvents;
eventCodes=[3, 4, 10, 11];
winLength=.5;
preLength=.5;
[epochCells,meanCells,indexPnts,sTimes,ernCodes,ernTimeStamps,ernRts]=ernEventEpochs(EEG,eventCodes,lern,preLength,winLength);
meanEeg=mean(meanCells);
xPnts=linspace(0,round(winLength*EEG.srate),length(meanEeg));
% error rates
eventCodes=[10, 11];
[ernEpochCells,ernMeanCells,~,~,~,~,~]=ernEventEpochs(EEG,eventCodes,lern,preLength,winLength);
meanErnEeg=mean(ernMeanCells);
eventCodes=[3, 4];
[crnEpochCells,crnMeanCells,~,~,~,~,~]=ernEventEpochs(EEG,eventCodes,lern,preLength,winLength);
meanCrnEeg=mean(crnMeanCells);
% only after stimuli appears
meanErnEeg=meanErnEeg(:,round(winLength*EEG.srate));
meanCrnEeg=meanCrnEeg(:,round(winLength*EEG.srate));
% plot figures
figure();
plot(xPnts,meanEeg)
ylabel('Voltage (uV)')
xlabel('Time (s)')
% endPoint=min([samples,sTimes(end)])
% find the doors arrow stim
% find the flanker response code
xPnts=linspace(0,round(winLength*EEG.srate),length(meanErnEeg));
plot(xPnts,meanErnEeg)
ylabel('Voltage (uV)')
xlabel('Time (ms)')
hold on;
plot(xPnts,meanCrnEeg)
legend('Error','Correct')
hold off;
xx=EEG.chanlocs;
splName='STUDY_headplot.spl';
xx = readlocs('Standard-10-10-Cap47.ced');
channelLocationFile = 'C:\Users\John\Documents\MATLAB\eeglab2021.1\plugins\dipfit\standard_BESA\standard-10-5-cap385.elp';
xx=readlocs(channelLocationFile);
headplot('setup', xx, splName)
figure;
%headplot(EEG.data, splName)
headplot(crnMeanCells, splName)
%% lst
clc;
clear EEG;
load('OSU-00002-04B-01-LST.bdf.mat')
winLength=1;
eventCodes=[6];
eventCodes=[11];
[~,meanCells,indexPnts,sTimes,ernCodes,ernTimeStamps,ernRts]=soarEventEpochs(EEG,eventCodes,llst,winLength);
lstWin=mean(meanCells);
eventCodes=[7];
eventCodes=[12];
[~,meanCells,indexPnts,sTimes,ernCodes,ernTimeStamps,ernRts]=soarEventEpochs(EEG,eventCodes,llst,winLength);
lstLos=mean(meanCells);
figure();
xPnts=linspace(0,1,length(lstWin));
plot(xPnts,lstWin)
ylabel('Voltage (uV)')
xlabel('Time (s)')
hold on;
plot(xPnts,lstLos)
legend('Win','Loss')
hold off;
splName='STUDY_headplot.spl';
%xx = readlocs('Standard-10-10-Cap47.ced');
channelLocationFile = 'C:\Users\John\Documents\MATLAB\eeglab2021.1\plugins\dipfit\standard_BESA\standard-10-5-cap385.elp';
xx=readlocs(channelLocationFile);
headplot('setup', xx, splName)
figure;
headplot(EEG.data, splName)