-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain_gui.m
More file actions
308 lines (274 loc) · 12.2 KB
/
Copy pathmain_gui.m
File metadata and controls
308 lines (274 loc) · 12.2 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
function varargout = main_gui(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_gui_OpeningFcn, ...
'gui_OutputFcn', @main_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before main_gui is made visible.
function main_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% Initialize
[main_path] = initialization;
set(handles.new_project,'UserData',{main_path});
set(handles.conf_tags,'Enable','off');
set(findall(handles.panel_seg, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel_lab, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel_class, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel_res, '-property', 'enable'), 'enable', 'off');
set(handles.res_demo,'Enable','on');
set(handles.paths_features,'Enable','off');
set(handles.res_compare_class,'Visible','off');
set(handles.classification_conf,'UserData',[0,100,0,25,40,0]);
set(handles.paths_features,'Visible','off');
set(handles.features_conf,'Visible','off'); %custom features
% Choose default command line output for main_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main_gui wait for user response (see UIRESUME)
% uiwait(handles.main_figure);
% --- Outputs from this function are returned to the command line.
function varargout = main_gui_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
function main_figure_CloseRequestFcn(hObject, eventdata, handles)
delete(hObject);
%%%% PROJECT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function new_project_Callback(hObject, eventdata, handles)
exe_new_project(hObject, eventdata, handles);
paths_features_Callback(hObject, eventdata, handles);
%pick default segmentation, labels, classification
refresh_seg_Callback(hObject, eventdata, handles);
refresh_labs_Callback(hObject, eventdata, handles);
refresh_class_Callback(hObject, eventdata, handles);
function load_project_Callback(hObject, eventdata, handles)
exe_load_project(hObject, eventdata, handles);
%in case the project was created using the old version generate the
%extra files
project_path = get(handles.load_project,'UserData');
project_path = char_project_path(project_path);
if ~exist(fullfile(project_path,'settings','my_trajectories_features.mat'))
paths_features_Callback(hObject, eventdata, handles);
end
%pick default segmentation, labels, classification
refresh_seg_Callback(hObject, eventdata, handles);
refresh_labs_Callback(hObject, eventdata, handles);
refresh_class_Callback(hObject, eventdata, handles);
function paths_features_Callback(hObject, eventdata, handles)
%EXECUTE AFTER NEW PROJECT
project_path = get(handles.load_project,'UserData');
project_path = char_project_path(project_path);
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return
end
[temp, idx] = hide_gui('RODA');
error = full_trajectory_features(project_path);
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
%%%% SEGMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function segmentation_button_Callback(hObject, eventdata, handles)
exe_segmentation(hObject, eventdata, handles);
refresh_seg_Callback(hObject, eventdata, handles);
function refresh_seg_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
[segmentations,~,~] = pick_defaults(project_path);
set(handles.default_segmentation,'String',segmentations);
set(handles.default_segmentation,'Value',1);
%%%% LABELLING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function browse_trajectories_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return
end
%hide this GUI
[temp, idx] = hide_gui('RODA');
if ~iscell(project_path)
project_path = {project_path};
end
browse(project_path);
set(temp(idx),'Visible','on');
refresh_labs_Callback(hObject, eventdata, handles);
function check_labels_Callback(hObject, eventdata, handles)
exe_check_labels(hObject, eventdata, handles);
function refresh_labs_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
[~,labels,~] = pick_defaults(project_path);
set(handles.default_labels,'String',labels);
set(handles.default_labels,'Value',1);
%%%% CLASSIFICATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function default_classification_Callback(hObject, eventdata, handles)
exe_default_classification(hObject, eventdata, handles);
refresh_class_Callback(hObject, eventdata, handles);
fclose('all');
function advanced_classification_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return;
end
[temp, idx] = hide_gui('RODA');
classification_adv(project_path);
set(temp(idx),'Visible','on');
refresh_class_Callback(hObject, eventdata, handles)
fclose('all');
function refresh_class_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
[~,~,class] = pick_defaults(project_path);
set(handles.default_class,'String',class);
set(handles.default_class,'Value',1);
%%%% RESULT BUTTONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function res_demo_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
demo_gui;
set(temp(idx),'Visible','on');
function res_metrics_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
error = gui_generate_results(handles,eventdata);
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
function res_strategies_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
error = gui_generate_results(handles,eventdata);
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
function res_transitions_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
error = gui_generate_results(handles,eventdata);
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
function res_probabilities_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
error = gui_generate_results(handles,eventdata);
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
function res_statistics_Callback(hObject, eventdata, handles)
project_path = char_project_path(get(handles.load_project,'UserData'));
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return;
end
class_name = get(handles.default_class,'String');
idx = get(handles.default_class,'Value');
class_name = class_name{idx};
if isempty(class_name)
errordlg('No classification is selected','Error');
return;
end
[temp, idx] = hide_gui('RODA');
%post or pre smoothing?
choice = questdlg('Would you like to generate the statistics before or after applying the smoothing function?', ...
'Statistics','Before','After','Cancel','Before');
switch choice
case 'Before'
[error,~,~] = class_statistics(project_path, class_name);
case 'After'
try
tmp = strsplit(class_name,'_');
tmp = strcat('segmentation_configs_',tmp{3},'_',tmp{4},'_',tmp{5},'.mat');
load(fullfile(project_path,'segmentation',tmp));
catch
errordlg('Cannot load segmentation object');
set(temp(idx),'Visible','on');
return
end
[error,~,~] = class_statistics(project_path, class_name, 'SEGMENTATION', segmentation_configs);
case 'Cancel'
error = 1;
otherwise
error = 1;
end
set(temp(idx),'Visible','on');
if ~error
msgbox('Operation successfully completed','Success');
end
function res_compare_class_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return;
end
[temp, idx] = hide_gui('RODA');
gui_compare(project_path);
set(temp(idx),'Visible','on');
%%%% MENU %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function options_tab_Callback(hObject, eventdata, handles)
function conf_figs_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
figure_configs;
set(temp(idx),'Visible','on');
function conf_tags_Callback(hObject, eventdata, handles)
project_path = get(handles.load_project,'UserData');
if isempty(project_path)
errordlg('No project is currently loaded','Error');
return;
end
[temp, idx] = hide_gui('RODA');
tags_config(project_path);
set(temp(idx),'Visible','on');
% --------------------------------------------------------------------
function advanced_tab_Callback(hObject, eventdata, handles)
function method_conf_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
ret = get(handles.method_conf,'UserData');
%[ STR_DISTR, TRANS_DISTR, SIGMA, INTERVAL, R_SIGMA, R_INTERVAL ]
ret = advanced_gui(ret);
set(handles.method_conf,'UserData',ret);
set(temp(idx),'Visible','on');
function features_conf_Callback(hObject, eventdata, handles)
features_config;
function classification_conf_Callback(hObject, eventdata, handles)
[temp, idx] = hide_gui('RODA');
ret = get(handles.classification_conf,'UserData');
%[ STOP_ERROR, STOP_K, PICK_Start, PICK_END, N_CLASS, START_K ]
ret = classification_configs_adv(ret);
set(handles.classification_conf,'UserData',ret);
set(temp(idx),'Visible','on');
%%%% AUTO-GEN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function seg_length_Callback(hObject, eventdata, handles)
function seg_length_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function seg_overlap_Callback(hObject, eventdata, handles)
function seg_overlap_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function default_segmentation_Callback(hObject, eventdata, handles)
function default_segmentation_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function default_labels_Callback(hObject, eventdata, handles)
function default_labels_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function default_class_Callback(hObject, eventdata, handles)
function default_class_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end