-
Notifications
You must be signed in to change notification settings - Fork 1
/
getA.m
37 lines (33 loc) · 1.07 KB
/
getA.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
function A = getA( assigned_states )
%getA A is N*4 matrix, the 4 columns save the beginnings of S1, systole, S2 and diastole in the same heart cycle respectively
%% We just assume that the assigned_states cover at least 2 whole heart beat cycle
indx = find(abs(diff(assigned_states))>0); % find the locations with changed states
if assigned_states(1)>0 % for some recordings, there are state zeros at the beginning of assigned_states
switch assigned_states(1)
case 4
K=1;
case 3
K=2;
case 2
K=3;
case 1
K=4;
end
else
switch assigned_states(indx(1)+1)
case 4
K=1;
case 3
K=2;
case 2
K=3;
case 1
K=0;
end
K=K+1;
end
indx2 = indx(K:end);
rem = mod(length(indx2),4);
indx2(end-rem+1:end) = [];
A = reshape(indx2,4,length(indx2)/4)'; % A is N*4 matrix, the 4 columns save the beginnings of S1, systole, S2 and diastole in the same heart cycle respectively
end