<<

FINALREPORTFOR IBSCAND MENG GROUP PROJECT

Machine Learning based Denoising of Electrocardiogram Signals from a Wearable ECG Monitor

December 31, 2018

Laure Abecassis, Magdalene Ho, Owuraku Titi-Lartey, Woochan Hwang Timothee Gathmann, Ze Lum, Ng Yee Loong, Joshua Moo

Supervisor: Dr. Anil Anthony Bharath

Imperial College London Department of Bioengineering

1 Imperial College London

Abstract

Long-term outpatient monitoring of the electrocardiogram (ECG) has been shown to be beneficial for not only early diagnosis of arrhythmias but also monitoring of high risk patients. Hence, this project aims to design a wearable ECG monitoring device capable of denoising electromyogram (EMG) , which is the chief contributor of motion artefacts, through the use of a machine learning denoising algorithm. Amongst the ECG signals obtained from textile and capacitive-coupled electrode prototypes, it was found that electrodes made from silver-plated conductive fabric were able to obtain ECG signals comparable to those obtained from conventional Medi-Trace gel electrodes, when placed on the biceps of each arm. A printed circuit board (PCB), utilising the ADS1292, was designed to test the possibility of measuring and amplifying ECG signals from two electrodes without a right leg drive circuitry. Furthermore, a novel five layer convolutional was trained using accelerometer data and noisy ECG signals generated from combining clean ECG signals from the MIT-BIH Arrhythmia Database with EMG signals measured from a Myoband manufactured by Thalmic Labs. Overall, the electrode prototypes and the proposed PCB design successfully work in conjunction with each other. The convolutional autoencoder utilizing acceleration data shows statistical improvement over conventional denoising methods, however is currently inconclusive for simultaneous ECG and Acceleration data obtained from the proposed device. Conclusively, the proposed device is a successful prototype for a long- term outpatient monitoring device but requires further improvements to include removal of EMG artefacts using machine learning algorithms.

Page 2 of 44 Imperial College London

Acknowledgements

We would like to thank:

• Dr Anil A. Bharath for his valuable and constructive suggestions during the planning and development of this project.

• Mr Paschal Egan and Mr Niraj Kanabar for their continuous help throughout this project.

• Dr Firat Guder and Mr Andrew Lee for their advice and assistance with the elec- trodes.

Page 3 of 44 Imperial College London

Contents

1 Introduction 6

2 Final Design 7 2.1 Electrode Design ...... 8 2.2 ECG Hardware and Printed Circuit Board ...... 8 2.3 Denoising Algorithm ...... 9

3 Methods 10 3.1 Electrode Design ...... 11 3.1.1 Electrode Quality Testing ...... 11 3.1.2 Optimal Position Testing ...... 12 3.1.3 ECG Signal Processing and Evaluation ...... 13 3.2 Printed Circuit Board Design ...... 14 3.3 Data Collection ...... 15 3.3.1 EMG and Accelerometer Data ...... 15 3.3.2 Generation of Noisy Data ...... 15 3.4 Denoising Algorithm ...... 16 3.4.1 Neural Network Training ...... 16 3.4.2 Evaluation ...... 16

4 Results 17 4.1 Electrode ...... 17 4.1.1 Electrode Quality ...... 17 4.1.2 Optimal Position Test ...... 18 4.2 ECG Hardware and Printed Circuit Board ...... 18 4.3 Denoising Algorithm ...... 20 4.4 Overall design ...... 20

5 Discussion 22 5.1 Electrodes ...... 22 5.2 Printed Circuit Board ...... 23 5.3 Data Collection ...... 25 5.4 Denoising Algorithm ...... 25 5.5 Market Needs ...... 27

Page 4 of 44 Imperial College London

6 Conclusion 28

Appendix A Product Evaluation Matrix 32

Appendix B Task Allocation 33

Appendix C Bill of Materials 34

Appendix D PCB design incorporating ADS1291 35

Appendix E ECG Hardware connections and EMG-Accelerometer Data Collection 37

Appendix F Electrodes Evaluation Rubrics and Data 38

Appendix G Electrode prototype designs 41

Appendix H Filter frequency response used for ECG filtering 43

Appendix I PyTorch Implementation of Convolutional Autoencoder 44

Page 5 of 44 Imperial College London

1 Introduction

Long-term outpatient monitoring of the electrocardiogram (ECG) has been shown to be beneficial for not only early diagnosis of arrhythmias but also monitoring of high risk patients [1, 2, 3]. Wearable ECG monitoring devices often suffer from severe electromyogram (EMG) noise [4, 5] as it is not easily filtered with conventional methods such as empirical mode decomposition [6] and wavelet analysis [7, 8, 9]. Hence, this project aims to design a low- power ECG monitoring armband, composed of two electrodes, with a machine learning denoising algorithm. The system should consistently denoise ECG signals, regardless of the user’s motion, to output clean signals. To measure an ECG, a minimum of two electrodes wired to an Instrumental Amplifier (IA) is required to provide high input impedance, high common-mode rejection and variable amplification of the differential signal [10]. The primary design objectives for the wearable electrodes are to achieve comfort, reliable and consistent data collection. The use of textile [11], conductive fabric [5] and capacitive-coupled electrodes [12] are investigated in this project, following the said studies. Furthermore, an Analog-to-Digital Converter (ADC) is required to digitally process the output from the circuit. The design from Chung et al. [5] gave promising results whilst using dry capacitive-coupled electrodes. However, the design itself did not meet the criteria of wearability since it used a driven Right Leg Drive (RLD) circuit [13]. Therefore, a fully integrated portable Printed Circuit Board (PCB) including the essential blocks stated above was implemented. Finally, a denoising algorithm that is robust under high EMG noise conditions is essential in generating a clinically useful ECG from a wearable device. Conventional bandpass filters

