File size: 3,537 Bytes
72417f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | % Script to take the dice score values produced by
% UWphoto_script_generateDiceScores and plot them in a scatter plot for
% ease of comparison.
%% set up directories
PHOTO_RECON_HOME=getenv('PHOTO_RECON_HOME');
path_label_table = fullfile(PHOTO_RECON_HOME,'code','data',...
'UWphoto_samsegusedlabels.csv');
top_scores_dir = fullfile(PHOTO_RECON_HOME,'figures','diceScores');
%% check for exclusion criteria
removalLevel = 4;
if exist(fullfile(figuresDir,'AdjustedCaseStats.mat'),'file')
load(fullfile(figuresDir,'AdjustedCaseStats.mat'),'segVolumeInfo')
removalFlag = (0<[segVolumeInfo.removaltype]) &...
([segVolumeInfo.removaltype] <=removalLevel);
removal_cases = {segVolumeInfo(removalFlag).caseID};
else
removal_cases = {};
end
output_dir = fullfile(top_scores_dir,['removalLevel_',num2str(removalLevel)]);
if ~exist(output_dir,'dir')
mkdir(output_dir)
end
%% find the dice files
dlist_soft_scores = dir(fullfile(top_scores_dir,'*soft_dice.mat'));
dlist_hard_scores = dir(fullfile(top_scores_dir,'*hard_dice.mat'));
%% read in values
full_soft_dice = [];
full_hard_dice = [];
for il=1:length(dlist_soft_scores)
load(fullfile(dlist_soft_scores(il).folder,dlist_soft_scores(il).name),...
'dice_scores_merge')
if contains(dlist_soft_scores(il).name,removal_cases)
continue
end
full_soft_dice=[full_soft_dice,dice_scores_merge]; %#ok<AGROW>
end
for il=1:length(dlist_hard_scores)
load(fullfile(dlist_hard_scores(il).folder,dlist_hard_scores(il).name),...
'dice_scores_merge')
if contains(dlist_hard_scores(il).name,removal_cases)
continue
end
full_hard_dice=[full_hard_dice,dice_scores_merge]; %#ok<AGROW>
end
table_labels = readtable(path_label_table);
%% setup plot
label_present_soft = any(~isnan(full_soft_dice),2)& any(full_soft_dice>0,2);
label_present_hard = any(~isnan(full_hard_dice),2)& any(full_hard_dice>0,2);
label_values_soft = find(label_present_soft);
label_values_hard = find(label_present_hard);
soft_xticks = table_labels.Labels_present2(...
ismember(table_labels.Labels_present1,label_values_soft));
for il=1:length(soft_xticks)
soft_xticks{il}=soft_xticks{il}(6:end);
end
hard_xticks = table_labels.Labels_present2(...
ismember(table_labels.Labels_present1,label_values_hard));
for il=1:length(hard_xticks)
hard_xticks{il}=hard_xticks{il}(6:end);
end
%% make plots
% plotx =repmat((1:length(soft_xticks))',[1,size(full_soft_dice,2)]);
ploty =full_soft_dice(label_present_soft,:);
h_soft = figure;
boxplot(ploty',soft_xticks)
xtickangle(60)
set(h_soft,'Position',[760,155,720,720])
xlabel('Label')
ylabel('Dice score')
title('Soft reconstruction Dice scores')
ylim([0 1])
drawnow
pause(2)
plotx =repmat((1:length(hard_xticks))',[1,size(full_hard_dice,2)]);
ploty =full_hard_dice(label_present_hard,:);
h_hard = figure;
boxplot(ploty',soft_xticks)
set(gca,'xtick',1:length(hard_xticks),'xticklabel',hard_xticks)
xtickangle(60)
set(h_hard,'Position',[760,155,720,720])
xlabel('Label')
ylabel('Dice score')
title('Hard reconstruction Dice scores')
ylim([0 1])
drawnow
pause(2)
%% save plots
saveas(h_soft,fullfile(output_dir,'soft_diceScores_combined_box.fig'))
saveas(h_soft,fullfile(output_dir,'soft_diceScores_combined_box.png'))
saveas(h_hard,fullfile(output_dir,'hard_diceScores_combined_box.fig'))
saveas(h_hard,fullfile(output_dir,'hard_diceScores_combined_box.png'))
|