Switch to unified view

a b/deep_learning_multiscale_lstm_fig2.m
1
%% plot performance curves of individual cpc groups
2
clear
3
time_step = 6;
4
time_range = 12:time_step:96;
5
neuron_num_short = 30:10:100;
6
neuron_num_long = 30:10:40;
7
load(['RF_clinical_regardless_time']);
8
prob_pts_clinical = prob_pts;
9
a = mean(prob_pts_clinical');
10
prob_pts_clinical = repmat(a',1,length(time_range));
11
load(['\long_limitSeq_8_bilstm_two_neurons_',num2str(neuron_num_long(2)),'_epoch_30.mat']);
12
prob_pts_long = prob_pts;
13
load(['\short_bilstm_two_neurons_',num2str(neuron_num_short(3)),'_epoch_15.mat']);
14
prob_pts_short = prob_pts;
15
16
prob_pts = (prob_pts_clinical+prob_pts_long+prob_pts_short)/3;
17
18
pred_prob_all = nan(size(prob_pts));
19
for i = 1:size(pred_prob_all,1)
20
for j = 1:size(pred_prob_all,2)
21
    if ~isnan(prob_pts(i,j))
22
        pred_prob_all(i,j) = nanmean(prob_pts(i,1:j));
23
    end
24
end
25
end
26
labels = nanmean(label_pts');
27
28
num_pts = length(labels);
29
index_tmp = find(labels==2);
30
feature_good = pred_prob_all(labels==2,:);
31
feature_mean = nanmean(feature_good');
32
[a,index_good] = sort(feature_mean);
33
index_good = index_tmp(index_good);
34
feature_good = pred_prob_all(index_good,:);
35
unique_names_good = unique_names(index_good);
36
37
index_tmp = find(labels==1);
38
feature_bad = pred_prob_all(labels==1,:);
39
feature_mean = nanmean(feature_bad');
40
[a,index_bad]=sort(feature_mean);
41
index_bad = index_tmp(index_bad);
42
feature_bad = pred_prob_all(index_bad,:);
43
unique_names_bad = unique_names(index_bad);
44
45
unique_names1 = [unique_names_good;unique_names_bad];
46
feature_all1 = [feature_good;feature_bad];
47
48
figure,
49
% mn = prctile(feature_all1(:),0); mx = prctile(feature_all1(:),100);% 90
50
imagesc(feature_all1(:,1:11));
51
colormap(flipud(cold));
52
% set(gca, 'YTick', 371, 'YTickLabel', 'poor')
53
xlabel('Hours After Cardiac Arrest');
54
title('Outcome Prediction Probability over Time');
55
colorbar;
56
set(gca, 'Xtick',1:11,'Xticklabel',num2cell(time_range(1:11)))
57
% set(gca, 'YTick', (1/num_pts:1/num_pts:1)*num_pts, 'YTickLabel', unique_names1)
58
59
load('\all_features.mat','cpc_scores','unique_names');
60
cpc_labels = zeros(size(labels));
61
62
for i = 1:length(labels)
63
    indx = ~cellfun(@isempty, strfind(unique_names,unique_names1{i}));
64
    indx = find(indx==1);
65
    indx = indx(1);
66
    cpc_labels(i) = cpc_scores(indx);
67
end
68
figure,
69
tmp = feature_all1(cpc_labels==1,1:11);
70
[h1,p] = boundedline(1:11, nanmean(tmp), nanstd(tmp)./sum(~isnan(tmp)),'-ro','alpha');% --b* --ro --g+ --cs
71
% h1 = outlinebounds(l,p);
72
hold on,
73
tmp = feature_all1(cpc_labels==2,1:11);
74
[h2,p] = boundedline(1:11, nanmean(tmp), nanstd(tmp)./sum(~isnan(tmp)),'-b*','alpha');% --b* --ro --g+ --cs
75
% h2 = outlinebounds(l,p);
76
hold on,
77
tmp = feature_all1(cpc_labels==3,1:11);
78
[h3,p] = boundedline(1:11, nanmean(tmp), nanstd(tmp)./sum(~isnan(tmp)),'-g+','alpha');% --b* --ro --g+ --cs
79
% h3 = outlinebounds(l,p);
80
hold on,
81
tmp = feature_all1(cpc_labels==4,1:11);
82
if ~isempty(find(sum(~isnan(tmp))==1))
83
    tmp(:,find(sum(~isnan(tmp))==1)) = nan;
84
end
85
[h4,p] = boundedline(1:11, nanmean(tmp), nanstd(tmp)./sum(~isnan(tmp)),'-cs','alpha');% --b* --ro --g+ --cs --md
86
% h4 = outlinebounds(l,p);
87
hold on,
88
tmp = feature_all1(cpc_labels==5,1:11);
89
[h5,p] = boundedline(1:11, nanmean(tmp), nanstd(tmp)./sum(~isnan(tmp)),'-k^','alpha');% --b* --ro --g+ --cs
90
% h5 = outlinebounds(l,p);
91
set(gca, 'XTick', 1:length(time_range(1:11)), 'XTickLabel', strsplit(num2str(time_range(1:11))));
92
xlabel('Hours After Cardiac Arrest');
93
ylabel('Mean Outcome Prediction Probability');
94
xlim([0 12]);
95
title('Mean Outcome Prediction Probability at Different Time Intervals')
96
legend([h5,h4,h3,h2,h1],'CPC =5','CPC = 4','CPC = 3','CPC = 2','CPC = 1');
97
legend boxoff