Figure 1: Overview of actual prototype with description of various components

Page 6 of 44 Imperial College London are unable to suppress EMG noise as they overlap in the frequency domain with the ECG [14], while the empirical mode decomposition is prone to filtering out the P and T waves [7]of the ECG (figure 1 ). To address such limitations, there has been efforts to integrate acceleration and skin-electrode impedance in the form of adaptive filtering [15, 16]. Moreover, approaches using neural networks in denoising ECGs [17, 18] have shown state of the art results on the benchmark MIT-BIH database [19, 20]. However, the study done by Xiong et al. [17] used ambulatory noise from the MIT-BIH database [13], which contains lesser EMG artefacts compared to the data obtained from wearable devices. Therefore, the primary objective for the denoising system will be to train a machine learning based algorithm that can denoise the high level of EMG contamination that we see in wearable ECG monitoring devices.

2 Final Design

The final prototype consists of two electrodes, one on each arm, connected to a designed PCB. The PCB and LIS3DH accelerometer are connected to the Raspberry Pi Zero micro-controller and are attached on the outer side of the armband, as shown in figure 2.

Figure 2: Overview of actual prototype with description of various components

Page 7 of 44 Imperial College London

Figure 3: Model representing an overview of the project design and concept

2.1 Electrode Design

The type of electrodes incorporated into armbands were chosen by evaluation against the user requirements (see Appendix A: Product Evaluation Matrix). The Silver plated polyamide fabric (Shieldex® Bremen) [21] was chosen due to its consistency in obtaining high quality ECGs, which is comparable to commercial Medi-Trace gel electrodes. All electrodes prototype were designed to have an area of 4cm2, determined by Marozas et al to be optimal for obtaining ECG signals; As an area less than 1cm2 or greater than 8cm2, results in attenuation of low frequency bandwidths and noise amplification respectively [22].

2.2 ECG Hardware and Printed Circuit Board

The overall circuitry involved a PCB with ADS1292 chip, a voltage regulator and a 2.5 mm audio jack to provide a simple way to connect the electrode armbands. To achieve a compact design, the conventional RLD circuitry, which requires a third electrode at the leg, was avoided. Instead, a bioinstrumentation circuit was designed to compensate for the degradation of the common-mode rejection without the RLD, which requires only two electrodes. Furthermore, a denoising algorithm would be used to remove both EMG and mains interference, which eliminates any need for analogue filters. The ADS1292 manufactured by Texas Instruments is able to record biological signals and meets the portability and low-power requirement. The ADS1292 integrates a high impedance differential input, amplified by a programmable gain amplifier (PGA) with a very high common-mode rejection ratio (CMRR) of typically 120dB [23], as opposed to a − lower 105dB CMRR used in Chung et al. [5]. The latter is then connected to an integrated − analog-to-digital converter (ADC) with a Serial Peripheral Interface (SPI).

Page 8 of 44 Imperial College London

Figure 4: Visual representation of the PCB Design. More details of the component in Appendix D

As for the PCB, four layers (refer to figure 4) were designed for the convenience of routing and to prevent crosstalk between analog and digital signals [24]. An external power supply provides 5V to the Raspberry Pi Zero, which in turn powers the PCB and manages additional GPIO pins required by the ADS1292 to function properly. The communication between the Raspberry Pi Zero and the ADS1292 was established through an SPI protocol, at a transmission rate of 2M Hz. The chip was configured to sample at a rate of 500 samples per second, and transmitted 24 bits of data for every sample.

2.3 Denoising Algorithm

The final architecture of the denoising algorithm is a five-layer convolutional autoencoder (CAE) as shown in figure 5. The encoder takes in a 2D array of size 4 by 300 where the first row contains the noisy ECG and the rest contains the 3-axis accelerometer data. Convolu- tions across the columns of the input identify correlation between the neighbouring ECG and accelerometer data. The first layer kernels are size 4 by 7 with zero paddings only in the columns to keep the convolution operations over all 4 rows of input at all times. The convolution layer is followed by an activation and max pooling layer. The decoder layers are 2D inverse convolution operators. The details of the PyTorch-based implementation are available on the Github repository [25].

Page 9 of 44 Imperial College London

Figure 5: Convolutional Autoencoder Architecture. The key dimensions are as follows: Input (4,300); Bottleneck (1,75); Output (1,300).

3 Methods

The methods can be classified into manufacturing and testing of electrode armbands, fab- ricating the PCB and building the architecture and training of the CAE. Figure 6 shows the overall steps and methods taken to achieve the project goals.

Figure 6: Overview of steps taken and completed to achieve project goals of comfortable wearable ECG device with denoising of motion artefacts capabilities via Machine Learning

Page 10 of 44 Imperial College London

Figure 7: A: Copper thread. B: Silver thread. C: Silver plated polyamide fabric (Shieldex® Bremen) with foam. D: Silver plated polyamide fabric without foam. E: Polyester fabric (EeonTex) with foam. F: Polyester fabric(EeonTex) without foam. G: Copper plate with Silk medium as capacitive coupled electrodes with foam. H: Capacitive coupled without foam.

3.1 Electrode Design

