Skip to content

Commit 68ee1ab

Browse files
committed
bugs fix
1 parent b385bcd commit 68ee1ab

14 files changed

+128
-44
lines changed

generate/build_folder_tree.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
% BUILD_FOLDER_TREE
33

44
error = 1;
5+
user_ppath = char_project_path(user_ppath);
56
ppath = fullfile(user_ppath,fname);
67

78
% check if project already exists

generate/generate_results.m

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
function generate_results(project_path, name, segmentation_configs, classifications, animals_trajectories_map, b_pressed, groups)
1+
function error = generate_results(project_path, name, segmentation_configs, classifications, animals_trajectories_map, b_pressed, groups)
22
%GENERATE_RESULTS creates results folder tree, forms the final results and
33
%saves them inside the specific folders
4-
4+
5+
error = 1;
56
dir_list = build_results_tree(project_path, b_pressed, name, length(classifications), groups);
7+
8+
% Check if segmentation and classification have the same segments
9+
segs = size(segmentation_configs.FEATURES_VALUES_SEGMENTS,1);
10+
try
11+
segs_ = size(classifications{1}.FEATURES,1);
12+
catch
13+
segs_ = size(classifications.FEATURES,1);
14+
end
15+
if segs ~= segs_
16+
errordlg('Selected classification and segmentation do not match','Error');
17+
return
18+
end
619

