1 Introduction

This study focuses on heartbeat detection in multi-channel ECG signals with high noise levels and intermittent signal loss. These types of disturbances could result from poor contact between the electrodes and the skin, as when using textile electrodes in smart clothing. Smart clothing is an evolving technique for monitoring of physiological parameters in various situations, such as home monitoring of elderly or patients with chronic diseases, or monitoring during sports activities [1, 4]. A textile electrode consists of a textile conductive surface that substitutes a traditional electrode. The conductive surface can be made of any conducting material, but the most common ones are silver-plated yarns or stainless steel yarn [3, 19]. Textile electrodes integrated in clothing differ from traditional electrodes, not only in terms of material and structure used for the conductive surface, but also in that they do not make use of electrode gel and they are not affixed to the skin. The use of textile electrodes can allow for flexible health monitoring systems integrated in clothing, such as the continuous monitoring of heart rate.

Disturbances are common in ECGs recorded with textile electrodes: this mainly because of movements in the textile structure [13] and movement artefacts. Disturbances can also be generated by intermittent loss of signal from individual electrodes and by electromyographic (EMG) interferences. Because of all these disturbances, it could be difficult to detect heartbeats in ECGs recorded with textile electrodes. By integrating many electrodes and by using multi-channel algorithms, heartbeat detection may still be feasible in textile ECG signals even in the presence of occasional signal loss in a single or a few channels or high noise levels.

Algorithms for heartbeat detection must determine the time instant for each heartbeat with high precision. High precision is important both to analyse beat-to-beat heart rate fluctuations and to detect abnormal changes in the morphology of the ECG. Although single-channel heartbeat detectors can handle relatively high noise levels, intermittent signal loss in different ECG channels can only be handled by analysing many ECG channels simultaneously. Moreover, since the redundancy of a multi-channel system is higher, a multi-channel detector would probably outperform a single-channel detector for heart beat detection in noisy ECG recordings.

Few studies have described methods for heartbeat detection in multi-channel ECG recordings. One previously suggested method is the length transform, where the samples of each channel are regarded as points in a vector space [7]. The length of the vector is calculated using data from a segment of approximately the same length as the QRS-complex, and the transform gives the highest value at those time instants when a heartbeat occurs. Another approach is to separate the ECG and noise sources by blind source separation (BSS), which is a method to estimate source signals by using their linear mixtures. In practice, this is often performed using independent component analysis (ICA) [9]. ICA-algorithms have been used to separate ventricular and atrial activity in the ECG [17], to characterise ECG signals [12], to suppress noise in ECG [2], and to separate foetal and maternal ECGs [20, 22]. To our knowledge, ICA has not previously been used as an explicit heartbeat detector.

In this study, we propose a method to detect heartbeat events in disturbed ECG recordings using adaptive spatio-temporal filtering [21]. This multi-channel filter is designed to give distinct peaks in the output signal at the time instants when heartbeats occur. The method was originally developed for extraction of motor unit action potentials in surface electromyograms [21]. In a preliminary study, we applied spatio-temporal filtering to eight-channel ECG recordings [16]. The results showed that heartbeats could be detected even though the ECG recordings had high levels of interferences, such as disturbances generated by muscular activity and electrode displacement.

This study evaluated the performance of adaptive spatio-temporal filtering in multi-channel ECG recordings with high noise levels and intermittent signal loss in single channels. We compared the performance of adaptive spatio-temporal filtering with the length transform and regular ICA. The multi-channel algorithms were evaluated using data from the PhysioBank archive. We also evaluated adaptive spatio-temporal filtering using data recorded with a garment with textile electrodes. Our aim was to investigate if adaptive spatio-temporal filtering would be a suitable technique to use for heartbeat detection in noisy ECGs recorded with smart clothes.

2 Methods

2.1 Multi-channel spatio-temporal filtering