Textile electrodes based on Bystricky et al. [12], were made by embroidering 0.125mm copper and silver thread (electrode A and B in figure 7, respectively) into polyester armbands, with a Necchi 681c computerised sewing machine. Textile electrodes were also made from Shieldex® Bremen silver-plated polyamide fabric [21] and EeonTex Non-Woven Conductive Fabric [26] (electrodes C,D and E,F respectively). Non-contact electrodes based on the concept capacitive-coupled electrodes using copper plates of varying thickness (2mm,3mm) with silk as a dielectric layer, as natural textiles such as silk and cotton, have been shown to be better insulators than synthetic fabrics with lower floor noise floor [27]. According to Kim et al. [28], foam beneath the electrodes improve contact pressure and hence, the signal noise ratio (SNR) of ECG detected. Therefore, each type of electrodes were investigated with the inclusion of foam too (electrodes C, E and G of figure 7). For detailed information regarding electrode prototypes, refer to Appendix G.

3.1.1 Electrode Quality Testing

The ECG signals of three subjects, obtained through the prototype electrodes were compared against gel electrodes, via the a PowerLab 4/25T device and LabChart version 8.1.10. The gel electrodes were placed on each arm of the subject, at position B1 shown in figure 8.

Page 11 of 44 Imperial College London

Figure 8: Visual representation of measuring points on arm, used in experiments

Recordings were taken over a period of 1 minute, after the ECG signals have stabilised. As a control, participants kept as still as possible, with their hands rested on their knees to avoid interference of external noise from wire movements and EMG. Recordings were repeated with electrodes prototype A-H (refer to figure 7).

3.1.2 Optimal Position Testing

In order to determine the optimal positioning of electrodes along the arm, gel electrodes placed from position A1 to D2 (figure 8) were paired across both arms as well as along the same arm, as shown in figure 9. A multitude of factors, including the quality of the signals acquired and the comfortability of electrodes were considered. Furthermore, optimal electrodes positions were also compared based on the EMG noise picked up from a range of daily movements: Flexion-Extension (FE), Supination-Pronation(SP), Walking Motion(WM) and opening-closing(OC) of hand, as shown in figure 10 .

Figure 9: Electrode pairs used to determine optimal electrode positioning.

Page 12 of 44 Imperial College London

Figure 10: (Top Left) Flexion-Extension (Top Right) Pronation and Supination (Bottom Left) Walking Motion (Bottom Right) Opening and closing of fist

3.1.3 ECG Signal Processing and Evaluation

ECG signals collected via PowerLab were imported into Matlab and digitally filtered through a notch filter, low pass filter and a moving average filter (refer to Appendix H for specifications of filters). The processed ECG signals were evaluated (Figure 11) for the consistent detectability of P,QRS,Tpeaks, amongst other medically relevant characteristics of an ECG. Values for R-wave peak amplitude, variation and baseline wander were benchmarked based on Medi-Trace gel electrodes when used with the PowerLab device.

Figure 11: Evaluation rubrics used to evaluate quality of ECG signals obtained from electrode proto- types and gel electrodes

Page 13 of 44 Imperial College London

3.2 Printed Circuit Board Design

The schematic and board layout were designed with Autodesk Eagle and sent to the company Elecrow for manufacturing. The board was subsequently populated with its components fixed in a reflow oven, with a controlled temperature profile. For ease of populating the board, large surface mount components (standard 0805) were used. Texas Instruments voltage regulator TPS71733DCKR [29] was used to provide a stable 3.3V power supply for the chip from a 5V supply. The 2.5 mm audio jack connector was mounted in order to provide a convenient and robust way of connecting the electrodes. The wiring up to the electrodes consists of a braided shield to protect the small signal against any possible outside interferences (see Appendix E). Lastly, the PCB was soldered onto a copper strip board for convenience. The ADS1292 testing procedure is as follows:

1. Check for solder bridges on the pins of the ADS and shorts between neighbouring breakout pins

2. Short test if electrode connections from the Jack connector to the ADS inputs are intact

3. Set up the wiring for the ADS

4. Check the power supply and the output of the voltage regulator

5. Set up the registers of the ADS for data collection

6. Generate a sine wave across the input and analyse the output

7. Record an ECG with conventional gel electrodes and compare results with self-made electrodes

It was decided to test the PCB with the gel electrodes across the chest where the signal is the strongest. Then, the gel electrodes were place on each biceps which is the optimal placement decided in section 4.1.2. The code that was used to retrieve data can be found on GitHub [25], and can be summed up with the following pseudo-code: configure Raspberry Pi Zero pins send ’ reset ADS1292 ’ configure registers{ 0x02 > register1 − 0xA0 > register2 − 0x60 > register4 −

Page 14 of 44 Imperial College London

0x80 > register5 − } send ’ s t a r t conversions ’ initialize record for 60 seconds { i f ADS1292 is data_ready{ input ADS1292 > record − } } save record

3.3 Data Collection

3.3.1 EMG and Accelerometer Data

Biceps EMG and its corresponding forearm acceleration data were collected (Visual rep- resentation in Annex E), from position C1 and M1 of figure 8 respectively, simultaneously over a range of motion (Flexion-Extension, rotation and eating motion). Thalmic Labs My- oBand was used to record EMG signals and the resulting forearm acceleration was recorded separately with a LIS3DH tri-axis accelerometer and Raspberry Pi Zero. MyoBand data was collected and stored directly onto a laptop via Bluetooth using the Myo Data Capture Software [30]. The LIS3DH accelerometer data was recorded by the Raspberry Pi Zero via I2C serial communication and the LIS3DH Python library written by Matt Dyson [31]. Both data were recorded at 200 Hz and initialized simultaneously. Each set of action was repeated every five seconds, at one motion cycle per second, over a period of one minute, giving approximately 10,000 usable samples per signal. Each motion was subsequently repeated at half a motion cycle per second. Data from four partici- pants were obtained, to account for varying EMG signals due to muscles, joints and kinetic redundancies. Hence a total of 240,000 EMG samples were eventually generated.

