Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0
(2,282 bytes)
function [risk,prediction]=physionet2012(tm,category,val)
truncated=0;
inputs={'tm','category','val','truncated'};
SAPS={{'Age'},{'HR'},{'SysABP'},{'Temp'},...
{'RespRate'},{'Urine'},{'BUN'},{'HCT'},...
{'WBC'},{'Glucose'},{'K'},{'Na'},{'HCO3'},{'GCS'},...
{'DiasABP'},{'Mg'},...
{'PaCO2'},{'PaO2'},{'pH'},{'SaO2'},...
};
tm=cell2mat(tm);
fr_data=find(str2num(tm(:,1:2))<48);
val=val(fr_data);
tm=str2num(tm(:,1:2));
tm=tm(fr_data);
category=category(fr_data);
count=0;
for s=1:length(SAPS)
saps_var=SAPS{s};
sig_ind= val.*0;
for ii=1:length(saps_var)
sig_ind=sig_ind | strcmp(saps_var(ii),category);
end
tmp_data=val(sig_ind);
tmp_time=tm(sig_ind);
mn=(tmp_data);
eval(['temp_data =' saps_var{1} '(mn);'])
[B, IX] = sort(tmp_time, 1);
parameter(: , 1) = B;
parameter(: , 2) = temp_data(IX(: , 1));
temp=NaN*ones(1,48);
for ii=1:48
temp(1,ii) = mean(parameter(find( parameter(:,1)==(ii-1)),2));
end
tmp=NaN*ones(1,48);
for ii=1:48
tmp(1,ii) = mean(parameter(find( parameter(:,1)==(ii-1)),1));
end
x=find(isnan(temp)~=1);
t=tmp(find(isnan(temp)~=1));
y=temp(find(isnan(temp)~=1));
xi=find(isnan(temp)==1);
if length(t)==1
temp=y*ones(1,48);
tmp=0:47;
elseif length(t)==0
count=count+1;
temp=0*ones(1,48);
tmp=0:47;
else
new_tmp = interp1(x,t,xi,'linear','extrap');
new_temp = interp1(x,y,xi,'linear');
temp(xi)=new_temp;
tmp(xi)=new_tmp;
end
x=find(isnan(temp)~=1);
t=tmp(find(isnan(temp)~=1));
y=temp(find(isnan(temp)~=1));
xi=find(isnan(temp)==1);
temp(xi(find(xi<x(1))))=temp(x(1));
temp(xi(find(xi>x(end))))=temp(x(end));
clear x t y xi
tempdata(s,:) = temp;
tmptime(s,:) = tmp;
clear temp1 temp tmp
clear parameter
end
param=sum(tempdata);
time=sum(tmptime);
clear tempdata
clear tmptime
%%
load net3
load minp
load maxp
param = 2*(param'-minp)./(maxp-minp) - 1;
CC = sim(net3 , param);
CC = CC';
[mx , ind] = max (CC);
prediction = ind-1;
risk = CC(: , 2);
if risk >0.5
risk=((.99-.5)/(1-.5)).*(risk-.5)+.5;
elseif risk<.5
risk=((.5-.01)/(.5-0)).*(risk)+.01;
end