-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit_D_from_csv_Rohan.m
56 lines (49 loc) · 1.35 KB
/
init_D_from_csv_Rohan.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
function D = init_D_from_csv(filename)
assert(endsWith(filename, '.csv'));
D.G.N = 0;
D.tasks.s = [];
D.tasks.g = [];
T = readtable(filename);
D.name = [strip(T.Group{1}), ' ', num2str(T.ID(1))];
phase = 'training_1';
for i = 1:size(T,1)
type = strip(T.Type{i});
switch phase
case 'training_1'
if strcmp(type, 'test')
phase = 'test_1';
end
case 'test_1'
if strcmp(type, 'training')
phase = 'training_2';
end
case 'training_2'
if strcmp(type, 'test')
phase = 'test_2';
end
end
if ~strcmp(phase, 'training_1')
% TODO 2nd half
break;
end
s = T.Displayed(i);
g = T.Goals(i);
if iscell(s)
s = str2num(s{1});
end
if iscell(g)
g = str2num(g{1});
end
D.tasks.s = [D.tasks.s s];
D.tasks.g = [D.tasks.g g];
D.G.N = max([D.G.N s g]);
path = strsplit(strip(T.Path{i}), ' ');
for k = 1:length(path) - 1
i = str2num(path{k});
j = str2num(path{k + 1});
D.G.E(i,j) = 1;
D.G.E(j,i) = 1;
D.G.N = max([D.G.N i j]);
end
end
end