3.3.2 Generation of Noisy Data

Similar to the method used to generate noisy ECG signals in the MIT-BIH Noise Stress Test Database [13], the EMG signals collected from the MyoBand are normalized to fit the ampli- tude range [-1, 1]. The amplitudes were scaled with a scaling factor from 0.2 to 8, depending on the difficulty level desired for training the neural network. 10,000 samples of each EMG

Page 15 of 44 Imperial College London signal were added to the first 240,000 samples of each clean ECG signal in the database. The EMG signals, sampled at 200 Hz, were re-sampled to match the sampling rate of the clean ECG signals acquired from the MIT-BIH Arrhythmia Database [13], which is at 360 Hz to allow for the combination. The modified EMG signals were then added [25] onto clean ECG signals and the noisy ECG generated was used to train the machine learning algorithm.

3.4 Denoising Algorithm

3.4.1 Neural Network Training

The data generated using the method detailed above is reshaped so that each input sample is in the form of 4 by 300 matrix, where the first row is 300 data points of the ECG input and the following are the three axis of the accelerometer data. From this dataset, a quarter of the input samples are randomly sampled to create the validation dataset. This validation dataset is not included in the training of the neural network and later used to evaluate the performance to check for over-fitting. The model is trained by mini-batch gradient descent based on backpropagation. The forward pass generates the model output from noisy input. The loss is calculated using least absolute deviation (L1 or LAD) between the model output and the label set. The choice of the L1 loss over mean squared error (MSE) loss was made as the loss was significantly smaller than 1 in most cases. This loss is then back propagated to update the parameters following the ADAM optimization method [32]. Optimal hyper-parameter settings were decided by experimentation where each variation was trained for a minimum of 5,000 epochs using a batch size of 128.

3.4.2 Evaluation

To evaluate the performance of our neural network, we calculate the signal error ratio (SER) as follows, where R(n) and C(n) denotes the denoised signal and the clean signal of length N, respectively. PN 2 n 0 R (n) SER 10 log = = · 10 PN 2 n 0(R(n) C(n)) = − The SER is then compared against the performance of conventional filters reported in recent literature. As the performances from most of these literature are based on the MIT-BIH noise stress database [13], which is different from the evaluation dataset used for the neural networks, simple low pass filters are implemented in Matlab to verify the performance (see Appendix H). To evaluate the efficacy of having acceleration data, a model was trained with zero-mean of amplitude 0.05 in place of the acceleration.

Page 16 of 44 Imperial College London

Figure 12: (Left) The top 2 graphs shows the normalised raw ECG data and filtered ECG data as obtained by the standard gel electrodes. In comparison, the bottom 2 graphs a ECG signals obtained by electrode D (Silver conductive fabric). (Right) Average points scored from all participants and its corresponding standard deviation for each electrode.

4 Results

4.1 Electrode

4.1.1 Electrode Quality

The processed ECG signals were evaluated on a point-based system (maximum score of 14 points), against the rubrics shown in Section 3.1.3. Electrode D and G obtained ECG comparable to ECG collected by the standard Medi-Trace gel electrodes, scoring an average of 11.3, 11 and 11.3 respectively (figure 12, right). As seen in figure 12, ECGs from both the standard (top two graphs) and prototype D (bottom two) electrodes had defined P, QRS and T peaks, as well as minimal R peak variation (refer to Appendix F for rubrics of all electrodes). Electrodes A and B were removed from the results section due to its inconsistency in producing a clean ECG signal. The quality of ECG signals obtained by electrode prototypes are reasonably consistent with a small deviation in scores, especially for higher scoring electrodes (C, H and standard) as shown in figure 12.

Page 17 of 44 Imperial College London

Figure 13: (Left) Scores obtained from evaluating ECG signals evaluated at position pairs for same arm and across both arm. (Right) ECG evaluated based on rubrics for Electrodes Prototype at position B1-B2 and A1-A2 over a range of motion. Refer to Appendix F for the individual rubrics sheet.

4.1.2 Optimal Position Test

ECG signals in the same arm and across both arms showed similar quality at the same regions, when the subject is still (figure 13). Overall, quality and amplitude of ECG signals improve with decreasing distance from the heart, with electrodes pairs at D1, D2 and D3 (deltoids region) scoring the highest. However, when the subject performs a range of movement, electrode pairs along the same arm produces significantly better ECG signals (higher scores) than pairs on different arms with B1-B2 having the best results (Figure 13, right).

4.2 ECG Hardware and Printed Circuit Board

Figure 14: Fully assembled and wired printed circuit board

Page 18 of 44 Imperial College London

Figure 15: Signal recorded with the PCB through gel electrodes indoors. (Left) Time domain. (Right) Fourier domain.

All signals were recorded using the PCB and two electrode inputs at a gain of 22 dB. Initially, ECGs were recorded indoors, which produced corrupted signals shown in figure 15. Hence, ECGs were subsequently recorded outdoors, giving clearer signals shown in figure 16

Figure 16: (Top) Signal recorded with the PCB through gel electrodes and (Bottom) silver electrodes prototype D on each bicep. (Left) Raw ECG data obtained with PCB. (Right) Signals filtered with a first order Butterworth high-pass filter.

ECG were recorded from electrode pairs positioned on the same arm. Although some recognisable ECG was obtained using the gel electrodes (figure 17), no useful ECG was obtainable using the electrode prototypes when used on the same arm.

