Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0

File: <base>/sources/mlipoff_at_gmail.com/entry2/MakePatientStruct.m (2,150 bytes)
function [allPatientStruct] = MakePatientStruct(inputFileStruct)


%% all variables in text files
% rawInputVariables = {'RecordID', 'Age', 'Gender', 'Height',...
%     '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','TropI',...
%     'TropT','Urine','WBC','Weight'};

%TropI and TropT are never recorded, so will omit them

rawInputVariables = {'RecordID', 'Age', 'Gender', 'Height',...
    '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',...
    'Urine','WBC','Weight'};


for i = 1:length(inputFileStruct)
    
    tempPatientStruct = struct('RecordID',[], 'Age',[], 'Gender',[], 'Height',[],...
    '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',[],...
    'Urine',[],'WBC',[],'Weight',[]);
    
    currentPatientFile = inputFileStruct(i);
  
    
    for j = 2:length(currentPatientFile.data)
        dataType = currentPatientFile.textdata{j,2};
        try
            a = tempPatientStruct.(dataType);
            a = [a; [((datenum(currentPatientFile.textdata(j,1)) - datenum('00:00'))*24), currentPatientFile.data(j-1)]]; 
            tempPatientStruct.(dataType) = a;
        catch
            % do nothing
            
        end
        
    end
    
    allPatientStruct(i) = tempPatientStruct;
    
end


end