Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0
(2,287 bytes)
function [ c ] = pnHighestValue(data,featStr)
%PNHIGHESTVALUE Highest measurement recorded
% [ c ] = pnHighestValue(data) calculates the first measurement recorded.
% For each feature, the above names are used as suffixes in the output
% feature label, i.e. for Albumin, the function would output
% AlbuminHighest, etc.
%
% [ c ] = pnHighestValue(data, featStr) allows specification of a subset
% of features to extract granularity values for. featStr should be a
% string if features are extracted from a single field, or a cell array
% of strings for feature extraction from multiple fields.
%
% Inputs:
% data - Cell array of data.
% Column 1 - Subject IDs
% Column 2 - Time stamp vectors for each subject
% Column 3 - Feature name vectors for each subject
% Column 4 - Data value vectors for each subject
%
% featStr - String of single field to extract features from OR cell
% array of strings of multiple fields to extract features from.
%
% Outputs:
% c - A cell of the same size as data in standard format (above)
% There exist multiple feature labels in Column 3.
%
%
% Example
% bpath = './set-a/';
% data = pnLoadTextFilesCell(bpath);
% c = pnHighestValue(data(1,:)) %
% See also PNGENERATEFEATURES
% References:
% Physionet Challenge 2012
% Copyright 2012 Alistair Johnson
% $LastChangedBy: alistair $
% $LastChangedDate: 2012-06-04 15:40:13 -0400 (Mon, 04 Jun 2012) $
% $Revision: 28 $
% Originally written on GLNXA64 by Alistair Johnson, 11-May-2012 09:12:20
% Contact: alistairewj@gmail.com
N = size(data,1);
c = cell(N,4);
c(:,1) = data(:,1);
genFeatStr = 'Highest';
%=== Lowest, get index of elements with recordings
idxExist = cellfun(@(x) ~isempty(x), data(:,2));
[fieldMax,idxMax] = cellfun(@max, data(idxExist,4),'UniformOutput',false);
%=== Feature labels
featStrCell = {strcat(featStr,genFeatStr)};
c(idxExist,3) = cellfun(@(x) [x;featStrCell],...
c(idxExist,3), 'UniformOutput',false);
%=== Time stamps
c(idxExist,2) = cellfun(@(x,y,z) [x;y(z)],...
c(idxExist,2), data(idxExist,2), idxMax, 'UniformOutput',false);
%=== Calculate features, min/max/avg/std, output to cell in ONE LINE!
c(idxExist,4) = cellfun(@(x,y) [x;y],...
c(idxExist,4), fieldMax, 'UniformOutput', false);
end