@@ -91,8 +91,27 @@ function results_strategies_transition_prob(segmentation_configs,classification_
9191 if length(groups ) ~= 1
9292 trans_prob1 = trans_prob1 ./ repmat(sum(trans_prob1 , 2 ), 1 , nc );
9393 trans_prob2 = trans_prob2 ./ repmat(sum(trans_prob2 , 2 ), 1 , nc );
94+ % NaN values
95+ for i = 1 : size(trans_prob1 ,1 )
96+ for j = 1 : size(trans_prob1 ,2 )
97+ if isnan(trans_prob1 )
98+ trans_prob1(i ,j ) = 0 ;
99+ end
100+ if isnan(trans_prob2 )
101+ trans_prob2(i ,j ) = 0 ;
102+ end
103+ end
104+ end
94105 else
95106 trans_prob1 = trans_prob1 ./ repmat(sum(trans_prob1 , 2 ), 1 , nc );
107+ % NaN values
108+ for i = 1 : size(trans_prob1 ,1 )
109+ for j = 1 : size(trans_prob1 ,2 )
110+ if isnan(trans_prob1 )
111+ trans_prob1(i ,j ) = 0 ;
112+ end
113+ end
114+ end
96115 end
97116
98117 for i = 1 : segments_classification .nclasses
@@ -108,5 +127,32 @@ function results_strategies_transition_prob(segmentation_configs,classification_
108127 save(fn , ' trans_prob1' );
109128 trans_prob1
110129 end
130+
131+ % save to txt
132+ fn2 = fullfile(strcat(segmentation_configs .OUTPUT_DIR ,' /' ), ' transition_probabilities.txt' );
133+ fileID = fopen(fn2 ,' wt' );
134+ for i = 1 : segments_classification .nclasses
135+ fprintf(fileID ,' %d . %s\n ' , i , segments_classification.classes{1 ,i }{1 ,2 });
136+ end
137+
138+ fprintf(fileID , ' \n ' );
139+ if length(groups ) ~= 1
140+ for i= 1 : size(trans_prob1 ,1 )
141+ fprintf(fileID , ' %6.4f ' , trans_prob1(i ,: ));
142+ fprintf(fileID , ' \n ' );
143+ end
144+ fprintf(fileID , ' \n ' );
145+ for i= 1 : size(trans_prob2 ,1 )
146+ fprintf(fileID , ' %6.4f ' , trans_prob2(i ,: ));
147+ fprintf(fileID , ' \n ' );
148+ end
149+ else
150+ for i= 1 : size(trans_prob1 ,1 )
151+ fprintf(fileID , ' %6.4f ' , trans_prob1(i ,: ));
152+ fprintf(fileID , ' \n ' );
153+ end
154+ end
155+ fclose(fileID );
156+
111157end
112158
0 commit comments