The proposed multi-channel filter is designed to produce an output signal having distinct peaks that correspond to the time instants where the QRS complexes occur. Such a signal resembles a spike train, where most of the data points have an amplitude value close to zero, but where the peaks have significantly larger values. Thus, the signal values have a super-gaussian distribution, with a marked tail in the histogram.

To maximise the super-gaussianity of the output signal, the adaptive multi-channel filter uses both spatial and temporal filtering. The temporal filtering is performed using individual finite impulse filters on each channel i according to

$$ z_{i} (n) = {\sum\limits_{k = 0}^{K - 1} {h_{i} (k)x_{i} (n - k)} }, $$
(1)

where x i (n) is the input signal from channel i, {h i (k)} are the coefficients of the temporal filtering, and K is the filter length. In this study the filter size was set to 1, 3, 5, 10, and 20 samples in the time domain.

With M input channels, the spatial filtering is given by

$$ y(n) = {\sum\limits_{i = 0}^{M - 1} {g_{i} z_{i} (n)} } = {\sum\limits_{i = 0}^{M - 1} {g_{i} } }{\sum\limits_{k = 0}^{K - 1} {h_{i} } }(k)x_{i} (n - k), $$
(2)

where {g i } are the coefficients of the spatial filtering.

If g i h i (k) is replaced with w i (k), then

$$ y(n) = {\sum\limits_{i = 0}^{M - 1} {{\sum\limits_{k = 0}^{K - 1} {w_{i} } }(k)x_{i} (n - k)} }. $$
(3)

Consequently, the output signal y(n) is a linear combination of time delayed input signals. In matrix form, this becomes

$$ {\mathbf{y}} = {\mathbf{Wx}}. $$
(4)

The coefficients w i (k) were adaptively determined by maximizing the skewness of the output by using the FastICA algorithm [8]. The input signals were normalised to unit variance. The dimension of the input vector x was reduced using PCA, keeping 99% of the variability.

Spatio-temporal filtering was performed on blocks of 6-s durations. In each block of the output signal, time instants for individual heartbeats were determined using a threshold detector. The threshold was based on the median of a successive series of peak values for each second. A heartbeat event was detected if a local peak in the output signal was above the threshold limit. If two or more events were detected within a window of 300 ms duration, the event with the highest amplitude of the output signal was kept and the others were discarded.

The multi-channel filter is adaptive because the filter coefficients were determined for each segment of the signal. Therefore, the phase shift was different for successive blocks of the output signal and the blocks were time-aligned as follows [15]: the algorithm first determined the minimum time differences between the last detected beats in one block and the first detected beats in the next partly overlapping block. Then the sum of the absolute values of these time differences was calculated. The difference in phase shift between the two blocks was determined as the value that minimises this sum. All calculations were performed using the Matlab software package (Mathworks, Natick, Mass.).

2.2 Independent component analysis

Assume that the M recorded ECG signals, \( x_{i} (n),\quad i \le M, \) are modelled as a linear combination of P unknown source signals, \( s_{j} (n),\quad j \le P. \) In matrix form this corresponds to the basic BSS model given by [9]

$$ {\mathbf{x}} = {\mathbf{As}}, $$
(5)

where A is the linear mixing matrix. If P = M then A is a square matrix, and the source signals can be estimated by computing its inverse

$$ {\mathbf{s}} = {\mathbf{A}}^{{ - 1}} {\mathbf{x}} = {\mathbf{Wx}}. $$
(6)

In standard ICA, the matrix W is estimated as the one that gives source signals (independent components) that are as non-gaussian as possible. This comes from the idea of using the central limit theorem “backwards”. The central limit theorem states that by summing independent variables the sum will eventually have a normal distribution regardless of the distribution of the independent variables. A common way to measure “non-gaussianity” is to use higher order cumulants, often kurtosis.

