-
Notifications
You must be signed in to change notification settings - Fork 1
/
soarLoader.m
134 lines (101 loc) · 3.41 KB
/
soarLoader.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
clear;
clc;
tic;
bnds=[.1,40];
ernAcc=[];
ernRtCor={};
ernRtInc={};
ernCorCells={};
ernIncCells={};
meanErnE=[];
meanCrnE=[];
meanWins=[];
meanLoss=[];
listWinCells={};
listLosCells={};
fName2='OSU-00001-04B-01-ERN.bdf.mat';
load(fName2)
fName='OSU-00001-04B-01-ERN.bdf';
subst='.bdf';
outEx='.mat';
logEx='.log';
ernSuf='ERN';
lstSuf='LST';
npuSuf='NPU';
dirName = 'C:\Users\John\Documents\MATLAB\soarData\';
impName=strcat(subst,outEx);
[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,impName);
if (tf == true)
load(fName)
x0=strfind(fName,'.');
prefixs=fName(1:(x0(1)-1));
tf1 = endsWith(prefixs,ernSuf);
if (tf1 == true)
try
f2=strcat(prefixs,logEx);
f2 = strrep(f2,'Actiview','Behavioral');
ern = readtable(f2,'NumHeaderLines',5,ReadRowNames=true);
lern=table2cell(ern);
winLength=.5;
preLength=.5;
[totalErnAccuracy,corErnRts,incErnRts,meanEeg,meanErnEeg,meanCrnEeg,ernEpochCells,crnEpochCells,xPnts]=ernProcess(EEG,lern,preLength,winLength);
ernAcc=[ernAcc; totalErnAccuracy];
ernRtCor{ij}=corErnRts;
ernRtInc{ij}=incErnRts;
meanErnE=[meanErnE; meanErnEeg];
meanCrnE=[meanCrnE; meanCrnEeg];
ernCorCells{ij}=ernEpochCells;
ernIncCells{ij}=crnEpochCells;
end
end
tf2 = endsWith(prefixs,lstSuf);
if (tf2 == true)
try
f3=strcat(prefixs,logEx);
f3 = strrep(f3,'Actiview','Behavioral');
lst = readtable(f3,'NumHeaderLines',5,ReadRowNames=true);
llst=table2cell(lst);
winLength=1;
[meanWinCells,meanLosCells,lstWin,lstLos,xPnts]=lstProcess(EEG,llst,winLength);
meanWins=[meanWins; lstWin];
meanLoss=[meanLoss; lstLos];
listWinCells{ij}=meanWinCells;
listLosCells{ij}=meanLosCells;
end
end
tf3 = endsWith(prefixs,npuSuf);
if (tf3 == true)
try
f4=strcat(prefixs,logEx);
f4 = strrep(f4,'Actiview','Behavioral');
npu = readtable(f4,'NumHeaderLines',7,ReadRowNames=true);
lnpu=table2cell(npu);
winLength=.5;
preLength=.5;
[xPnts]=ernProcess(EEG,lnpu,preLength,winLength);
end
end
end
%chanPercent=[chanPercent; chanPer];
save('ernAccSoar.mat','ernAcc');
save('ernRtCorSoar.mat','ernRtCor');
save('ernRtIncSoar.mat','ernRtInc');
save('meanErnESoar.mat','meanErnE');
save('meanCrnESoar.mat','meanCrnE');
save('meanErnCorSoar.mat','ernCorCells');
save('meanErnIncSoar.mat','ernIncCells');
save('meanLstWinsSoar.mat','meanWins');
save('meanLstLossSoar.mat','meanLoss');
save('meanLstWinCellSoar.mat','listWinCells');
save('meanLstLosCellSoar.mat','listLosCells');
end
finalMean=mean(ernAcc);
toc;