Skip to content

Commit 97024b4

Browse files
committed
bugs fix
1 parent ad2e49f commit 97024b4

File tree

5 files changed

+52
-30
lines changed

5 files changed

+52
-30
lines changed

check/validate_groups.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
groups = [1,2];
1616
return;
1717
end
18-
end
18+
end
19+
if length(varargin) == 2
20+
if isequal(varargin{1},1) && isequal(varargin{2},2)
21+
groups = [1,2];
22+
return;
23+
end
24+
end
1925

2026
% Other data
2127
if length(groups) == 1 %Only one animal group

gui.m

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,27 @@ function class_path_CreateFcn(hObject, eventdata, handles)
185185
%% CODE FOR ALL THE PATH TEXTS %%
186186
function b_path_data_Callback(hObject, eventdata, handles)
187187
FN_data = uigetdir(matlabroot,'Select data folder');
188-
if FN_data==0
189-
return
190-
end
191-
set(handles.path_data,'String',FN_data);
188+
if isnumeric(FN_data)
189+
return
190+
end
191+
set(handles.path_data,'String',FN_data);
192192
function b_path_output_Callback(hObject, eventdata, handles)
193193
FN_output = uigetdir(matlabroot,'Select output folder');
194-
if FN_output==0
195-
return
196-
end
197-
set(handles.path_output,'String',FN_output);
194+
if isnumeric(FN_output)
195+
return
196+
end
197+
set(handles.path_output,'String',FN_output);
198198
function b_path_labels_Callback(hObject, eventdata, handles)
199199
[FN_labels,PN_labels] = uigetfile({'*.csv','CSV-file (*.csv)'},'Select CSV file containing segment labels');
200-
if FN_labels==0 && PN_labels==0
201-
return
202-
end
200+
if isnumeric(FN_labels) && isnumeric(PN_labels)
201+
return
202+
end
203203
set(handles.path_labels,'String',strcat(PN_labels,FN_labels));
204204
function segment_path_Callback(hObject, eventdata, handles)
205205
[FN_seg,PN_seg] = uigetfile({'*.mat','MAT-file (*.mat)'},'Select MAT file containing segmentation data');
206-
if FN_seg==0 && PN_seg==0
207-
return
208-
end
206+
if isnumeric(FN_seg) && isnumeric(PN_seg)
207+
return
208+
end
209209
error = check_object_output_dir(1, FN_seg, PN_seg);
210210
if error == 1
211211
errordlg('File path for segmentation configurations not found.','Input Error');
@@ -214,12 +214,12 @@ function segment_path_Callback(hObject, eventdata, handles)
214214
errordlg('Wrong MAT file was selected.','Input Error');
215215
return
216216
end
217-
set(handles.seg_path,'String',strcat(PN_seg,FN_seg));
217+
set(handles.seg_path,'String',strcat(PN_seg,FN_seg));
218218
function b_class_path_Callback(hObject, eventdata, handles)
219219
[FN_class,PN_class] = uigetfile({'*.mat','MAT-file (*.mat)'},'Select MAT file containing classification data');
220-
if FN_class==0 && PN_class==0
220+
if isnumeric(FN_class) && isnumeric(PN_class)
221221
return
222-
end
222+
end
223223
error = check_object_output_dir(2, FN_class);
224224
if error == 1
225225
errordlg('File path for classification configurations not found.','Input Error');
@@ -229,7 +229,7 @@ function b_class_path_Callback(hObject, eventdata, handles)
229229
return
230230
end
231231
set(handles.class_path,'String',strcat(PN_class,FN_class))
232-
232+
233233
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234234
%% CODE FOR BUTTONS %%
235235
function load_traj_buttom_Callback(hObject, eventdata, handles)

results/RUN_ALL_RESULTS.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function RUN_ALL_RESULTS( segmentation_configs, classification_configs, labels_path, folds, group_1, group_2, varargin )
22

33
results_class_weights (segmentation_configs, classification_configs);
4-
results_clustering_parameters (segmentation_configs, labels_path);
4+
results_clustering_parameters (segmentation_configs, labels_path, 0);
5+
results_clustering_parameters (segmentation_configs, labels_path, 1);
56
results_confusion_matrix (segmentation_configs, classification_configs, folds);
67
results_latency_speed_length (segmentation_configs, group_1, group_2, varargin{:});
78
results_strategies_distributions_length (segmentation_configs, classification_configs, group_1, group_2, varargin{:});

