function [prob,died]=physionet2012(tm,category,val) % % Submission #1 for the PhysioNet 2012 Challenge, Phase 1. % % Written by Alexandros Pantelopoulos, 23/04/2012 % % % Inputs: % ------- % tm - (Nx1 Cell Array) Cell array containing time of measurement % category- (Nx1 Cell Array) Cell array containing type (category) % measurement % value - (Nx1 Cell Array) Cell array containing value of measurement % % % Outputs: % -------- % prob - (Scalar) Probability value of the patient dying in the % hospital. % died - (Logical) Binary classification if the patient is going to % die in the hospital (1 - Died, 0 - Survived) % % % Requirements: % ------------- % mat file 'nnet.mat' % % % Description: % ------------ % My submission calculates the in-hospital death probability using several % simple statistical features extracted from the timeseries data and a % neural network classifier. In order to run it requires the mat file % 'nnet.mat' to be in the same folder. This mat file contains the neural % network object created by MATLAB after training the classifier. It calls % the basic MATLAB function 'sim' in order to calculate the probability of % death in the hospital. In the case this probability is bigger than 0.5, % then the prediction is made that the patient will die in the hospital. % In this version the timestamps of the measurements are not utilized in % the classifier. Finally this function normalizes all features based on % the mean and stdev values calculated from the training set. % % Load the neural network object & the saved mean & stdev values load('nnet.mat') % Basic attribute descriptions attributes = {'RecordID','Age','Gender','Height','Weight','Albumin','ALP','ALT','AST','Bilirubin','BUN','Cholesterol',... 'Creatinine','DiasABP','FiO2','GCS','Glucose','HCO3','HCT','HR','K','Lactate','Mg','MAP','MechVent','Na','NIDiasABP',... 'NIMAP','NISysABP','PaCO2','PaO2','pH','Platelets','RespRate','SaO2','SysABP','Temp','TroponinI','TroponinT','Urine','WBC'}; numAtributes = length(attributes); % feature array initialization numStaticF = 4; numDynamicF = 36; numStatsPerA = 5; numFeatures = numDynamicF*numStatsPerA + numStaticF; features = zeros(numFeatures,1); % Extract all the attributes in individual cells for j = 1:numAtributes eval([attributes{j} ' = val(strcmp(category,attributes(j)));']) end % Extract all the features from the existing attributes ctr = 0; % Age j = 2; eval(['temp = ' attributes{j} ';']); if (length(temp)>1) ctr = ctr + 1; features(ctr) = max(temp); else ctr = ctr + 1; features(ctr) = temp; if (temp == -1) % missing value features(ctr) = MEAN(ctr); end end % Gender and Height for j = 3:4 ctr = ctr + 1; eval(['temp = ' attributes{j} ';']); features(ctr) = temp; if (temp == -1) % missing value features(ctr) = MEAN(ctr); end end % MechVent j = 25; eval(['temp = ' attributes{j} ';']); ctr = ctr + 1; if (isempty(temp)) features(ctr) = 0; else features(ctr) = max(temp); end % Grab the rest of he features from the remaining attributes for j = 5:numAtributes if (strcmp(attributes{j},'MechVent') == 0) temp = 0; eval(['temp = ' attributes{j} ';']); if (isempty(temp))||(sum(temp == -1)>0) % missing value ctr = ctr + 1; features(ctr) = MEAN(ctr); ctr = ctr + 1; features(ctr) = MEAN(ctr); ctr = ctr + 1; features(ctr) = MEAN(ctr); ctr = ctr + 1; features(ctr) = MEAN(ctr); ctr = ctr + 1; features(ctr) = MEAN(ctr); else ctr = ctr + 1; eval(['features(ctr) = mean(' attributes{j} ');']); ctr = ctr + 1; eval(['features(ctr) = min(' attributes{j} ');']); ctr = ctr + 1; eval(['features(ctr) = max(' attributes{j} ');']); ctr = ctr + 1; eval(['features(ctr) = sqrt(var(' attributes{j} '));']); ctr = ctr + 1; eval(['features(ctr) = sum(diff(' attributes{j} '));']); end end end % Normalize the features features = (features-MEAN)./STDEV; % Calculate the probability of in-hospital death prob = sim(nnet,features); % Calculate the binary prediction of in-hospital death TH = 0.5; died = prob>=TH; % Scale the prob value (emprically calculated based on the training set prob = prob.^2;