Pre-processing of RR
n
series
A. Median filter
A median filter is implemented by windowing the acquired data, ranking the samples in the window, and outputting the median of the sorted samples. Considering a RR interval (RR
n
) sequence x
n
, as shown in Figure 1(a), the output y
n
of this nonlinear filter is given by,
(1)
where the window is of a fixed width 2w+1. From the perspective of signal processing, the time delay of the median filter is w. A window size of 17 is used herein, with a delay of 8 samples. The introduction of a median filter brings about two advantages: (i) the suppression of unwanted outliers, which are mostly caused by erroneously detected (or missed) R-wave peaks; (ii) to preserve sharp edges (i.e., onsets and terminations of AF episodes) without extensively blurring the context.
B. Integer filter for low scale reference
Subsequently, we filter the output y
n
of median filter with a low-pass filter of the form
(2)
where, the gain is G a i n 1=16=24, and the intrinsic delay of H
l
(z) is 7.5 samples. This low-pass filter is applied to smooth y
n
resulting from the previous median filtering. Another benefit of the low-pass filter is the removal of fluctuations possibly caused by Respiratory Sinus Arrhythmia (RSA) phenomena around the current sample from acquisition. Let xl
n
be the output of this filter, as illustrated in Figure 1(b).
C. Integer filter for high scale reference
Another low-pass filter H
h
(z) is then applied to the resultant xl
n
of the previous low-pass filter H
l
(z),
(3)
where, the gain is G a i n 2=2048=211, and the relevant delay of H
h
(z) is 47 samples. This low-pass filter is introduced to generate a reference RR sequence of a larger scale, which needs to be exploited in the definition of symbolic series as explained in the following subsection. The resulting output denoted by xh
n
is shown in Figure 1(c).
As we have seen, the time delays of x
n
and xl
n
are −62.5 and −47 samples with respect to xh
n
, respectively. To ensure synchronization of the filtered data, let and denote the corresponding time-delay corrected sequences of x
n
and xl
n
, respectively. Then, can be defined as the difference in time delay, seen in Figure 1(d).
Symbolic dynamics of Δ RR
n
The purpose of employing symbolic dynamics is to describe the dynamic behavior of Δ RR
n
with respect to xh
n
. Symbolic dynamics encodes the information as a variation of RR
n
to a series with fewer symbols, with each symbol representing an instantaneous state. The implemented thresholds can be defined as: t h r e 1=xh
n
×2−4 (with t h r e 1=xh
n
>>4), t h r e 2=xh
n
×2−3 (with t h r e 2=xh
n
>>3), t h r e 3=t h r e 1+t h r e 2, t h r e 4=xh
n
×2−2 (with t h r e 4=xh
n
>>2) and t h r e 5=t h r e 4+t h r e 1. The mapping function of the symbol transform can therefore be defined as,
(4)
The raw RR sequence x
n
is then quantified into symbol sequence sy
n
with specific symbols from the predefined “alphabet” in Eq. (4) (i.e., 0 to 9). Recalling Figure 1(a)-(d) and scanning the distribution of calculated symbols in Figure 1(e), we confirm that most of normal beats are defined as zero symbols, and possible abnormal beats (arrhythmias, e.g., AF) are defined as non-zero symbols by the transform Eq. (4).
To facilitate the analysis of sy
n
, the widely used 3-symbol template (i.e., a word consists of 3 successive symbols) is applied to examine entropic properties. The word value can then be calculated by a novel operator as defined below,
(5)
where, sy
n−2×28 and sy
n−1×24 are implemented with sy
n−2<<8 and sy
n−1<<4, and 0≤wv
n
≤2457. Figure 2 briefly elucidates the transformation of the symbol sequence with the template and the corresponding word, while Figure 1(f) depicts the word sequence of sy
n
shown in Figure 1(e).
Shannon entropy
Shannon entropy (SE) is a statistical tool that quantifies a time series in terms of the information size. For the sake of completeness, we define the discrete probability space of a dynamic system as A=(A|P). The total number of elements in A is N. The characteristic elements can then be defined as A={a
1,⋯,a
k
}, as well as the relevant probability set P={p
1,⋯,p
k
}(1≤k≤N). Each element a
i
has probability p
i
=N
i
/N (), where N
i
is the total number of the element a
i
in A. Thus, the SE of A is defined as [26],
(6)
By Jensen’s inequality, we can prove with equality if p
i
≡1/N and k≡N for all i. Then, a uniform distribution of can be expressed as,
(7)
where, if N≡1, make log2N=1. Eq. (7) is also referred to as the normalized entropy, since the entropy is divided by the maximum entropy log2N. A coarser version of can be defined as,
(8)
Currently, the dynamic A consists of all 127 consecutive word elements from wv
n−126 to wv
n
(the bin size in this case is N=127). By determining the characteristic set A and the relevant probability set P with these elements, we can thus calculate the SE . The presence of AF is then detectable, with the rhythm labeled AF if exceeds a discrimination threshold, and otherwise non-AF, which can be seen in Figure 1(g). We utilize the training database to determine the optimal discrimination threshold by investigating various threshold settings which lie within the range [0.0, 1.0]; the best performing threshold of 0.353 is thus derived and employed for the performance assessment using different testing databases.
Key issues of online processing
From Eq. (1)–(5) and (8), outwardly, this AF detection technique poses computational challenges. However, these challenges can be overcome by implementing clever recursive algorithms with beat-by-beat, real-time processing.
A. Pseudo-recursive median filtering
The median filter in Eq. (1) can be implemented with a so-called pseudo-recursive method: for input x
i
, we define S={s
r
↑:1≤r≤2w+1} as a sorted array of successive elements from x
i−2w−1 to x
i−1, where the output y
i
is obtained by following steps ➊-➎ below,
➊ A Binary search technique is used to seek out the position m of the sample x
i−2w−1 which will depart from the window (i.e., s
m
=x
i−2w−1. Simultaneously, x
i
will get into the window);
➋ The Binary search technique is applied again to search for the position t at which the input x
i
needs to be set (i.e., s
t
<x
i
≤s
t+1);
➌ From positions m to t, the current s
r
is replaced with the adjacent s
r ± 1 (the ’ ±’ indicates where the element is taken from the right or left, with the ’ +’ and ’ −’ symbols representing the element to the right and left, respectively);
➍ Replace the element s
t
with x
i
;
➎ Median s
w+1 of the updated S becomes output y
i
.
For the following input x
i+1, we repeat steps ➊ to ➎ and obtain the new output s
w+1 (i.e., y
i+1), as shown in Figure 3, where the sorting utilizes the Binary search technique twice. Comparing our technique with the traditional median filter, the computational complexity can be decreased from approximately O(n2) to O(n).
B. Recursive implementation of integer filters
The recursive implementation (also referred to as the “difference equation”) of the filter H
l
(z) can be expressed as,
(9)
The above equation, Eq. (9) includes 1 integer addition, 3 integer subtractions as well as 1 integer right-shift operation, when xl
n
>>4 (as G a i n 1=24) to offset the gain of H
l
(z).
The filter H
h
(z) can then be computed recursively using
(10)
where, xh
n−1×2 is implemented with xh
n−1<<1. The above equation, Eq. (10) consists of 2 integer additions, 8 integer subtractions, 1 integer left-shift operation and 1 integer right-shift operation, when xh
n
>>11 (as G a i n 2=211) to offset the gain of H
h
(z).
C. Mapping the definition of
Investigating the dynamic A, we immediately see that each characteristic symbol of each bin N may have the probability p
i
=i/N (1≤i≤N, i.e., 1/N≤p
i
≤1). Along these lines, a probability array PiMap can be pre-calculated,
(11)
where, C o n s=1000000 is a constant such that decimal floating points can be converted into integers and N=127, and indicates to take the integer part of each .
Notably, for each cardiac cycle screened, this predefined PiMap permits the sole operation by picking the straightforward integer (i.e., P i M a p[i]) from the set PiMap in accordance with the index i rather than calculating using arithmetic and logarithmic operations. The use of this predefined calculation significantly decreases calculation times.
D. Recursive implementation of
We define a buffer array (wv
i
≤2457) to store the number of the i th characteristic element wv
i
in space A. For the input wv
n
, it will get into A (i.e., wv
n
will be the rightmost element), and simultaneously the leftmost element wv
n−127 will depart from A, see Figure 2 for clarity. It is obvious that a variation of SE is purely determined by and in dynamic A. Therefore, is calculated recursively by the algorithm below,
where and represent and , respectively; (∗ indicates that P i M a p[i]=0 is fixed for the case i≡0; and 127000000=N∗C o n s=127×1000000. For the next input wv
n+1, steps ➀-➂ are again executed to obtain . From an online processing perspective, the time delays of are 64 and 126.5 samples with respect to xh
n
and x
n
, respectively.
An architecture of the overall logic of the recursive realization can be seen in Figure 4. By using recursive algorithms, this AF detector consists of several basic operations, such as integer addition/subtraction, integer comparison and integer shifting. In effect, the calculation of and distinguishing the current beat x
n
, only needs to include 1 multiplication and 1 division lying within , together with 1 floating-point comparison between and a threshold. Consequently, a useful computational efficiency can be achieved.