Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0
(2,746 bytes)
function [risk,prediction]=physionet2012(time,param,value)
% [risk,prediction]=physionet2012(time,param,value)
%
% time - (Nx1 Cell Array) Cell array containing time of measurement
% param - (Nx1 Cell Array) Cell array containing type (category) of
% measurement
% value - (Nx1 Cell Array) Cell array containing value of measurement
%
%
% risk - (Scalar) estimate of the risk of the patient dying in hospital
% prediction - (Logical)Binary classification if the patient is going to die
% in the hospital (1 - Died, 0 - Survived)
%
% Example:
% [risk,prediction]=physionet2012(time,param,value)
%
% Written by Chih-Chun Chia, 2012
%
% Version 1.1
%
%TH=0.265; %Threshold for classifying the patient as non-survivor
load('S.mat');
tm = time;
category = param;
val = value;
AllVars = {{'Age'},{'Height', 'Weight'}, {'Albumin'},{'ALP'}, {'ALT'}, {'AST'}, {'Bilirubin'},...
{'BUN'},{'Creatinine'}, {'DiasABP'},{'FiO2'},{'GCS'},...
{'Glucose'},{'HCO3'},{'HCT'},{'HR'},{'K'},{'Lactate'}, {'Mg'}, {'MAP'},...
{'Na'},{'NIDiasABP'},{'NIMAP'},{'NISysABP'},{'PaCO2'},...
{'PaO2'},{'pH'},{'Platelets'},{'RespRate','MechVent'},{'SaO2'},{'SysABP'},{'Temp'},...
{'Urine'},{'WBC'}};
UsefulVars = {{'Age'},{'Height', 'Weight'},{'HR'}, {'Bilirubin'},{'BUN'},{'pH'},...
{'Urine'},{'WBC'},{'Platelets'},{'HCT'},{'Creatinine'},{'Na'},{'K'},{'HCO3'},...
{'RespRate','MechVent'},{'Temp'},{'GCS'},{'FiO2'},{'PaO2'},...
{'DiasABP'},{'MAP'},{'NIDiasABP'},{'NIMAP'},{'NISysABP'},{'SysABP'}};
AllVars = UsefulVars;
features = zeros(1,length(AllVars));
for s=1:length(AllVars)
%Get data for the selected category only (If more than one name exist for the variables, merge data)
saps_var=AllVars{s};
sig_ind= val.*0;
for i=1:length(saps_var)
sig_ind=sig_ind | strcmp(saps_var(i),category);
end
tmp_data=val(sig_ind);
if(strcmp(saps_var{1},'RespRate'))
tmp_category=category(sig_ind);
mech_vent_ind=find(strcmp(saps_var(2),tmp_category)==1);
if(~isempty(mech_vent_ind) && any(mech_vent_ind))
tmp_data=49;
end
end
if(strcmp(saps_var{1},'Height'))
if (tmp_data(2) == -1 || tmp_data(1) == -1)
tmp_data = NaN;
else
tmp_data = tmp_data(2) / (tmp_data(1)/100)^2;
end
end
features(s) = mean(tmp_data);
if (isnan(features(s)))
features(s) = MeanFeat(s);
end
end
%%%%%%%%%%%%%%%%%%%%%%%
% SVM %
%%%%%%%%%%%%%%%%%%%%%%%
addpath('libsvm-3.12/matlab');
addpath('kernel_calibration_test');
features = (features - Feature_Min)*Feature_ScaleRatio;
[pred, accu, probs] = svmpredict(zeros(1), features, S);
risk = kernel_calibrate(probs', dec_value', IHD', besth);
prediction=(risk>TH);