@@ -3,15 +3,19 @@ function demo_gui(set,user_path,varargin)
33% and produces the results
44
55 % %Global Options
6- seg_overlap = [0.7 ,0.9 ];
7- seg_length = 250 ;
8- if ~isempty(varargin )
9- if varargin{1 } == - 1
10- seg_overlap = 0.7 ;
6+ if set == 1
7+ seg_overlap = [0.7 ,0.9 ];
8+ seg_length = 250 ;
9+ groups = [1 ,2 ];
10+ if ~isempty(varargin )
11+ if varargin{1 } == - 1
12+ seg_overlap = 0.7 ;
13+ end
1114 end
15+ elseif set == 2
1216 end
17+
1318
14-
1519 user_path = char_project_path(user_path );
1620 h = waitbar(0 ,' Initializing...' );
1721
@@ -24,7 +28,12 @@ function demo_gui(set,user_path,varargin)
2428 if error
2529 return
2630 end
27- project_path = fullfile(user_path ,' demo_original_set_1' );
31+
32+ if set == 1
33+ project_path = fullfile(user_path ,' demo_original_set_1' );
34+ elseif set == 2
35+ project_path = fullfile(user_path ,' demo_original_set_2' );
36+ end
2837 waitbar(1 / 2 );
2938
3039 %% Copy the settings mat files (skip gui_project.m)
@@ -67,41 +76,37 @@ function demo_gui(set,user_path,varargin)
6776 end
6877
6978 %% Labelling
70- files = { ' labels_1301_250_07-tiago.csv ' , ' labels_1657_250_09-tiago .csv' } ;
71- seg_name = { ' segmentation_configs_10388_250_07.mat ' ,' segmentation_configs_29476_250_09 .mat' } ;
79+ files = dir(fullfile( datapath , ' * .csv' )) ;
80+ seg_name = dir(fullfile( project_path , ' segmentation ' ,' * .mat' )) ;
7281 for i = 1 : length(seg_overlap )
73- % check if everything is ok
74- if ~exist(fullfile(datapath ,files{i }),' file' ) || ~exist(fullfile(project_path ,' segmentation' ,seg_name{i }),' file' )
75- errordlg(' Cannot create labels files' ,' Error' );
76- return
77- end
7882 % copy the csv files from the datapath
79- labels_path = fullfile(datapath ,files{ i } );
83+ labels_path = fullfile(datapath ,files( i ).name );
8084 copyfile(labels_path ,fullfile(project_path ,' labels' ));
8185 % the labels are now inside the project path
82- labels_path = fullfile(project_path ,' labels' ,files{ i } );
86+ labels_path = fullfile(project_path ,' labels' ,files( i ).name );
8387 % load the segmentation and generate the labels mat file
84- load(fullfile(project_path ,' segmentation' ,seg_name{ i } ));
88+ load(fullfile(project_path ,' segmentation' ,seg_name( i ).name ));
8589 generate_mat_from_labels(labels_path ,segmentation_configs );
8690 clear segmentation_configs
8791 end
8892
8993 %% Classification
90- lab_name = { ' labels_1301_250_07-tiago.mat ' ,' labels_1657_250_09-tiago .mat' } ;
94+ lab_name = dir(fullfile( project_path , ' labels ' ,' * .mat' )) ;
9195 for i = 1 : length(seg_overlap )
9296 % check if everything is ok
93- if ~exist(fullfile(project_path ,' labels' ,lab_name{ i } ),' file' )
97+ if ~exist(fullfile(project_path ,' labels' ,lab_name( i ).name ),' file' )
9498 errordlg(' Cannot create classifiers' ,' Error' );
9599 return
96100 end
97- default_classification(project_path ,seg_name{ i } ,lab_name{ i } );
98- end
101+ default_classification(project_path ,seg_name( i ).name ,lab_name( i ).name );
102+ end
99103
100- %% Results
101- groups = [1 ,2 ];
102- load(fullfile(project_path ,' segmentation' ,seg_name{1 }));
104+ %% Animal Trajectories Map
105+ load(fullfile(project_path ,' segmentation' ,seg_name(1 ).name));
103106 [exit , animals_trajectories_map ] = trajectories_map(segmentation_configs ,groups ,' Friedman' ,set );
104107
108+ %% Results
109+
105110 % METRICS
106111 str = num2str(groups );
107112 str = regexprep(str ,' [^\w'' ]' ,' ' ); % remove gaps
@@ -118,24 +123,12 @@ function demo_gui(set,user_path,varargin)
118123
119124 % STRATEGIES - TRANSITIONS - PROBABILITIES - STATISTICS
120125 b_pressed = {' Strategies' ,' Transitions' ,' Probabilities' };
121- class = { ' class_1301_10388_250_07_10_10_mr0-tiago ' , ' class_1657_29476_250_09_10_10_mr0-tiago ' } ;
126+ class = dir(fullfile( project_path , ' Mclassification ' )) ;
122127
123128 for j = 1 : length(seg_overlap )
124-
125- % Check if everything is ok
126- if ~exist(fullfile(project_path ,' Mclassification' ,class{j }),' file' )
127- errordlg(' Check fail for results: strategies, transitions and probabilities' ,' Error' );
128- return
129- end
130-
131- % Statistics
132- [error ,~ ,~ ] = class_statistics(project_path , class{j });
133- if error
134- errordlg(' Error: statistics generation' ,' Error' );
135- end
136-
129+
137130 % Check the classification
138- [error ,name ,classifications ] = check_classification(project_path ,segmentation_configs ,class{ j } );
131+ [error ,name ,classifications ] = check_classification(project_path ,segmentation_configs ,class( 2 + j ).name );
139132 if error
140133 errordlg(' Classification check failed' ,' Error' );
141134 return
@@ -149,21 +142,25 @@ function demo_gui(set,user_path,varargin)
149142 return
150143 end
151144 end
145+
146+ % Statistics
147+ [error ,~ ,~ ] = class_statistics(project_path , class(2 + j ).name);
148+ if error
149+ errordlg(' Error: statistics generation' ,' Error' );
150+ end
152151 end
153152
154153 %% Labelling Quality
155- files = {' labels_1301_250_07-tiago.mat' ,' labels_1657_250_09-tiago.mat' };
156154 for i = 1 : length(seg_overlap )
157- load(fullfile(project_path ,' segmentation' ,seg_name{i }));
158- load(fullfile(project_path ,' labels' ,files{i }));
159-
155+ load(fullfile(project_path ,' segmentation' ,seg_name(i ).name));
156+
160157 p = strsplit(files{i },' .mat' );
161158 p = p{1 };
162159 output_path = char(fullfile(project_path ,' labels' ,strcat(p ,' _check' )));
163160 if ~exist(output_path ,' dir' )
164161 mkdir(output_path );
165162 end
166- [nc ,res1bare ,res2bare ,res1 ,res2 ,res3 ,covering ] = results_clustering_parameters(segmentation_configs ,labels ,0 ,output_path ,10 ,100 ,1 );
163+ [nc ,res1bare ,res2bare ,res1 ,res2 ,res3 ,covering ] = results_clustering_parameters(segmentation_configs ,fullfile( project_path , ' labels' ,lab_name( i ).name) ,0 ,output_path ,10 ,100 ,1 );
167164 output_path = char(fullfile(project_path ,' results' ,strcat(p ,' _cross_validation' )));
168165 if exist(output_path ,' dir' );
169166 rmdir(output_path ,' s' );
0 commit comments