From Eq. (6), it follows that BSS using ICA is similar to spatio-temporal filtering with K = 1. Thus regular ICA can be regarded as a pure spatial filtering, whereas spatio-temporal filtering also uses the temporal information of the data. Moreover, in ordinary ICA, we obtain as many independent components as recorded data signals, whereas our proposed filtering technique results in a single output. In this study, we implemented ICA using the FastICA algorithm, where we selected the output signal with maximum kurtosis. This is the same approach as previously suggested to separate QRS-complexes from atrial activity in 12-lead ECGs [5].

2.3 Length transform

The length transform of a multi-channel ECG recording is given by [7]

$$ L(M,q,n) = {\sum\limits_{k = n}^{n + q - 1} {{\sqrt {{\sum\limits_{i = 1}^M {(x_{i} (k) - x_{i} (k - 1))^{2} } }} }} }, $$
(7)

where M is the number of input channels, and q is a window with size approximately equal to the duration of the QRS complex. In this study, q = 65 was used. The input signals were high-pass filtered and normalised. Heartbeat events were determined in the output signal using a similar threshold detector as described above.

2.4 Database recordings

The multi-channel heartbeat detectors were evaluated using recordings from the Physikalisch-Technische Bundesanstalt (PTB) Diagnostic ECG Database (http://www.physionet.org). We selected the first ten recordings from healthy controls and analyzed the first 2 min of each 12 leads-ECG recording. The sampling frequency was 1,000 Hz. The signals were high-pass filtered (cut-off frequency 0.01 Hz) to suppress baseline drift.

Pseudoreal signals were generated by adding four different noise signals to each of the ten database recordings. Two recordings with noise typical in ambulatory ECG recordings were downloaded from the MIT–BIH Noise Stress Test Database (http://www.physionet.org). The first recording consisted of electrode motion artefacts (record ‘em’), and the second recording contained muscle artefacts (record ‘ma’). The sampling frequency was 360 Hz, but was increased to 1,000 Hz by interpolation and re-sampling. Each noise recording consisted of two channels of 30 min duration. Data were divided into 2-min segments, resulting in a total of 30 blocks of data for each noise type. Twelve of these thirty blocks were randomly selected and added to the each of the twelve channels of the ECG recording. Two different noisy ECG signals were generated: (1) ECG with electrode motion artefacts only, and (2) ECG with the sum of electrode motion artefact noise and muscle artefact noise. The signal-to-noise ratio (SNR) was defined as the ratio of the variance of the ECG signal and the variance of the noise signal. As a result of the used procedure an equal SNR was achieved in all channels.

The noisy ECG signals described above were also used to test the effect of intermittent signal loss due to poor electrode contact. To simulate a short interruption of the signal, we added short pulses modelled as a randomly occurring rapid transition to the maximum value followed by an exponential decay [6]. The duration of these pulses was randomly selected with a uniform distribution between 0.1 and 3.0 s, and the time constant of the decay was set to 4 s. The pulses were randomly distributed in different channels with an average interval of 15 s between pulses. SNR was calculated before adding the simulated pulses with signal loss.

The performance of the multi-channel algorithms was evaluated using different noise sources at three different SNRs (0, −5, and −10 dB) and at three different numbers of channels: four (leads I, II, III and AVR), eight (leads I, II, III, AVR, AVL, AVF, V1, V2 and V3), and all twelve ECG channels. Reference values of time instants for the heartbeats were determined by using each algorithm on all 12 channels without any additional noise.

2.5 Recordings with textile electrodes

Data were recorded from ten healthy male subjects (age 21–47 years, mean 30 years) using a T-shirt with integrated textile electrodes. The data acquisition unit had a wireless transfer of data to an ordinary PC system [10, 11]. The modular-constructed acquisition unit consisted of a main module with a single-chip microprocessor (8051-core), an application-specific signal conditioner module (including A/D converters), and a digital wireless module (Bluetooth). All modules can be exchanged depending on the specific measurement situation. In this study, ECG was measured using amplifiers with fixed gain, high resolution and oversampling 16-bit A/D converters. The wireless multi-channel data acquisition unit was configured for recording of eight ECG channels at 500 Hz. Baseline drift was suppressed by analogue high-pass filtering at 0.1 Hz.

Seven ECG channels were recorded using an elastic garment with textile electrodes placed on the chest and shoulders (Fig. 1). ECG was measured bipolar with a textile reference electrode placed near the waist. In addition, one ECG channel was recorded with two conventional Ag/AgCl electrodes placed on the wrists (lead I). This signal was recorded as a reference signal to confirm the detected heartbeats. The textile electrodes were made from stainless steel and knitted in pieces of approximate size 2 × 2 cm. Snap buttons were mounted on the textile pieces with electrical insulation between the back of the buttons and the skin of the test subjects. Standard ECG cables were used for connections of the textile electrodes to the wireless data acquisition system. All recordings were performed with dry textile electrodes.

Fig. 1
figure 1

T-shirt with integrated textile electrodes and the ECG monitor with a wireless transfer of data to a PC. White dots indicate positions of electrodes

Data were recorded for approximately 9 min. During the recording, the subjects generated intermittent disturbances by moving or by high levels of muscular activity: walking, changing between sitting and standing, flexing the breast muscles, and push-ups. Heartbeat events were detected using spatio-temporal filtering. All heartbeat event times were manually confirmed. Detection errors were found by visual inspection of the ECG recordings and the determined RR intervals.

2.6 Scoring of results

A heartbeat event was labelled as true positive (TP) if it belonged to a window of 128 ms duration around the R-peak [14], if not, it was labelled as false positive (FP). Undetected R-peaks were labelled as false negatives (FNs). The probability of detection was measured by the sensitivity and precision:

$$ {\text{sensitivity}} = \frac{{{\text{TP}}}} {{({\text{TP}} + {\text{FN}})}}\quad {\text{precision}} = \frac{{{\text{TP}}}} {{({\text{TP}} + {\text{FP}})}}. $$

Results were presented as boxplots, which showed minimum and maximum values, 75% percentile, median, 25% percentile and outliers. Outliers were defined as values smaller than (25% percentile) − 1.5(median − 25% percentile). The error in the determined time instants for all beats classified as TP was estimated by the mean-squared error (MSE), given by the average of the squared deviation from the corresponding reference values.

2.7 Statistical analysis

The performance of the different multi-channel algorithms was compared using the Kruskal–Wallis test. In all tests, a p value of less than 0.05 was considered statistically significant.

3 Results

3.1 Database recordings

Figure 2 shows one example of the performance from the evaluation of the proposed algorithm for adaptive spatio-temporal filtering using the database recordings. In this example, the SNRs were −10 dB for all input channels. The figure shows three input signals, but a total of 12 noisy ECG channels were used to determine the output signal with maximum skewness. For reference, the top panel shows the corresponding noise-free ECG.

Fig. 2
figure 2

Adaptive spatio-temporal filtering of a database recording using filter length 20. Top panel Original noise-free ECG. Middle panels Three input signals with SNR = −10 dB and intermittent signal loss. Bottom panel Output signal with maximum skewness. Circles indicate determined time instants for heartbeat events

Figures 3 and 4 show the results from the evaluation of the algorithms for different SNR and number of input channels. The boxplots show the pooled results for all four generated types of noise: the boxplots represent 40 values each. As shown in the figures, the poorest performance was obtained for the length transform. Therefore, the length transform was excluded from further analyses.

Fig. 3
figure 3

Results from database recordings: sensitivity for different SNR:s and different number of channels for the length transform (LT), independent component analysis (ICA), and for different filter lengths of adaptive spatio-temporal filtering

Fig. 4
figure 4

Results from database recordings: precision for different SNR:s and different number of channels for the length transform (LT), independent component analysis (ICA), and for different filter lengths of adaptive spatio-temporal filtering

When SNR was −5 dB, spatio-temporal filtering with eight channels and filter length 20 resulted in a mean sensitivity of 99.7% with a mean precision of 99.7%. The corresponding results for ICA were 99.0 and 98.2%, respectively. At SNR = −10 dB, the best results were obtained for 12 channels and spatio-temporal filtering with filter length 20 with a mean sensitivity of 98.2% and a mean precision of 99.3%. ICA with 12 channels resulted in a mean sensitivity of 89.9% and a mean precision of 84.6%. Although there was a tendency to increased sensitivity with increasing filter length in the spatio-temporal filter, the only statistically significant differences were found between filter length 20 and ICA (p < 0.001). Regardless of filter length, the precision was statistically significantly higher for spatio-temporal filtration than for ICA (p < 0.001). Table 1 shows the average MSE for the detected heartbeat event times. The average MSE was below 1 ms for spatio-temporal filtration with at least eight channels.

Table 1 Mean square error (MSE) for the determined heartbeat event times for all 40 pseudoreal noisy ECG signals

3.2 Textile electrode recordings

Figure 5 shows the performance of adaptive spatio-temporal filtering (using K = 20) in one recording with textile electrodes while the subject was doing push-ups. As seen in the figure, all input channels contained severe muscular interferences. These interferences were suppressed in the multi-channel filter, as shown by the time instants of the spikes in the output signal before and after the onset of muscular interferences.

Fig. 5
figure 5

ECG recording made with the T-shirt with integrated textile electrodes in a healthy subject while doing push-ups. Bottom panel Output signal from adaptive spatio-temporal filtering

Table 2 shows the results of adaptive multi-channel filtering in the recordings with textile electrodes. No statistically significant differences were found between spatio-temporal filtering and ICA. There was a tendency that the number of heartbeat detection errors was reduced for spatio-temporal filtering when the filter length was increased from 1 up to 20. Using filter length 20 and all 7 channels, the sensitivity and the precision was higher than 97% in 9 of 10 subjects. The majority of misclassifications were made when the subjects were doing push-ups. One subject had a lot of hair on his chest and his recording had very poor quality, with a maximum sensitivity of 93% and precision of 93%. The length transform was not used to analyse the textile recordings because of its poor performance on the database recordings.

Table 2 Sensitivity and precision for textile ECG recordings from ten healthy subjects

4 Discussion

Our primary goal was to evaluate whether adaptive spatio-temporal filtering was a suitable method to use in smart clothes where frequent disturbances in the ECG can be expected. Our idea was to integrate many textile electrodes in a T-shirt and use advanced signal processing to extract heartbeats. Therefore, we evaluated different methods for heartbeat detection in multi-channel ECG recordings with high noise levels and intermittent signal loss. We found that spatio-temporal filtering outperformed both regular ICA and the length transform when SNR was low. The performance of the multi-channel increased with increasing number of channels. We also found that the performance of the filter increased when the length of the temporal filter was increased. Thus the combination of spatial and temporal filtering reduced the number of detection errors in the database recordings with high noise levels. We also applied adaptive spatio-temporal filtering to multi-channel ECG data recorded with textile electrodes. Although the noise level was very high in some of the channels, 97% or more of the heartbeat events were extracted in recordings in nine out of ten healthy subjects.

In this study, spatio-temporal filtering was used to automatically extract one output signal—the one with the maximum skewness. The same filtering approach can also be used with other criteria and algorithms than the FastICA algorithm. Previously, kurtosis was used as criterion in spatio-temporal filtering of EMG signals [21]. Kurtosis is also more common in regular ICA applications. A preliminary study showed that skewness tended to be more robust against ECG disturbances than kurtosis [15], which was also found in this study as indicated by the higher precision for spatiotemporal filtering than for ICA. At present, we are developing the algorithms for adaptive multi-channel filtering to obtain an even more robust selection of the “best” output signal.

ICA has been used on multi-channel ECG in order to suppress noise [2], but not explicitly as a robust heartbeat detector. Compared to ICA, spatio-temporal filtering has the advantage that the use of time information decreases length of the signal corresponding to a heartbeat, thereby making the heartbeat easier to detect. In this study, this is seen as an improved performance with increasing time length of the filter.

The maximum filter length used for spatio-temporal filtration was 20, which corresponds to a time window of 20 ms duration. Thus, one would expect that the filter performs better for removal of muscular interferences than most movement artefacts. If the electrodes are spatially distributed, electrode movement artefacts probably only occurs in a few channels simultaneously. Similarly, muscle interferences in different channels are probably independent. This could be the reason why the proposed method seems to handle rather large noise levels. We performed tests where the filter length was increase to 50. The performance did not improve, but there was a marked increase in computational time.

ICA is used to recover the source signals from a linear combination of mixed signals [9], whereas spatio-temporal filtering extracts time instants for heartbeats without preserving the shape of the ECG. The shape of the QRS-complexes can be estimated in individual channels by using time instants for successive heartbeats and noise-reduction by averaging. Time delayed input signals have been used in variants of ICA to separate the foetal ECG from the maternal ECG [18, 20].

We accepted detected heartbeats if they were found within 128 ms around the corresponding R-peak, but the estimated error in heartbeat event time was below 1 ms for spatio-temporal filtration with eight channels. We have performed preliminary tests on recordings with ectopic beats. These tests indicate that additional functionality will be needed to fully separate ventricular ectopic beats from sinus beats. Supraventricular ectopic beats will probably be detected in the same way as sinus beats.

We investigated the performance of the multi-channel algorithms in two different situations. The pseudoreal signals based database recordings were analysed with the same SNR in all input channels. In this case, the performance improved markedly by adding more input channels. The textile recordings had different SNR in different channels. In several subjects, the first two ECG channels were of relatively high quality with low noise levels. There was no significant improvement in performance when adding more channels or when the filter length was increased. On the other hand, these results indicate that the performance did not decrease when more noisy data channels were added. In smart clothes, the electrodes may have good contact with the skin at certain times, whereas they will have poor contact at other times. By using many textile electrodes and the proposed algorithm, it may not be necessary to identify data channels of poor quality before the heartbeat detection. One disadvantage with using many electrodes is that more data needs to be recorded.

Another disadvantage with adaptive spatio-temporal filtering is the complexity of the algorithm. Many simple one-channel algorithms are available that can detect heartbeats in relatively noisy ECGs but not during temporary signal loss. Spatio-temporal filtering could be used as a robust reference method when developing simpler multi-channel algorithms.

The textile recordings were performed with a T-shirt with integrated textile electrodes and conventional cables attached to snap buttons. Movement of electrode cables caused additional disturbances, disturbances that may be avoided using integrated textile cables. Dry textile electrodes were used and there were no preparations of the subjects’ skin before putting on the T-shirt. The missed beats were mainly in the segment where push-ups were performed and in the less successful recordings from subjects with most chest hair. The effect of body movements may also be reduced by using other electrode positions than those used in this T-shirt.

Smart textiles, i.e., clothing with integrated textile sensors have large potential in areas such as clinical monitoring, health surveillance, ergonomics, and sports medicine. The technique enables a heart patient to be continuously monitored at the clinic or in the patients home by just putting on a T-shirt including textile electrodes. Fire-fighters can be provided with smart clothing for continuous monitoring of vital signs during rescue operations in order to not expose individuals beyond safe conditions. Another possible application of smart clothing is monitoring of heart rate variability, which can be used to evaluate the cardiac autonomic modulation during different experimental conditions as well as during stressful situations.

5 Conclusions

Multi-channel spatio-temporal filtering may be a suitable method for heartbeat detection in ECG measurements with high noise levels and intermittent signal loss, e.g., when textile electrodes are used in smart clothes. Heartbeat detection using spatio-temporal filtering can also be applied to other multi-channel ECG recordings with high noise levels and/or temporary signal loss in some channels, such as Holter-ECGs and stress-test ECGs.