Page 19 of 44 Imperial College London

Figure 17: Processed ECG data recorded with PCB through gel electrodes on the biceps and triceps of the same arm (position B1-B2 at figure 8).

4.3 Denoising Algorithm

Qualitative analysis of the convolutional autoencoder performance is demonstrated in figure 18. It illustrates the output of the best performing variant on a noisy signal of SER 6. The denoised output is considerably cleaner than the noisy input, however a moderate smoothing of the QRS complex is observable. Figure 19 shows performance comparison to conventional filters used. The plot on the left is generated by comparing to the performance reported by Han et al. [33] in a review paper. This shows a clear performance enhancement with the convolutional autoencoder, however the performances are calculated using a different dataset. The plot on the right is an implementation of a low pass filter on the dataset used for the convolutional autoencoder. Figure 20 shows performance comparison between a convolutional autoencoder with and without corresponding acceleration data.

4.4 Overall design

The full armband assembly including the ADS1292 PCB, electrode prototype D (silver-plated textile electrode) on each biceps and the accelerometer could be tested with a one arm motion of rotation (figure 21).

Page 20 of 44 Imperial College London

Figure 18: Qualitative comparison of final model performance on sample 103 from the MIT-BIH arrhythmia database [13] with the y-axis being the normalized amplitude of the signal. The segment plotted was part of the validation dataset, hence it was not used in training of the model.

Figure 19: SER performance comparison to conventional filters. (Left) Compared to performance reported in literature [33] (Right) Compared to Low Pass Filter implemented on the dataset used for the project.

Page 21 of 44 Imperial College London

Figure 20: SER of denoised ECG against input ECG for convolutional autoencoder with and without accelerometer data.

Figure 21: Raw ECG signal recorded with the ADS1292 and simultaneous accelerometer data during a one arm rotation

5 Discussion

5.1 Electrodes

From section 4.1.1, it is shown that electrode armbands D and H designed in this project, are able to obtain ECG signals comparable, if not better, than those obtained with the commercial

Page 22 of 44 Imperial College London

Medi-Trace electrodes, which is widely used in hospitals. This has plenty of implications as unlike disposable gel electrodes, these armband electrodes are durable, comfortable and retains its effectiveness throughout its usage. With the use of a tight fitted armband, it is ensured that sufficient surface area of the electrodes are in close contact to the skin, allowing for cleaner and stronger ECG signals to be obtained with minimal motion artefact from movements of the wearable. Interestingly, electrode pairs on the same arm (B1-B2 of figure 13) produces higher quality signals for a range of movements than pairs across different arms. This is potentially due to some similar EMG noise, from the same muscle region of the arm, canceling to give observable ECG signals (difference between electrodes). However, when tested on other devices such as the ADS1292, solely two electrodes on the same hand caused significant baseline wander. Hence, electrodes across both arms, which gave more consistent and reliable results across different devices, were used for initial testing of the ADS1292 and neural networks. In the future, investigation for electrodes on the same arm will be carried out. Despite having the best ECG signals obtained from the deltoids (D2-D3, scoring 10 points in figure 13), position C1 at the lower biceps ( scored 9 points) was chosen as the ideal position when both comfort and quality of signals was considered. ECG signals obtained from PowerLab were taken indoors which constantly introduced a 50 Hz mains noise (figure 15). Using simple filters (refer to Appendix H) to obtain a clean signal were not the best denoising method due to the simplicity of the filter. As the filter does not account for baseline wander or other noise with frequency components less than 20 Hz, a more complex filtering method should be introduced.

5.2 Printed Circuit Board

According to figure 16 the ADS1292 is capable of recording ECG signals using only two elec- trodes on each biceps and no right leg drive. However, the ADS1292 responds inconsistently since a viable ECG signal was acquired after several trials. Moreover, data collection had to be conducted in an interference-free environment such as the outdoors. This is due to a 50 Hz mains noise interference that was found to be dominating the acquired data (figure 15) when recordings were conducted indoors. As a result, the differential amplifier saturates and distorts the signal, which results in non-viable data. For differential amplifiers, common interference between the inputs would be attenuated so the interference has to occur within the circuit. Thus, whilst implementing a 50Hz notch filter would seem ideal, it is arduous and insignificant. For instance, a twin-T network could be used to notch out the 50Hz but would require a ground which is both difficult and pointless for this circuit. Furthermore, eventhough the algorithm is capable of removing 50Hz interference (figure 22), the saturation

Page 23 of 44 Imperial College London

Figure 22: Example of the filtering action of the Machine Learning algorithm using data acquired with a PowerLab.

Figure 23: Variation of the internal reference and the bias current with temperature of the ADS1292. due to the interference makes it impossible to recover useful data. In future developments, a metal casing could be designed around the PCB to shield it. The ADS1292 heated up during operation, which raises concerns about thermal non- idealities. However, the ADS1292 shows strong invariance to temperature changes [23]: its internal voltage reference drops of an order of 1 mV between -40 and 85 ◦ C, and its input bias current remains very low (maximally 0.5 nA) through this range as well (figure 23).

Page 24 of 44 Imperial College London

5.3 Data Collection

