-
Notifications
You must be signed in to change notification settings - Fork 1
/
info.cc
156 lines (114 loc) · 4.06 KB
/
info.cc
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
#include "exp.h"
#include <stdexcept>
#include <set>
struct session_info {
std::string name;
std::vector<std::string> todo;
std::vector<std::string> done;
};
struct session_set {
session_info& add(const colortilt::session &info);
session_info& add(const colortilt::trail &trail);
std::vector<session_info> sessions;
};
session_info &session_set::add(const colortilt::session &info) {
for (session_info &i : sessions) {
if (i.name == info.stim) {
i.todo.push_back(info.rnd);
return i;
}
}
session_info nfo;
nfo.name = info.stim;
nfo.todo = std::vector<std::string>{info.rnd};
sessions.push_back(nfo);
return sessions.back();
}
session_info &session_set::add(const colortilt::trail &trail) {
for (session_info &i : sessions) {
if (i.name == trail.stim) {
i.done.push_back(trail.rnd);
return i;
}
}
session_info nfo;
nfo.name = trail.stim;
nfo.done = std::vector<std::string>{trail.rnd};
sessions.push_back(nfo);
return sessions.back();
}
int main(int argc, char **argv) {
try {
iris::data::store store = iris::data::store::default_store();
std::string name = "";
if (argc > 1) {
name = argv[1];
}
std::string baseloc = "";
if (argc > 2) {
baseloc = argv[2];
}
// load the experiment data
fs::file exp_file = colortilt::experiment::find_file(name, baseloc);
if (exp_file.path().empty()) {
std::cerr << "Could not find experiment file!" << std::endl;
return -1;
}
fs::file exp_yaml = fs::file(exp_file);
if (!exp_file.exists()) {
std::cerr << "Could no find experiment file" << std::endl;
return -1;
}
colortilt::experiment exp = colortilt::experiment::from_yaml(exp_yaml);
std::cout << "Color Tilt Experiment" << std::endl;
std::cout << "Contrast BG: " << exp.c_bg << std::endl;
std::cout << "Contrast FG: " << exp.c_fg << std::endl;
std::cout << "Mouse gain: " << exp.cursor_gain << std::endl;
std::vector<std::string> sids = exp.subjects();
std::vector<iris::data::subject> subjects;
std::cout << std::endl << "Enrolled subjects: " << std::endl;
for (const std::string &sid : sids) {
std::cout << " " << sid;
iris::data::subject s;
try {
s = store.load_subject(sid);
subjects.push_back(std::move(s));
} catch (const std::exception &e) {
std::cout << "\t[! unregisted subject]";
}
std::cout << std::endl;
}
std::cout << std::endl << "Subjects: " << std::endl;
for (const iris::data::subject &subject : subjects) {
std::vector<colortilt::session> sessions = exp.load_sessions(subject);
session_set unique;
std::cout << " " << subject.name << std::endl;
for (const colortilt::session &s : sessions) {
unique.add(s);
}
std::vector<colortilt::trail> trails = exp.list_trails(subject);
for (const colortilt::trail &trail : trails) {
unique.add(trail);
}
int todo = 0;
int done = 0;
long diff = 0;
for (const session_info &i : unique.sessions) {
std::cout << " " << i.name << "\t" << i.done.size();
std::cout << " / " << i.todo.size() << std::endl;
todo += i.todo.size();
done += i.done.size();
long d = i.todo.size() - i.done.size();
if (d > 0) {
diff += d;
}
}
std::cout << " * Summary: \t " << done << " / " << todo;
std::cout << " [" << diff << "]" << std::endl;
}
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
return -1;
}
return 0;
}