|
| 1 | +ppath = 'I:\Documents\MWMGEN\tiago_original\segmentation'; |
| 2 | +mclassification = 'I:\Documents\MWMGEN\tiago_original\Mclassification\class_2322_29476_250_09_10_10_mr0-correct2\merged_1.mat'; |
| 3 | +output_file = 'I:\Documents\labels.csv'; |
| 4 | + |
| 5 | +files = dir(fullfile(ppath,'*.mat')); |
| 6 | +segmentations = cell(1,length(files)); |
| 7 | +for i = 1:length(files) |
| 8 | + load(fullfile(ppath,files(i).name)); |
| 9 | + segmentations{i} = segmentation_configs; |
| 10 | +end |
| 11 | +[output,~] = match_segments(segmentations); |
| 12 | + |
| 13 | +load(mclassification); |
| 14 | +labels = classification_configs.CLASSIFICATION.class_map(output(:,2))'; |
| 15 | +table = [num2cell(output(:,1)), num2cell(labels)]; |
| 16 | +tags = classification_configs.CLASSIFICATION_TAGS; |
| 17 | +for i = 1:size(table,1) |
| 18 | + if table{i,2} > 0 |
| 19 | + table{i,2} = tags{table{i,2}}{1}; |
| 20 | + else |
| 21 | + table{i,1} = []; |
| 22 | + table{i,2} = []; |
| 23 | + end |
| 24 | +end |
| 25 | +table(all(cellfun(@isempty,table),2),:) = []; |
| 26 | + |
| 27 | +VariableNames = cell(1,length(tags)+2); |
| 28 | +VariableNames{1} = 'Segment'; |
| 29 | +for i = 2:length(VariableNames) |
| 30 | + VariableNames{i} = strcat('label',num2str(i-1)); |
| 31 | +end |
| 32 | +table{1,length(VariableNames)} = []; |
| 33 | +table = cell2table(table,'VariableNames',VariableNames); |
| 34 | +writetable(table,output_file,'WriteVariableNames',1); |
| 35 | + |
0 commit comments