The MyoBand and accelerometer data was collected onto two separate devices, a laptop and a Raspberry Pi Zero. It was essential that the recordings started simultaneously and was performed manually which may introduce a source of error. Additionally, it was noted that the sampling frequencies of both devices were not matched accurately at 200 Hz. The mismatch becomes significant when recording for long periods of time (> 2 minutes), as the time error accumulates. This mismatch was due to the sampling rate of the Raspberry Pi Zero approximating 200 Hz. A better method of data collection would have been to use a single device, for the recording of both EMG and accelerometer data. Having the same sampling frequency will enable the synchronization of both the initialization and recording of the data. Furthermore, whilst performing the specified movements, (flexion-extension, rotation, eating) physical restraints should have been used to isolate certain muscle groups and ensure only specific movements were performed; e.g. to avoid a combination of flexion-extension and supination-pronation. In addition, other input parameters and their resulting noise contributions could be recorded and included in the training data to represent a more accurate model of a noisy ECG signal. An example would include the change in impedance of the recording device due to temperature resulting in a baseline wander.

5.4 Denoising Algorithm

Qualitative and quantitative analysis of the results lead to a few general observations regard- ing the hyper-parameters of the convolutional autoencoder. First, larger filter sizes in the first convolution layer lead to smoothing of the reconstructed signal. This is understandable considering the nature of convolutions as neighborhood operators. Second, TanH activation layers seem to be advantageous over ReLU [34] layers as they prevent loss of gradient infor- mation that may be needed for reconstruction. Third, models deeper than the presented version tend to overfit leading to a performance gap between the training and validation set. Neural networks are generally very difficult to interpret in terms of how it generates the output due to the high level of non-linearity in its operations. In the case of the convolutional autoencoder trained for this project however, feeding to the network generated some interesting results. In figure 24, the periodogram of the network output of the white noise is very similar to that of the clean ECGs used as labels during training. Not only do they have similar distributions across the frequency domain but they also reconstruct the characteristic frequency peaks seen in the clean ECGs. This indirectly shows that the

Page 25 of 44 Imperial College London convolutional autoencoder has learned some of the key features of an ECG signal. The comparison between the convolutional autoencoder model with and without acceler- ation data in figure 20 clearly shows that acceleration data is useful in denoising at least in our model. A one-sided T-test showed statistically significant (p-value < 0.05) improvement for inputs with SER higher than 7. For inputs with lower SER, the T-test failed to show statistical significance. This is expected as under a certain SER level, the signal will become too noisy to reconstruct properly with or without acceleration data. In this perspective, we can view our approach as a robust non-linear adaptive filter that adjusts the filter coefficients based on acceleration input, which is what the convolution operators may indeed be doing. Further work may be to visualize the trained convolutional filters to see if such interpretations are valid. Even with the robust non-linear approximation properties of neural networks, it was difficult to retain sharp QRS peaks while suppressing the noise. While a popular way of overcoming this is through peak detection [35], the level of noise generated during movement is much too high to apply such methods reliably. As the application of empirical mode decomposition (EMD) [36] has shown some of the best performances [33, 35] in ECG signal denoising, EMD was integrated into the design of the neural network architecture as seen in figure 25. The EMD method decomposes a signal in the time domain into several components called intrinsic mode functions (IMF). The IMFs of the noisy input are individually passed through a separately trained convolutional autoencoder to create denoised IMF components,

Figure 24: Periodogram of (Top) Training data from MIT-BIH database (Middle) White Noise (Bottom) CAE output from white noise.

Page 26 of 44 Imperial College London which are then used to reconstruct a denoised ECG. This may allow the individual networks to be further converged to the respective noise characteristics present within each IMF.However, due to time restraints, full convergence all of the parallel networks was not achieved.

5.5 Market Needs

Current wearable ECG devices include the Holter-Monitor [37] and AliveCor [38]. The Holter- Monitor provides a 24-hours ECG monitoring device and offers live interpretation of the signals. However, the device is uncomfortable, bulky and expensive. The alternative, AliveCor is a small and portable device that records short ECG signals upon activation. This device is limited due to the discontinuous short ECG recordings as the user’s inability to move during

Figure 25: Architecture of the EMD-variant Convolutional Autoencoder model.

Page 27 of 44 Imperial College London recording. The identified market needs for a wearable ECG device is thus comfortability, and robust long-term measurements of an ECG invariant to motion artefacts. Following these market needs, the proposed device achieves an intermediate stance in between the Holter-Monitor and AliveCor. Additionally, with the current machine learning algorithm, the proposed device is able to achieve significant long-term ECG recordings while being invariant to EMG noise, the primary motion artefact. Thus, the proposed design satisfies the current market need but remains below commercial standards and requires extensive research to be viable.

6 Conclusion

The aim of the project was to design a low-power wearable ECG monitoring device that is robust under the noise conditions of a moving subject. The results have shown substantial success under specific conditions which holds great potential for such a device to be fully implemented. Reliable, comfortable electrodes were designed, with their optimal positions identified. Furthermore, the proposed PCB design successfully worked in conjunction with the elec- trodes to produce usable and medically relevant ECG signals. The denoising algorithm itself was also successful and showed a significant performance enhancement over conventional filters in denoising EMG artefacts. However, because the denoising algorithm was trained on ECGs from the MIT-BIH database [13], which has a different hardware setting from the proposed device, and also focused specifically on EMG noise, the algorithm was not able to perform well on signals obtained from the proposed device without acceleration data. Although the device is already able to detect signals with motion artefacts and record all signals simultaneously (ECG and Acceleration), due to time constraints, the machine learning algorithm could not be evaluated on the final complete datasets. A wider range of participants and training on data collected from the proposed device will likely show improvements in denoising performance. Following these findings, the proposed device is a suitable prototype for a longterm wearable ECG monitor but will require additional research and development.

Page 28 of 44 Imperial College London

References

