*2.4. Piecewise Adaptation of the Local Relevance Function*

Assigning *k* = {1 ... 5} to the consecutive borders of waves: P-onset, P-end, QRS-onset, QRS-end and T-end (T-onset is not considered as standard fiducial point), the projection of gMRF to aMRF consists in calculating the values of the latter,

$$\bigvee\_{b \in aMRF} \exists \bigvee\_{a \in gMRF} \colon aMRF(b) = \text{gMRF}(a) \tag{1}$$

where *a* and *b* express integer sample numbers in adapted and generalized medical relevance functions, respectively, and

$$a = \frac{(a\_k - a\_{k-1}) \times (b - b\_{k-1})}{(b\_k - b\_{k-1})} + c \tag{2}$$

where *c* is a complement transferring fraction of border sampling interval between ECG waves, i.e.,

$$c = \begin{cases} \frac{a\_{k+1} - a\_k}{b\_{k+1} - b\_k} & for \, k = 2\\ 0 & for \, k \in \{3, 4\} \\ \frac{a\_{k-2} - a\_{k-1}}{b\_{k-2} - b\_{k-1}} & for \, k = 5 \end{cases} \tag{3}$$

We applied the piecewise linear projection of gMRF to aMRF (Figure 3) for its computational simplicity and without noticing any consequences of singularities in aMRF caused by stepwise changes of gMRF sampling. Otherwise, either digital filtering of the resulting aMRF or projection with the use of cubic splines with nodes at the landmarks are possible alternatives. All calculations use real number representation in time and value domains of these functions.

**Figure 3.** Projection of generalized medical relevance function (gMRF) to local positions of the heartbeat sections: (**a**) gMRF (with the bar graph it stems from), (**b**) aMRF (adapted medical relevance function) calculated for CSE-Mo001 record, (**c**) aMRF calculated for CSE-Mo003 record.

Finally, for each heartbeat the values of the aMRF are used to control the local sampling interval *ls*(*t*) within the range corresponding to frequency limits (*fm*, *fs*) accordingly to the linear relationship:

$$ds(t) = T\_{\rm{m}} + (T\_{\rm{s}} - T\_{\rm{m}}) \times aMRF(t) \tag{4a}$$

or conversely,

$$ds(t) = \frac{1}{f\_m} + \frac{f\_m - f\_s}{f\_m \times f\_s} \cdot aMRF(t) \tag{4b}$$

In the proposed implementation, the adaptive algorithm is dedicated to the ECG signal sampled at *fs* = 500 Hz and the minimum usable value of local sampling frequency tested in two experiments was set to *fm*<sup>1</sup> = 100 Hz (Figure 4) and *fm*<sup>2</sup> = 50 Hz respectively.

**Figure 4.** Interval of consecutive samples in a non-uniform representation (*fm*<sup>1</sup> = 100 Hz) calculated for the reference beat from file CSE001.

#### *2.5. ECG Signal Resampling*

The objective of the sampling problem is to recover a function *<sup>f</sup>* on <sup>R</sup><sup>d</sup> from its samples {*f*(*xj*): *<sup>j</sup>* <sup>∈</sup> *J.*}, where *J.* is a countable indexing set, and *f* satisfies some a priori constraints [33]. Extension of the classical Shannon theory to the non-uniform sampling of bandlimited functions specifies that for the exact and stable reconstruction of such function *f* from its samples {*f*(*xj*): *xj* ∈ *X*}, it is sufficient that the Beurling density,

$$D(X) = \lim\_{r \to \infty} \inf\_{y \in \mathbb{R}} \frac{\#X \cap (y + [0, r])}{r} \tag{5}$$

(where *r* is radius of sampling grid and *y*—sample position), satisfies *D*(*X*) > 1 [34,35]. Conversely, if *f* is uniquely and stably determined by its samples on *X* ⊂ R, then *D*(*X*) ≥ 1.

Solution of the sampling problem *f* in non-uniform shift-invariant bases *V<sup>p</sup> <sup>v</sup>*(φ) (where *p* is space dimension, ν is the weight function and φ is the space generator) consists of two parts.

• Given a generator ϕ, conditions on *X* have to be defined, usually in the form of a density, such that the norm equivalence (6) holds.

$$\|c\_{\mathcal{P}}\|f\|\_{L^{p}\_{v}} \leq \left(\sum\_{\mathbf{x}\_{j}\in\mathcal{X}} \left|f(\mathbf{x}\_{j})\right|^{p} \left|\mathbf{v}(\mathbf{x}\_{j})\right|^{p}\right)^{\frac{1}{p}} \leq \mathbb{C}\_{\mathcal{P}} \|f\|\_{L^{p}\_{v}}\tag{6}$$

Then, at least in principle, *<sup>f</sup>* <sup>∈</sup> *<sup>V</sup><sup>p</sup> <sup>v</sup>*(φ) is uniquely and stably determined by *f X*.

• Reconstruction procedures useful and efficient in practical applications have to be designed as fast numerical algorithms which recover *f* from its samples *f <sup>X</sup>*, when (6) is satisfied.

Since the iterative frame algorithm is often slow to converge and its convergence is not even guaranteed beyond *V*2(ϕ), alternative reconstruction procedures based on Neumann series have been designed [34]. In [33] Aldroubi presented the example iterative algorithm with the proof of the convergence of results. The reconstruction of the uniform biosignal from an incomplete time series was also developed by Candes et al. [36] and Needell and Tropp [37].

In the proposed algorithm for adaptive ECG sampling we used the cubic splines interpolation to transform the ECG from its native uniform representation to the adaptively sampled representation and vice-versa. Considering the uniform representation as a particular case of non-uniform time series, the approximation first projects the input time series *Nj*({*n*, *v*(*n*)}) to the continuous space with the use of 3rd order polynomial function,

$$S\_n(t) = a\_n + b\_n(t - t\_n) + c\_n(t - t\_n)^2 + d\_n(t - t\_n)^3 \tag{7}$$

where *t* ∈ [*tn*, *tn*+1], *n* ∈ {0, 1, ... *N* − 1} is best fitted to the time series *Nj*. Next, the output signal representation is obtained by sampling the *Sn*(*t*) at desired time points *m*:

$$N\_j'(m) = \sum\_m S\_n(t) \times \delta(t - m \times \text{ls}(t))\tag{8}$$

In the case of forward transformation, the positions of input sampling points *n* are equispaced whereas the positions of output sampling points *m* are determined by the local sampling interval *ls*(*t*) (see Equation (4), Figure 5). In the case of inverse transformation, the input time series comes as non-uniformly sampled, and considering the information about local distances between samples, the cubic splines interpolation yields the uniform ECG representation.

**Figure 5.** Regular and irregular representations of the same heartbeat (**a**) global scale, (**b**) local scale (terminal section of QRS). Vertical axes represent the ECG voltage, approximately 2.44 μV per unit.