results/results_clustering_parameters.m

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [varargout] = results_clustering_parameters(segmentation_configs,labels_path,varargin)
1+
function [varargout] = results_clustering_parameters(segmentation_configs,labels_path,graph,varargin)
22
% Generates three figures indicating the impact of the number of clusters
33
% on the clustering performance for a set of N computed segments:
44
% 1. Percentage of classification errors.
@@ -7,6 +7,15 @@
77
% 3. Percentage of the full swimming paths that are covered by at least
88
% one segment of a known class.
99
% The calculated data from the clustering proceedures are also saved.
10+
11+
% PARAMETERS:
12+
% Segmentation object
13+
% Path of the labels CSV file
14+
% 0/1: don't generate/generate graphs
15+
16+
% Optional: min number of clusters
17+
% max number of clusters
18+
% increment
1019

1120
% Iterations
1221
min_num = 1;
@@ -26,7 +35,16 @@
2635

2736
% Tag trajectories/segments if data are available
2837
[~, LABELLING_MAP, ~, CLASSIFICATION_TAGS] = setup_tags(segments,labels_path);
29-
38+
39+
% generate unique id
40+
segs = num2str(size(features,1));
41+
a = [];
42+
for i = 1:10
43+
temp = num2str(size(find([LABELLING_MAP{:}]==i-2),2));
44+
a = [a, temp];
45+
end
46+
a = [segs,a];
47+
3048
% run multiple clusterings with different target number of clusters
3149
ptest = 0;
3250
res1 = [];
@@ -68,7 +86,7 @@
6886

6987
% i) two-phase clustering (default)
7088
% see if we already have the data
71-
fn = fullfile(strcat(segmentation_configs.OUTPUT_DIR,'/'), sprintf('clustering_n%d.mat', n));
89+
fn = fullfile(strcat(segmentation_configs.OUTPUT_DIR,'/'), sprintf('clustering_%d_%s.mat', n,a));
7290
if exist(fn ,'file')
7391
fprintf('\nData for %d number of clusters (two-phase clustering) found. Loading data...\n', n);
7492
load(fn);
@@ -86,7 +104,7 @@
86104
% ii) clustering using all the constraints
87105
% see if we already have the data
88106
classif.two_stage = 1;
89-
fn = fullfile(strcat(segmentation_configs.OUTPUT_DIR,'/'), sprintf('clustering_all_constr_%d.mat', n));
107+
fn = fullfile(strcat(segmentation_configs.OUTPUT_DIR,'/'), sprintf('clustering_all_%d_%s.mat', n,a));
90108
if exist(fn ,'file')
91109
fprintf('\nData for %d number of clusters (clustering using all the constraints) found. Loading data...\n', n);
92110
load(fn);
@@ -99,9 +117,6 @@
99117
covering = [covering, res.coverage(feature_length)];
100118
end
101119

102-
% export data
103-
save(fullfile(strcat(segmentation_configs.OUTPUT_DIR,'/'), 'clustering_parameters.mat'), 'res1', 'res2', 'res3');
104-
105120
% remap the classes as to not invalidate mixed clusters
106121
% because we want to compare the clustering errors
107122
res1bare = [];
@@ -113,7 +128,7 @@
113128
res2bare = [res2bare, res2(i).remap_clusters('DiscardMixed', 0)];
114129
end
115130

116-
if length(varargin) > 3
131+
if graph
117132
% Generate the graphs
118133
results_clustering_parameters_graphs(segmentation_configs.OUTPUT_DIR,nc,res1bare,res2bare,res1,res2,res3,covering);
119134

utility/number_of_clusters.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function run_callback(varargin)
214214
max_num = str2num(get(h.text_max,'string'));
215215
step = str2num(get(h.text_step,'string'));
216216
% run clustering
217-
[nc,res1bare,res2bare,res1,res2,res3,covering] = results_clustering_parameters(segmentation_configs,labels_path,min_num,max_num,inc_dec);
217+
[nc,res1bare,res2bare,res1,res2,res3,covering] = results_clustering_parameters(segmentation_configs,labels_path,0,min_num,max_num,inc_dec);
218218
[nc,per_errors1,per_undefined1,coverage] = algorithm_statistics(1,nc,res1bare,res2bare,res1,res2,res3,covering);
219219
% UPDATE THE TABLE
220220
data_old = get(t,'Data');
@@ -257,7 +257,7 @@ function graphs_callback(varargin)
257257
max_num = str2num(get(h.text_max,'string'));
258258
step = str2num(get(h.text_step,'string'));
259259
try
260-
results_clustering_parameters(segmentation_configs,labels_path,min_num,max_num,inc_dec,1);
260+
results_clustering_parameters(segmentation_configs,labels_path,1,min_num,max_num,inc_dec,1);
261261
return
262262
catch
263263
errordlg('Graphs cannot be generated.','Error');

0 commit comments

Comments
 (0)