-
Notifications
You must be signed in to change notification settings - Fork 47
/
SAH.m
49 lines (33 loc) · 1.21 KB
/
SAH.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [ temp ] = SAH(temp, vitalslab_hold)
% Matthieu Komorowski - Imperial College London 2017
% will copy a value in the rows below if the missing values are within the
% hold period for this variable (e.g. 48h for weight, 2h for HR...)
% vitalslab_hold = 2x55 cell (with row1 = strings of names ; row 2 = hold time)
h = waitbar(0,'Initializing waitbar...');
hold=table2array(cell2table(vitalslab_hold(2,:)));
nrow=size(temp,1);
ncol=size(temp,2);
lastcharttime=zeros(1,ncol);
lastvalue=zeros(1,ncol);
oldstayid=temp(1,2);
for i=4:ncol
waitbar(i/ncol,h,i/ncol*100)
for j=1:nrow
if oldstayid~=temp(j,2)
lastcharttime=zeros(1,ncol);
lastvalue=zeros(1,ncol);
oldstayid=temp(j,2);
end
if isnan(temp(j,i))==0
lastcharttime(i)=temp(j,3);
lastvalue(i)=temp(j,i);
end
if j>1
if isnan(temp(j,i)) && temp(j,2)==oldstayid && (temp(j,3)-lastcharttime(i))<=hold(i-3)*3600 %note : hold has 53 cols, temp has 55
temp(j,i)=lastvalue(i);
end
end
end
end
close(h);
end