720
h = waitbar(0,'Generating results...','Name','Results');
821
% Variables of interest:
@@ -89,11 +102,12 @@ function generate_results(project_path, name, segmentation_configs, classificati
89102
create_average_figure(vals_,vals_grps_,pos_,dir_list{end},total_trials,class_tags);
90103
case 'Probabilities'
91104
fpath = fullfile(dir_list{end},'pvalues_summary.csv');
92-
error = create_average_probs(vals_,class_tags,fpath);
105+
error = create_average_probs(vals_,class_tags,fpath,groups);
93106
if error
94107
errordlg('Could not create summary file');
95108
end
96109
delete(h);
110+
error = 0;
97111
return;
98112
end
99113
if length(groups) > 1;
@@ -104,5 +118,6 @@ function generate_results(project_path, name, segmentation_configs, classificati
104118
end
105119
end
106120
delete(h);
121+
error = 0;
107122
end
108123

gui_classification/gui_similarity.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function gui_similarity_CloseRequestFcn(hObject, eventdata, handles)
5353

5454
function pathstr = uiget(handles)
5555
project_path = get(handles.gui_similarity,'UserData');
56-
project_path = char(project_path{1});
56+
project_path = char_project_path(project_path);
5757
if isempty(project_path)
5858
project_path = matlabroot;
5959
end
@@ -79,7 +79,7 @@ function gui_similarity_CloseRequestFcn(hObject, eventdata, handles)
7979

8080
function refresh_similarity_Callback(hObject, eventdata, handles)
8181
project_path = get(handles.gui_similarity,'UserData');
82-
project_path = char(project_path{1});
82+
project_path = char_project_path(project_path);
8383
f1 = get(handles.field1,'String');
8484
f2 = get(handles.field2,'String');
8585
if isempty(f1) || isempty(f2) || isequal(f1,f2)

gui_classification/test_similarity.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,23 @@
2222
segmentations = {};
2323
k = 1;
2424
files1 = dir(fullfile(f1,'*.mat'));
25+
if isempty(files1)
26+
errordlg('No classification file found','Error');
27+
return
28+
end
2529
load(fullfile(f1,files1(1).name));
30+
if ~exist('classification_configs','var')
31+
errordlg('Wrong specified folder','Error');
32+
return
33+
end
2634
s1 = length(classification_configs.CLASSIFICATION.class_map);
35+
clear classification_configs
2736
files2 = dir(fullfile(f2,'*.mat'));
2837
load(fullfile(f2,files2(1).name));
38+
if ~exist('classification_configs','var')
39+
errordlg('Wrong specified folder','Error');
40+
return
41+
end
2942
s2 = length(classification_configs.CLASSIFICATION.class_map);
3043
%find the segmentations
3144
files = dir(fullfile(pr_folder,'segmentation','*.mat'));
@@ -69,10 +82,18 @@
6982
classifications = {};
7083
k = 1;
7184
load(f1);
85+
if ~exist('classification_configs','var')
86+
errordlg('Wrong file input','Error');
87+
return
88+
end
7289
s1 = length(classification_configs.CLASSIFICATION.class_map);
7390
classifications{1} = classification_configs;
7491
clear classification_configs
7592
load(f2);
93+
if ~exist('classification_configs','var')
94+
errordlg('Wrong file input','Error');
95+
return
96+
end
7697
s2 = length(classification_configs.CLASSIFICATION.class_map);
7798
classifications{2} = classification_configs;
7899
%find the segmentations

gui_main/set_project.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function project_name_CreateFcn(hObject, eventdata, handles)
6363
end
6464

6565
function ok_button_Callback(hObject, eventdata, handles)
66-
path = get(handles.project_path,'String');
66+
ppath = get(handles.project_path,'String');
6767
name = get(handles.project_name,'String');
6868
if isempty(name)
6969
errordlg('Project name not specified','Error');
@@ -72,11 +72,12 @@ function ok_button_Callback(hObject, eventdata, handles)
7272
errordlg('Project path not specified','Error');
7373
return
7474
end
75-
error = build_folder_tree(path, name);
75+
error = build_folder_tree(ppath, name);
7676
if error
7777
return;
7878
else
79-
set(handles.ok_button,'UserData',strcat(path,'/',name));
79+
ppath = fullfile(ppath,name);
80+
set(handles.ok_button,'UserData',ppath);
8081
set_project_CloseRequestFcn(hObject, eventdata, handles);
8182
end
8283
function cancel_button_Callback(hObject, eventdata, handles)

results/demo/demo.m

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,25 @@ function demo(mode,varargin)
2929
%% GUI Mode
3030
% With GUI elements
3131
elseif mode == 1
32-
prompt={'Type 1 or 2 to import the equivalent setup or ''q/Q'' to exit'};
33-
name = 'Published';
34-
defaultans = {'1'};
35-
options.Interpreter = 'tex';
36-
setup = inputdlg(prompt,name,[1 30],defaultans,options);
37-
if isempty(setup)
38-
return
39-
end
40-
setup = str2double(setup{1});
41-
try
42-
if setup ~= 1 && setup ~= 2
43-
warndlg('Input must be 1 or 2 or q/Q.','Error');
44-
return
45-
end
46-
catch
47-
warndlg('Input must be 1 or 2 or q/Q.','Error');
48-
return
49-
end
32+
% prompt={'Type 1 or 2 to import the equivalent setup or ''q/Q'' to exit'};
33+
% name = 'Published';
34+
% defaultans = {'1'};
35+
% options.Interpreter = 'tex';
36+
% setup = inputdlg(prompt,name,[1 30],defaultans,options);
37+
% if isempty(setup)
38+
% return
39+
% end
40+
% setup = str2double(setup{1});
41+
% try
42+
% if setup ~= 1 && setup ~= 2
43+
% warndlg('Input must be 1 or 2 or q/Q.','Error');
44+
% return
45+
% end
46+
% catch
47+
% warndlg('Input must be 1 or 2 or q/Q.','Error');
48+
% return
49+
% end
50+
setup = 1;
5051
demo_gui(setup,user_path);
5152
end
5253
end

results/demo/demo_gui.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ function demo_gui(set,user_path)
108108
end
109109
% Generate the results
110110
for i = 1:length(b_pressed)
111-
generate_results(project_path, name, segmentation_configs, classifications, animals_trajectories_map, b_pressed{i}, groups)
111+
error = generate_results(project_path, name, segmentation_configs, classifications, animals_trajectories_map, b_pressed{i}, groups);
112+
if error
113+
errordlg('Cannot generate results','Error');
114+
return
115+
end
112116
end
113117
end
114118
end

results/gui_generate_results.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
if error
1616
return
1717
end
18+
project_path = char_project_path(project_path);
1819

1920
% Select groups
2021
groups = select_groups(segmentation_configs);
@@ -40,6 +41,8 @@
4041
results_latency_speed_length(segmentation_configs,animals_trajectories_map,1,output_dir);
4142
error = 0;
4243
catch
44+
errordlg('Cannot generate metrics','Error');
45+
error = 1;
4346
end
4447
return
4548
end
@@ -51,13 +54,12 @@
5154
if isempty(class)
5255
return
5356
end
54-
[error,name,classifications] = check_classification(char(project_path),segmentation_configs,class);
57+
[error,name,classifications] = check_classification(project_path,segmentation_configs,class);
5558
if error
5659
return
5760
end
5861

5962
% Generate the results
60-
generate_results(char(project_path), name, segmentation_configs, classifications, animals_trajectories_map, b_pressed, groups);
61-
error = 0;
63+
error = generate_results(project_path, name, segmentation_configs, classifications, animals_trajectories_map, b_pressed, groups);
6264
end
6365

results/one_group_metrics.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ function one_group_metrics(animals_trajectories_map,vars,total_trials,days,trial
2929
data = [data, tmp(:)'];
3030
groups = [groups, repmat(t*2 - 1 + g - 1, 1, length(tmp(:)))];
3131
end
32+
33+
box_plot_data(data, groups, output_dir, names{i});
3234

3335
f = figure;
3436
set(f,'Visible','off');
@@ -68,6 +70,5 @@ function one_group_metrics(animals_trajectories_map,vars,total_trials,days,trial
6870
export_figure(f, output_dir, sprintf('g1_animals_%s', names{i}), Export, ExportStyle);
6971
close(f);
7072
end
71-
box_plot_data(data, groups, output_dir);
7273
end
7374

results/one_group_transition_counts.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
close(f)
7979
end
8080

81+
box_plot_data(data, groups, output_dir, 'transition_counts');
82+
8183
%% Output
8284
varargout{1} = data; % input data (vector)
8385
varargout{2} = groups; % grouping variable (length(x))

0 commit comments

Comments
 (0)