[1] W. Newham and M. Tayebjee, “Excellent symptom rhythm correlation in patients with palpitations using a novel smartphone based event recorder,” Journal of atrial fibrilla- tion, p. 10, 6 2017.

[2] W. Newham and M. Tayebjee, “Excellent symptom rhythm correlation in patients with palpitations using a novel smartphone based event recorder,” Journal of atrial fibrilla- tion, 6 2017.

[3] K. G. Tarakji, O. M. Wazni, T. Callahan, M. Kanj, A. H. Hakim, K. Wolski, B. L. Wilkoff, W. Saliba, and L. Bd., “Using a novel wireless system for monitoring patients after the atrial fibrillation ablation procedure: the itransmit study,” Heart Rhythm, vol. 31, 3 2015.

[4] K. T. Hickey, J. Dizon, and A. Frulla, “Detection of recurrent atrial fibrillation utilizing novel technology,” Journal of Atrial Fibrillation, vol. 6, 12 2013.

[5] V. P.Rachim and W. Chung, “Wearable noncontact armband for mobile ecg monitoring system,” Biomedical Circuits and Systems,, pp. 1112–1118, 6 2016.

[6] M. Akhbari, M. B. Shamsollahi, C. Jutten, A. A. Armoundas, and S. O. E. denoising and, “and fiducial point extraction using an extended kalman filtering framework with linear and nonlinear phase observations,” Physiological measurement, vol. 15, p. 203, 1 2016.

[7] M. A. Kabir and C. Shahnaz, “Denoising of ecg signals based on algo- rithms in emd and wavelet domains,” Biomedical Signal Processing and Control, vol. 30, pp. 481–489, 9 2012.

[8] Y. F.Tan and L. Du, “Study on wavelet transform in the processing for ecg signals,” in InSoftware Engineering (IEEE, ed.), pp. 515–518, WCSE’09, WRI World Congress, 2009.

[9] M. Alfaouri and D. K., “Ecg signal denoising by wavelet transform thresholding,” Ameri- can Journal of applied sciencesMar;, pp. 276–81, 3 2008.

[10] V. Acharya Texas Instrument datasheet, 2011.

[11] C. L. Ng and R. Mbi., “Characterization of textile-insulated capacitive biosensors,” Sen- sors (Switzerland), no. 17, 2017.

Page 29 of 44 Imperial College London

[12] T. Bystrick?, D. Moravcova, P. Kaspar, R. Soukup, and A. Hamacek, “A comparison of embroidered and woven textile electrodes for continuous measurement of ecg. proc int spring semin electron technol,” IEEE, vol. 10, pp. 7–11, 11 2006.

[13] A. L. Goldberger, A. Lan, L. Glass, J. M. Hausdorff, I. PCh, R. G. Mark, J. E. Mietus, G. B. Moody, P. C-k, and S. H. PhysioBank, “Physiotoolkit, and physionet: Components of a new research resource for complex physiologic signals,” Circulation, pp. 215–220, 6 2000.

[14] I. I. Christov and D. Ik., “Filtering of electromyogram artifacts from the electrocardio- gram,” Medical engineering and physics, pp. 731–736, 12 1999.

[15] I. Romero, D. Geng, and T. Berset, “Adaptive filtering in ecg denoising: A comparative study,” Computing in Cardiology (CinC), 2012.

[16] A. Lanata et al., “A novel algorithm for movement artifact removal in ecg signals acquired from wearable systems applied to horses,” PloS one, 10 2015.

[17] P.Xiong, H. Wang, M. Liu, F.Lin, Z. Hou, and X. Liu, “A stacked contractive denoising auto-encoder for ecg signal denoising,” Physiological measurement, p. 7, 11 2016.

[18] P.Vincent, H. Larochelle, I. Lajoie, Y. Bengio, and M. Pa., “Stacked denoising autoen- coders: Learning useful representations in a deep network with a local denoising crite- rion.,” Journal of Machine Learning Research, vol. 11, pp. 3371–3408, 12 2010.

[19] G. B. Moody and M. Rg., “The impact of the mit-bih arrhythmia database,” IEEE Eng in Med and Biol, pp. 45–50, 5-6 2001.

[20] A. L. Goldberger, L. A. Amaral, L. Glass, J. M. Hausdorff, P. C. Ivanov, R. G. Mark, J. E. Mietus, G. B. Moody, C. K. Peng, and S. He., “Physiobank, physiotoolkit, and physionet,” pp. 215–220, 6 2000.

[21] Hitek, “Shieldex® bremen rs; no: 110010180.” 2016.

[22] V. Marozas, A. Petrenas, S. Daukantas, and A. Lukosevicius, “A comparison of conductive textile-based and silver/silver chloride gel electrodes in exercise electrocardiogram recordings,” J. Electrocardiol., vol. 44, no. 2, pp. 189–194, 2011.

[23] T. Instruments, “Ads1292 datasheet,” Available at: [Accessed, 12 2011.

[24] www.e2v.com, “Design considerations for mixed-signal pcb layout.”.

Page 30 of 44 Imperial College London

[25] W. Hwang, “Woo-h/ecg_denoising, github,”

[26] A. D. Child, “?method of enhancing the stability of conductive polymers,? us5833884 a,” 1995.

[27] C. L. Ng and M. B. I. Reaz, “Characterization of textile-insulated capacitive biosensors,” Sensors (Switzerland), vol. 17, no. 3, 2017.

[28] S. Kim and al., “Influence of contact pressure and moisture on the signal quality of a newly developed textile ecg sensor shirt,” pp. 256–259, Proc. 5th Int. Work. Wearable Implant. Body Sens. Networks, BSN2008, conjunction with 5th Int. Summer Sch. Symp. Med. Devices Biosensors, 2008.

[29] T. Instruments, “Tps71733dckr datasheet,”

[30] market.myo.com Myo Data Capture. [online], 2018.

[31] M. Dyson, M. Smalley, and T. Holzfigure, “mattdy/python-lis3dh. [online] github.” [Ac- cessed 31 May 2018], 2016.

[32] Kingma, D. P.,and J. Ba., “Adam: A method for stochastic optimization,” preprint, arXiv, 2014.

[33] G. Han, B. Lin, and Z. Xu., “Electrocardiogram signal denoising based on empirical mode decomposition technique: An overview,” Journal of Instrumentation, p. P03010, 3 2017.

[34] X. Glorot, A. Bordes, and Y. Bengio, “Deep sparse rectifier neural networks,” in Proceed- ings of the Fourteenth International Conference on Artificial Intelligence and Statistics, 2011.

[35] B. Weng, M. Blanco-Velasco, and K. E. Barner, “Ecg denoising based on the empirical mode decomposition,” in Engineering in Medicine and Biology Society, 2006. EMBS’06. 28th Annual International Conference of the IEEE., 2006.

[36] N. E. Huang et al., “The empirical mode decomposition and the hilbert spectrum for nonlinear and non-stationary time series analysis,” Proceedings of the Royal Society of London A: mathematical, physical and engineering sciences, vol. 454, no. 1971, 1998.

[37] N. F.Trust, “Trust ?ecg holter monitor test ? (2015) [online],” 2015.

[38] AliveCor, “Alivecor: how it works.”.

Page 31 of 44 Imperial College London

Appendix A Product Evaluation Matrix

Figure 26: Product Evaluation Matrix with notes for future improvements

Page 32 of 44 Imperial College London

Appendix B Task Allocation

Figure 27: Task Allocation for Autumn Term

Figure 28: Task Allocation for Spring-Summer Term

Page 33 of 44 Imperial College London

Appendix C Bill of Materials

Figure 29: Table for bill of materials for this project

Page 34 of 44 Imperial College London

Appendix D PCB design incorporating ADS1291

Figure 30: PCB schematic

Figure 31: PCB layers

Page 35 of 44 Imperial College London

Figure 32: ADS1292 pins and their functions

Page 36 of 44 Imperial College London

Appendix E ECG Hardware connections and EMG-Accelerometer Data Collection

Figure 33: (Left) Shielded electrode to PCB connecting wires (Right) Fully assembled and wired PCB

Figure 34: Data collection with MyoBand and accelerometer attached to armband

Page 37 of 44 Imperial College London

Appendix F Electrodes Evaluation Rubrics and Data

Figure 35: Evaluation rubrics for electrodes quality and optimal position test. Optimal position testing over a range of movements were evaluated on a rubrics data excluding variations and baseline wander

Figure 36: Testing of prototype electrodes with the PowerLab device

Figure 37: Obtaining ECG with Medi-Trace gel electrodes for benchmark

Page 38 of 44 Imperial College London

Figure 38: Normalised raw ECG data and filtered ECG data of participant 1 used for evaluation of ECG quality. Left column from top to bottom: Electrodes C, D, E, F and for the right column from the top: G, H, standard gel electrodes. ECG signals of participant 2 and 3 were processed and analysed in a similar fashion.

Page 39 of 44 Imperial College London

Figure 39: Summarised scores of ECG signals obtained from different electrodes for participant 1, 2 and 3, as compared against the evaluation rubrics above

Page 40 of 44 Imperial College London

Appendix G Electrode prototype designs

Capacitive-coupled electrodes

Figure 40: Design of capacitive coupled electrode with Metal plate, dielectric/Insulating cloth in- tegrated to the armband. Layering (top left), cross section assembled view (top right), assembled electrode with stiches sewn to integrate it into armband

Conductive fabric electrodes

Figure 41: Design of conductive fabric as textile electrodes

Conductive fabric with foam electrodes

Page 41 of 44 Imperial College London

Figure 42: (Left) Textile electrode consisting of conductive fabric with an underlying foamed material. (Right) Side view of a different type of flexible electrode which utilises foam as both an electrostatic shield but also as an electrode surface Kim et al.

Page 42 of 44 Imperial College London

Appendix H Filter frequency response used for ECG filtering

Notch filter used removed 50Hz noise. The SNR was estimated from the periodogram (PSD) estimate defined by the normalized absolute square of the Fourier Transform of the unfiltered ECG signal. The signal was defined as the sum of the frequency range between 0 and 20Hz whereas the noise was defined as the sum above 20Hz. The equation to calculate SNR 10 Powerof signal = · log10 Powerofnoise . All processes were done using the MATLAB inbuilt functions of designfilt, filter/filtfilt, fft and fftshift.Refer to figure 43 for plot of frequency response in low pass filters tested with.

Figure 43: (Top): Linear frequency response where Fpass = 40 Hz; Fstop = 65 Hz; Apass = 1 dB, gain for the pass band; Astop = 95 dB, reduction for the stop band; Fs = 1e3 Hz, sampling frequency. (Bottom) Strict frequency response where Fpass = 15 Hz; Fstop = 65 Hz; Apass = 1 dB, gain for the pass band; Astop = 150 dB, reduction for the stop band; Fs = 1e3 Hz sample frequency

Page 43 of 44 Imperial College London

Appendix I PyTorch Implementation of Convolutional Autoen- coder

Figure 44: Convolutional Autoencoder Python Code

Page 44 of 44 Imperial College London

Page 45 of 44