0% found this document useful (0 votes)
52 views185 pages

Braveheart Userguide

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 185

BRAVEHEART: Open-Source Software for

Automated Electrocardiographic and


Vectorcardiographic Analysis

User Guide
Software Version 1.1.2

Hans Fredrich Stabenau, MD, PhD & Jonathan W. Waks, MD


Harvard-Thorndike Electrophysiology Institute, Department of Cardiovascular Medicine,
Beth Israel Deaconess Medical Center, Harvard Medical School, Boston, MA, USA

http://www.github.com/BIVectors/BRAVEHEART

Copyright © 2016-2024 Hans Fredrich Stabenau & Jonathan W. Waks


All Rights Reserved

Document Version 2/27/2024


Contents
1 Introduction 5
2 Version History/Changelog 6
3 Abbreviations 8
4 Installation 9
4.1 Using MATLAB Source Code (For Users With MATLAB) . . . . . . . . . . . . 9
4.2 Using Executables (For Users Without MATLAB) . . . . . . . . . . . . . . . . . 10
4.2.1 Install the MATLAB Runtime . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2.2 Install BRAVHEART Executables on a Windows PC . . . . . . . . . . . . 11
4.2.3 Install BRAVHEART Executables on a Mac . . . . . . . . . . . . . . . . . 13

5 Quick Start Using the BRAVEHEART GUI 16


5.1 Example 1 - Good Quality ECG . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Example 2 - ECG with PVCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 Example 3 - ECG with Artifact . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.4 Example 4 - Dealing with Pacing Artifact . . . . . . . . . . . . . . . . . . . . . 32
5.5 Example 5 - Using .anno Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.6 Editing Beats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.7 Removing Beats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.8 Adding Beats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.9 Removing PVCs and other Non-Dominant Beats . . . . . . . . . . . . . . . . . 40
5.10 Removing Outlier Beats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.11 Manually Adjusting Median Beat Annotations . . . . . . . . . . . . . . . . . . . 43
5.12 Exporting Measurements to a Text File . . . . . . . . . . . . . . . . . . . . . . . 44
5.13 Exporting Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.14 Exporting Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6 Annotation Parameters ( Annoparams.m ) 46


6.1 Annoparams Properties ( Annoparams.m ) . . . . . . . . . . . . . . . . . . . . . . 47
6.2 Annoparams Property Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . 48

7 Adjusting Denoising/Filtering Settings 56


7.1 High-frequency Denoising (Low-pass Filtering) . . . . . . . . . . . . . . . . . . . 56
7.2 Low-frequency Denoising (High-pass Filtering) for Baseline Wander Removal . . 58
7.3 Denoising/Filtering Frequencies and Visualizing Results . . . . . . . . . . . . . 59
7.4 Denoising/Filtering Using braveheart_batch.m . . . . . . . . . . . . . . . . . . 60

8 Adding New ECG Formats 61


8.1 The ECG12 Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
8.2 Editing ECG12.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.3 Editing ecg_formats.csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.4 Using Newly Added ECG File Formats . . . . . . . . . . . . . . . . . . . . . . . 65

1
9 Adding New Transformation Matrices 66
9.1 Create a Function for The New Transformation Matrix . . . . . . . . . . . . . . 66
9.2 Editing ecgtransform.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.3 Editing transform_mat.csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.4 Using Newly Added Transformation Matrices . . . . . . . . . . . . . . . . . . . 67

10 Adding New ECG/VCG Parameters 69


10.1 Result Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
10.1.1 VCG_Calc.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
10.1.2 Lead_Morphology.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
10.1.3 VCG_Morphology.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
10.2 Adding a New Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

11 Adding New Denoising/Filtering 75


11.1 Calling the ECG Denoising/Filtering Function from ECG12.m . . . . . . . . . . . 75
11.2 Editing ecgfilter.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11.3 Editing ECG12.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

12 Using the BRAVEHEART GUI 79


12.1 GUI Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
12.2 GUI Section 1  ECG Loading, Filtering, R Peak Detection, and Baseline Correction 81
12.3 GUI Section 2  VCG Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
12.4 GUI Section 3  Fiducial Point Annotation and Median Beat Creation/Annotation 87
12.5 GUI Section 4  Median Beat Display and Quality Assessment . . . . . . . . . . 90
12.6 GUI Section 5  Select Displayed Information . . . . . . . . . . . . . . . . . . . 92
12.7 GUI Section 6  GUI Information Display . . . . . . . . . . . . . . . . . . . . . 94
12.8 GUI Section 7  Display Various Figures . . . . . . . . . . . . . . . . . . . . . . 105
12.9 GUI Section 8  Beat Editing, Addition, and Removal . . . . . . . . . . . . . . 107
12.10 GUI Section 9  PVC/Non-Dominant and Outlier Beat Removal . . . . . . . . . 110
12.11 GUI Section 10  GUI Toolbar for Interacting with Figures . . . . . . . . . . . . 111

13 Batch Processing ECGs with braveheart_batch.m 112


13.1 Batch Processing Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.2 Batch Processing via MATLAB Command Line . . . . . . . . . . . . . . . . . . 115
13.3 Batch Processing Using the Command Line Stand-Alone Executable . . . . . . 116
13.4 braveheart_batch.m Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

14 Batch Processing ECGs via GUI ( braveheart_gui.m ) 119


15 BRAVEHEART ECG/VCG Processing 122
15.1 R Peak Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
15.2 Baseline Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
15.3 PVC and Non-Dominant Beat Morphology Detection . . . . . . . . . . . . . . . 126
15.4 Outlier Beat Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

2
16 ECG Quality Assessment 130
16.1 Quality Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
16.2 Quality Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
16.3 Editing Quality Filtering Parameters - Qualparams.m . . . . . . . . . . . . . . . 132
16.4 Quality Output Files During Batch Processing . . . . . . . . . . . . . . . . . . . 133
16.5 Quality Output When Using the GUI . . . . . . . . . . . . . . . . . . . . . . . . 134
16.6 Other Uses for Quality Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

17 Using .anno Files 136


17.1 Generating .anno Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
17.2 Using .anno Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

18 First Pass Annotation 139


18.1 First Pass Annotation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 139
18.2 First Pass Annotation Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
18.3 Common Annotation Parameter Problems . . . . . . . . . . . . . . . . . . . . . 141

19 Neural Network Median Beat Annotation 143


20 Figures 145
20.1 Summary Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
20.2 12-Lead ECG/VCG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
20.3 Median Beats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
20.4 Normal Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
20.5 VCG Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
20.6 3D VCG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
20.7 Lead Morphology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
20.8 Animated VCG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
20.9 X-, Y-, Z- Stats Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
20.10 Full VCG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
20.11 Osets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
20.12 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
20.13 Threshold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
20.14 Debug Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
20.15 Angle Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

21 Annotation Parameter Presets 158


22 Normal Ranges 160
23 ECG Format Information 161
24 Result Class Variables 164
24.1 VCG Morphology Class ( VCG_Morphology.m ) . . . . . . . . . . . . . . . . . . . 164
24.2 VCG Calculation Class ( VCG_Calc.m ) . . . . . . . . . . . . . . . . . . . . . . . . 165
24.3 Lead Morphology Class ( Lead_Morphology.m ) . . . . . . . . . . . . . . . . . . . 167

25 Equations 168

3
26 Annotation Parameter Links with GUI 174
27 Testing Framework 175
28 Troubleshooting/Help/FAQs 176
28.1 The GUI is Cut O/Missing Some Features . . . . . . . . . . . . . . . . . . . . 176
28.2 My ECG Won't Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
28.3 Safe Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
28.4 The ECG Loads but I get an Error When Press Calculate . . . . . . . . . . . . 177
28.5 A Measured Parameter Returns as NaN . . . . . . . . . . . . . . . . . . . . . . 177
28.6 Error Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
28.7 Debugging Annotation Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
28.8 How should I cite use of the BRAVEHEART software? . . . . . . . . . . . . . . 178
28.9 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

29 External Code/Files 182


30 References 183

4
1 Introduction

BRAVEHEART ( Beth Israel Analysis of Vectors of the Heart) is a modular, customizable,


open-source software package for processing electrocardiograms (ECGs) and vectorcardiograms

(VCGs) for research purposes. BRAVEHEART was built using MATLAB and requires a version

after R2022a (http://www.mathworks.com). The most up to date version of the software can be

found on GitHub at http://www.github.com/BIVectors/BRAVEHEART, where the software, source

code, and executables for Windows and Mac are available under version 3 of the General Public

License (GPL) (http://www.gnu.org/licenses/gpl-3.0.en.html).

The following document contains information on how to use BRAVEHEART and how to

eciently edit select parts of the source code to allow addition of new ECG formats,

transformation matrices, ECG/VCG parameters, and new denoising/ltering methods.

Information on the inner-workings of the software is also provided to facilitate understanding

exactly what the software is doing at each step of ECG/VCG processing. This document is

focused on use of the BRAVEHEART software. For additional, detailed information on the

methodology behind various aspects of signal processing and annotation, please see our separate

methods manuscript [1] which is also available on the BRAVEHEART GitHub repository as le

braveheart_methods.pdf .

BRAVEHEART is available in dierent packages that will t the needs of dierent types of

users. braveheart_batch.m is a command line based program without any graphical user

interface (GUI) that is able to rapidly process directories of ECGs by setting a few parameters.

braveheart_gui.m is a GUI based version of BRAVEHEART that allows additional control over

every aspect of ECG/VCG processing and additional types of signal processing and data

visualizations. Both the command line version and GUI version of BRAVEHEART are also

available as compiled executables for Windows and Mac computers that can be run without the

need to have MATLAB installed.

We hope that BRAVEHEART will be helpful for your ECG/VCG research projects and welcome

any feedback, bug reports, criticisms, or suggestions that you have while using BRAVEHEART.

We can be contacted at braveheart.ecg@gmail.com with any questions, suggestions, or

concerns.

5
2 Version History/Changelog
ˆ v1.0.0  5/1/2023: Initial public release

ˆ v1.0.1  9/12/2023: See GitHub Releases for detailed change log.

 Added additional mother wavelets/wavelet levels to the GUI dropdowns.

 Added error handling for selecting wavelet decomposition levels > max level.

 Default high-frequency denoising (low-pass ltering) wavelet decomposition level in


Annoparams.m
and Annoparams.csv set to 1 (was 2). This changes the low-pass cuto from 62.5 Hz to 125 Hz for an
ECG sampled at 500 Hz. The default value can be changed by editing Annoparams.m when running
via MATLAB or Annoparams.csv when running via executable.

 When choosing a new ECG format in the GUI, the default low-frequency denoising (high-pass
ltering) is set to the highest level with frequency cuto Chapter 7).
< 0.25 Hz (see

 Updated normal range values based on our new publication [2] (see Chapter 22).
 Added ability to read Cardiosoft XML les (see Chapter 23).

ˆ v1.0.2  9/29/2023: See GitHub Releases for detailed change log.

 Fixed a bug related to median beat annotations being incorrect by a small number of samples if the
ECG sampling frequency was not 500 Hz or 1000 Hz.

 Became aware of a bug that results in parallel ECG batch processing not working only when using a
compiled executable version of BRAVEHEART (both GUI and command line). While a x is being
worked on, parallel processing via the compiled versions of BRAVEHEART has been disabled.

 Fixed a bug that resulted in errors which prevented calculating results in the `LeadMorphology.m'
results class for ECGs sampled at < 500 Hz.

 Updated functions to load DICOM, HL7 XML, and Cardiosoft XML ECG les to deal with dierent
versions of these le formats (see Chapter 23).
 Fixed issue that caused the Osets and Lead Morphology button/functions to not display properly if
an ECG lead was missing (see Chapter 12.2 and Chapter 12.6).

ˆ v1.1.0  10/5/2023: See GitHub Releases for detailed change log.

 Refactored quality assessment to x the bug that caused an error when using parallel ECG batch
processing in a compiled executable version of BRAVEHEART. The external le
quality_presets.csv was renamed Qualparams.csv . While running BRAVEHEART via MATLAB
Qualparams.m which is analagous to
source code, quality parameters are now set using the le
Annoparams.m . The external le Qualparams.csv is only used when running BRAVEHEART via
compiled executables. See Chapter 16.3 for further details of these changes.
 Fixed bug that caused errors when running parallel batch processing via compiled executables.

 Added quality test cases to test_braveheart.m (see Chapter 27).


 Added console logging when using executable versions to assist with troubleshooting any errors (see
Chapter 28.6).

ˆ v1.1.1  12/6/2023: See GitHub Releases for detailed change log.

 Added function to calculate the QRS frontal plane axis (see Chapter 25).
 Added QRS area, T area, and QRST area for the 12 standard ECG median beats to
Lead_Morphology.m results class.

 Added new gure that graphically displays QRS fontal plane axis when clicking on the
Lead Morphology button (see Chapter 12.2 and Chapter 12.6).

6
 Added quality test cases to test_braveheart.m reecting additions to Lead_Morphology.m (see
Chapter 27).
 Updated angle information gure displayed by clicking on the Angle Info button (See Chapter
12.7) to better clarify the denition of angle elevation in spherical coordinates.
 Fixed some bugs related to processing ECGs with sampling frequencies other than 500 Hz.

ˆ v1.1.2  2/27/2024: See GitHub Releases for detailed change log.

 Updated load_philipsxml.m to allow loading of more variations in Philips XML format les.

 Fixed bug that prevented display of the Filtering gure in the GUI (see Chapter 20.12).
 Mac OS: Fixed bug that prevented display of external reference les (userguide, equations, etc) from
their respective buttons when running the compiled GUI.

 Added some missing le format extensions to get_source_ext.m

7
3 Abbreviations
ˆ BIDMC  Beth Israel Deaconess Medical Center
ˆ BMI  body mass index
ˆ bpm  beats per minute
ˆ DC  direct current
ˆ DICOM  Digital Imaging and Communications in Medicine
ˆ ECG  electrocardiogram
ˆ GPL  general public license
ˆ GUI  graphical user interface
ˆ HL7  Health Level Seven
ˆ HR  heart rate
ˆ ISHNE  International Society for Holter and Noninvasive Electrocardiology
ˆ LSTM  Long-Short Term Memory
ˆ NN  neural network
ˆ NCC  normalized cross correlation
ˆ OS  operating system
ˆ PVC  premature ventricular contraction
ˆ Qon  QRS complex onset
ˆ Qoff  QRS complex end/oset
ˆ RMSE  root mean square error
ˆ SNR  signal to noise ratio
ˆ SVG  spatial ventricular gradient
ˆ Toff  T Wave end/oset
ˆ VCG  vectorcardiogram
ˆ VM  vector magnitude
ˆ XML  extensible markup language

8
4 Installation

The most up to date MATLAB source code and executables for Windows and Mac operating

systems can be found on the BRAVEHEART GitHub repository at

http://www.github.com/BIVectors/BRAVEHEART.

4.1 Using MATLAB Source Code (For Users With MATLAB)


Using BRAVEHEART via source code requires MATLAB R2022a or later and the
following toolboxes (https://www.mathworks.com/products.html):

ˆ Signal Processing

ˆ Deep Learning

ˆ Wavelet

ˆ Parallel Computing (optional)

ˆ Image Processing (optional  only for reading DICOM les  see Chapter 23)

To get a copy of the latest source code, open the BRAVEHEART GitHub and click on the

button:

From here you can download a .zip le of all of the source code or clone the GitHub repository

to your computer.

Alternatively, you can click the `Releases' link on the right hand side, or go directly to

9
http://github.com/BIVectors/BRAVEHEART/releases and download a .zip le of all of the

source code for a specic release. If you download the source code this way make sure you obtain

the most recent release.

You can now view/edit/run the source code:

ˆ To run the GUI version of BRAVEHEART run braveheart_gui from within MATLAB as

described in detail in Chapter 12.

ˆ To run the command line version of BRAVEHEART run braveheart_batch() from within

MATLAB as described in detail in Chapter 13.

4.2 Using Executables (For Users Without MATLAB)


If you do not have access to MATLAB, or if you have MATLAB but do not have access to all of

the required toolboxes, BRAVEHEART can be run via a compiled executable which contains the

core MATLAB functions and all of the required and optional MATLAB toolboxes. Open the

BRAVEHEART GitHub and navigate to the `Releases' link on the right hand side, or go directly

to http://github.com/BIVectors/BRAVEHEART/releases.

Note that the most current release may be after v1.0.0 and we suggest that you download the

10
most recent version of the software. Download the .zip le that is appropriate for your

operating system, unzip it, and then follow the instructions below. The les

braveheart_windows_x.x.x.zip.md5 and braveheart_mac_x.x.x.zip.md5 contain the MD5

hashes for their respective .zip les (where x.x.x is the release version) if you would like to

verify the contents of the .zip le before unzipping.

You must unzip/install the executable in a folder that has write access so that various les that

are required for BRAVEHEART to function are editable.

4.2.1 Install the MATLAB Runtime


The MATLAB Runtime is a set of libraries that allow execution of compiled MATLAB code.

The R2022a (9.12) version of the Runtime must be installed to run any version of the compiled
BRAVEHEART programs.

The MATLAB Runtime only needs to be installed once. To install there are 2 options:

1. Go to https://www.mathworks.com/products/compiler/matlab-runtime.html and

download the R2022a (9.12) Runtime for Windows or Mac.


2. Within the downloaded .zip le there is a shortcut to directly download the appropriate

(Windows or Mac) Runtime version.

After downloading, run the MATLAB Runtime installer and follow the instructions to complete

the installation. Depending on the security settings of your computer you may need

administrator rights to install the MATLAB Runtime.

4.2.2 Install BRAVHEART Executables on a Windows PC


After installing MATLAB Runtime R2022a (see above), unzip the braveheart_windows.zip le

in a directory that has write access (on some systems, depending on security settings, the

`Program Files' folder may not work). You will see the 12 following les/folders:

ˆ braveheart_gui.exe  BRAVEHEART GUI version (see Chapter 12).


ˆ braveheart_batch.exe  BRAVEHEART Command line version (see Chapter 13).
ˆ Annoparams.csv  File to edit annotation parameters (see Chapter 6).
ˆ ecg_formats.csv  File to add new ECG formats (see Chapter 8).

11
ˆ transform_mats.csv  File to add new transformation matrices (see Chapter 9).
ˆ batch_settings.csv  File to edit command line batch parameters (see Chapter 13).
ˆ Qualparams.csv  File to edit quality parameters (see Chapter 16).
ˆ search_presents.csv  File to edit annotation presets (see Chapter 21).
ˆ braveheart_userguide.pdf  This le.

ˆ Example ECGs  Directory containing 4 example ECG les (see Chapter 5).
ˆ Download MATLAB Runtime - Windows 64 bit  Link to download MATLAB Runtime.

ˆ splash.png  Image used while loading.

The external .csv les can be edited as needed and described in later sections of the user guide.

If you are unable to edit the .csv les, unzip braveheart_windows.zip in a dierent directory

with write access. The .csv les need to be in the same directory as the .exe les.

Double click on braveheart_batch.exe or braveheart_gui.exe to run the program.

Whitelist BRAVEHEART on Windows Runtime Protection


Depending on your version of windows and your anti-virus software, when you run

braveheart_gui.exe or braveheart_batch.exe for the rst time, a pop-up may block execution

of the program. If the Windows Defender pop-up blocks execution of the program simply click

 More Info and then  Run anyway:

The exact appearance and text may vary depending on your version of Windows and specic

12
security settings. If an alternative security program is in use, there will be a similar way of

whitelisting the executable so that in the future, when you run it, the OS will not block it. This

process will only have to be repeated if you install a new version of BRAVEHEART.

4.2.3 Install BRAVHEART Executables on a Mac


After installing MATLAB Runtime R2022a (see above), unzip the braveheart_mac.zip le in a

directory that has write access. You will see the 15 following les/folders:

ˆ install_csv.command  Script to copy .csv les to appropriate directory and to

disable Mac OS runtime protection for relevant les (see next paragraphs in this section).

ˆ braveheart_gui.app  BRAVEHEART GUI version (see Chapter 12)


ˆ braveheart_batch.app  BRAVEHEART Command line version (see Chapter 13).
ˆ run_braveheart_gui.sh  Script used by MATLAB

ˆ run_braveheart_batch.sh  Script used by MATLAB

ˆ Annoparams.csv  File to edit annotation parameters (see Chapter 6).


ˆ ecg_formats.csv  File to add new ECG formats (see Chapter 8).
ˆ transform_mats.csv  File to add new transformation matrices (see Chapter 9).
ˆ batch_settings.csv  File to edit command line batch parameters (see Chapter 13).
ˆ Qualparams.csv  File to edit quality parameters (see Chapter 16).
ˆ search_presents.csv  File to edit annotation presets (see Chapter 21).
ˆ braveheart_userguide.pdf  This le.

ˆ Example ECGs  Directory containing 4 example ECG les (see Chapter 5).
ˆ Download MATLAB Runtime - Mac 64 bit  Link to download MATLAB Runtime.

ˆ splash.png  Image used while loading.

Double click install_csv.command . The rst time that you run install_csv.command , Mac OS

runtime protection may block it because it is from an unidentied developer and not signed:

13
To allow the script to run (this only has to be done once), Control-click install_csv.command ,

and choose  Open from the menu. When the popup below appears, click Open :

This process will only have to be repeated if you install a new version of BRAVEHEART.

A script will run in Terminal. Enter your system password and press return on the keyboard.

This script moves the 6 necessary external .csv les noted above to the

home/users/<username>/braveheart directory where they can be edited. The les are removed

from the current directory after the script has run successfully. If you prefer, the les can also be

moved to the folder manually.

Entering your system password is necessary because the script also whitelists

braveheart_gui.app , run_braveheart_gui.sh , braveheart_batch.app , and

run_braveheart_batch.sh for the Mac OS Gatekeeper runtime protection so the software can

14
run without needing to manually whitelist each le. This is performed by removing the le

attributes that blacklist an unsigned le from Gatekeeper and requires your system password:

sudo xattr -d com.apple.quarantine <filename>

If you prefer to not run the script, you will have to manually whitelist the .app and .sh les by

Control-clicking on each le and choosing  Open from the menu.

NOTE: Due restrictions with how compiled Matlab programs interact with the Mac OS, the
above .csv les must be kept/edited in the home/users/<username>/braveheart directory. If

the les are placed/edited in another directory the program will not run and edits to the .csv

les will not be recognized. This restriction on where the .csv les must be stored is unique to

the Mac operating system. The executable .app les and their associated .sh les can be stored

in any directory.

Double click on braveheart_batch.app or braveheart_gui.app to run the program.

15
5 Quick Start Using the BRAVEHEART GUI

The following sections are provided as a way to quick start use of the BRAVEHEART GUI.

Details on using BRAVEHEART in command line mode are provided in Chapter 13. Your

understanding of the BRAVEHEART GUI will be better if you understand Annoparams.m

Chapter 6) and the specics functions in each GUI section (Chapter 12), but this section is
(

designed to get you using BRAVEHEART quickly, while showing you common functions.

This quick start guide uses 4 ECG les, ( example1.xml , example2.xml , example3.xml , and

example4.xml ) which are available on the BRAVEHEART GitHub repository in GE MUSE

XML format (see Chapter 23).

5.1 Example 1 - Good Quality ECG


In this example we will load and process an ECG without any ectopy or signicant noise/artifact

using the standard ltering and annotation settings, and save the results to an external le.

Start at the highlighted ` Initialize/Load ECG' section:

16
The ` Initialize/Load ECG' section of the GUI controls loading ECG les, ltering, baseline
correction, and transformation into a VCG.

Click the Load button:

Select example1.xml from the appropriate directory and click `Open' in the system dialogue box.

We see that the ECG has been loaded, converted into a VCG, and displayed in the upper left

section of the GUI (` X-, Y-, Z-, Vector Magnitude Leads'):

17
Once the ECG is loaded, we can view the standard 12-Lead ECG with 12 rhythm strips

( 12L ECG ) and the VCG ( X,Y,Z VCG ) with rhythm strips by clicking on the appropriate

buttons in the ` View/Save ECG & Figures' section in the upper right (see Chapter 12.8
and Chapter 20):

In the upper left section of the GUI (` X-, Y-, Z-, Vector Magnitude Leads'), note that each
of the 8 R peaks has a magenta * which indicates the location of a detected R wave peak in the

vector magnitude (VM = X2 + Y2 + Z2 ) lead. In this example we are able to visually conrm

that QRST complexes were not missed or over counted:

If we wanted to adjust ECG ltering parameters we would select the appropriate ltering

parameters in the ` Initialize/Load ECG' section (see Chapter 6.2 and Chapter 12.2) prior
to clicking Load . Alternatively we could change the parameters after the ECG is loaded and

then click Reload which is to the left of the Load button:

18
At this point the ECG has been loaded, ltered as appropriate, and converted into a VCG. We

are now ready to further process the VCG with annotation, PVC/outlier beat removal, median

beat construction, and calculations.

All of these processes can be performed by clicking the Calculate Fiducial


button in the `

Point Dectection & Annotation' Section:

19
Click the Calculate button. The ECG is processed:

Note that after the ECG is processed using the Calculate button, new sections of the GUI have

been lled in. For this ECG, no beats were detected as PVCs or outliers and removed (see

Chapter 15.3 and Chapter 15.4), and we see all beats continue to have a magenta *,
indicating that they remain in the analysis. The ` X-, Y-, Z-, Vector Magnitude Leads'
section in the upper left now also shows the QRS onset (Qon ), QRS oset (Qoff ), and T wave

oset (Toff ) annotations for each beat as dashed vertical lines:

20
Since the ECG has been annotated, on the right of the GUI, in the ` Annotated Beats' section,
we see the ducial points (in samples  in the order of Qon , R peak, Qoff , and Toff ) which were

used to segment out the 8 beats from the full ECG signals. These sample numbers correspond to

the dashed lines and * in the `X-, Y-, Z-, Vector Magnitude Leads' section noted above.

The median VCG beats (X, Y, and Z, and vector magnitude [VM]) are displayed in the lower

left of the GUI in the ` Median Beats' section:

21
The individual beats that make up the X, Y, and Z median beats are displayed as black dotted

plots, and the median beat ducial points Qon , Qoff , and Toff are denoted with vertical black

dashed lines. This section also allows assessment of ECG processing quality. Note that the

normalized cross correlation (`X-Corr') values for the X, Y, and Z leads on the left (red box with

*) are all very close to 1, indicating that all of the beats that were used to construct the median
beat are similar and aligned property. The `Prob (%)', in the lower right (red box with **),
which is the predicted probability of the processed ECG being good quality, is 100%, and the

number of poor quality ags (`Counts') is 0 indicating good quality processing. For further

details of ECG quality assessment see Chapter 16.

Click on the VCG Calculations button in the middle of the GUI which displays calculations from

the VCG_Calc results class (see Chapter 24):

22
This brings up the ` VCG Calculations' section which displays various VCG measurements and
is also used for exporting all calculations (including parameters which are not displayed in the

GUI). The controls for data export are shown in the bottom right:

The default directory used to save les is the same directory from which the ECG was loaded. To

change the directory for saving click Select and choose a new directory. The default le name for

the saved data le is braveheart_outut ; change this to what you want to name the output le.

Once your le name and directory are set, click Export Data (.csv) to export the data to a .csv

le located in the directory chosen above and with the specied le name. Once the le is

successfully exported, Success! is displayed in green in the bottom right of the section.

5.2 Example 2 - ECG with PVCs


In this example we will load an ECG with a PVC, and show dierent ways of removing the PVC

(see Chapter 15.3 for additional information on PVC detection/removal).

First load example2.xml using the Load button as noted above in Example 1 ( Chapter 5.1).

By inspecting the ` X-, Y-, Z-, Vector Magnitude Leads' section, note that the last beat of
this ECG is a PVC, and all beats/R peaks are correctly identied with a *:

23
Click the Calculate button:

The ECG is processed, and because automatic PVC removal was turned on (this is enabled by

default), the PVC is automatically removed. We can see the PVC has been removed by looking

at the ` X-, Y-, Z-, Vector Magnitude Leads' section where we see that PVC does not have a
* anymore, the ducial points for the PVC are not present in the Annotated Beats' section,
and the PVC is not seen in the ` Median Beats' section:

24
Also note that the Quality metrics (green text boxes in the lower right of the ` Median Beats'
section show an excellent estimated quality (`Prob (%)') of approximately 95% (see Chapter
16).

Now click the Reload button:

25
The GUI is cleared and the ECG is reloaded without having to select the le again.

This time we will disable automatic PVC removal. We can do this by either unchecking

V All Auto in the `Fiducial Point Detection & Annotation' section which disables BOTH
PVC and outlier removal, or by unchecking V Auto in the PVC removal section in the bottom

right of the GUI.

If you uncheck 2 All Auto , the 2 2 Auto checkboxes in the PVC and outlier removal sections

also become unchecked. Similarly, checking V All Auto checks both V Auto checkboxes.

Uncheck 2 All Auto (and note that the 2 2 Auto checkboxes in the ` PVC
Removal/Extraction' and `Outlier Removal' sections also become unchecked), and then
click Calculate . This time the PVC is not removed; note that in the ` X-, Y-, Z-, Vector
Magnitude Leads' section, the PVC still has a * and annotations (dashed lines):

26
Also note that the PVC has a triangle around the * (△
* ) which is how a beat that has been
detected as a PVC is marked. In this case there is also a circle around the * because the PVC is
additionally detected as an outlier (see Example 3 in Chapter 5.3 and Chapter 15.4).

As the PVC is still present, the PVC ducial points are also still present in the Annotated
Beats' list where the PVC's ducial points are followed by a `#', which is used to signify that
the beat has been detected as a PVC by BRAVEHEART's PVC detection algorithm (the ` **'
denotes that this beat was classied as an outlier as well):

Median Beats' section the PVC is represented by a black dotted line that is dierent
In the `

from the other beats:

27
Also note that the quality metrics (red text boxes in the lower right of the ` Median Beats'
section shows a low probability of good quality `Prob (%)') of only 3.7% due to the PVC (see

Chapter 16).

We will rst remove the PVC using the PVC removal algorithm. In the ` PVC
Removal/Extraction' section in the bottom right of the GUI, simply click Remove PVCs :

The ECG is reprocessed, the PVC is removed, and the median beat is recreated without the

PVC.

Alternatively we could manually tell BRAVEHEART to remove the PVC. Reload the ECG with

the Reload button. Click on the PVC beat in the ` Annotated Beats' list. The selected beat

is highlighted in the list and appears in the ` Selected Beat Viewer' right below the
` Annotated Beats' list:

28
The selected beat is also highlighted with a green * in the `X-, Y-, Z-, Vector Magnitude
Leads' section, and the beat is highlighted in green in the `Median Beats' section:

Click on the Remove Beat button in the `Add/Remove Selected Beats' section:

29
The ECG is reprocessed, the PVC is removed, and the median beat is recreated without the

PVC. Once the PVC is removed, the estimated quality of the ECG is now high (94.8 % with

green color background).

At this point, the data can be exported as noted above in Example 1 ( Chapter 5.1).

5.3 Example 3 - ECG with Artifact


In this section we will load an ECG with focal noise that is removed with outlier detection and

removal.

First load example3.xml and disable 2 All Auto Chapter 5.2).


as noted above in Example 2 (

Note that the 6th beat has some focal noise.

30
Click the Calculate button. The 6th beat is identied as an outlier as noted by the circle

around the * ( #* ), and the `**' next to the beat in the `Annotated Beats' section.

Had we had V All Auto or the V Auto Outlier Removal' section checked o, this beat,
in the `

identied as an outlier, would have been automatically removed. In this case, however, because

we disabled automatic outlier removal, we will have to manually remove the outliers similar to

how PVCs are removed in Example 2 ( Chapter 5.2). The outliers can be automatically

removed by clicking the Remove Outliers button:

The outlier can also be removed by clicking on the beat in the ` Annotated Beats' section and
then clicking the Remove Beat button in the ` Add/Remove Selected Beats' section as
noted in Example 2 ( Chapter 5.2).

31
5.4 Example 4 - Dealing with Pacing Artifact
In this example we will see how BRAVEHEART deals with pacing artifact.

Pacemaker artifact detection and removal are controlled in the bottom right of the

` Initialize/Load ECG' section of the GUI:

The `Peak %' and `Pk Width (ms)' textboxes usually can stay at their nominal values of `20' and

further details on these parameters are available in Chapter 6.2. We will focus on the V On
checkbox which enables/disables pacemaker artifact removal.

We will start by disabling pacemaker artifact removal by unchecking the 2 On checkbox. Next,

load example4.xml as noted in the above examples:

32
The ` X-, Y-, Z-, Vector Magnitude Leads' section shows that for almost all of the beats the
R peak has been detected as the large pacing spike (see the location of the *) because in most
beats the pacing artifact magnitude is larger than the QRS complex magnitude in the VM lead.

This is very problematic, as if you press Calculate now you will see that the ECG does not

process correctly and the results are unusable.

Re-enable pacemaker artifact removal by checking the V On checkbox, and then reload the

ECG with the Reload button:

This time, as pacemaker artifact removal was enabled, the pacemaker spikes are ignored, and the

true QRS peaks are detected as the R peaks. If you press Calculate the ECG will process

correctly.

5.5 Example 5 - Using .anno Files


In this example we will load an ECG, process with non-nominal settings, remove some beats, and

then use an .anno le to reproduce this workow automatically the next time the ECG is loaded.

For illustrative purposes we will disable ltering and remove the second beat. Uncheck

2 Wavelet Low Pass and 2 Wavelet High Pass Initialize/Load ECG' section:
in the `

33
Next, load example1.xml and click Calculate as noted in the examples above. Click on the

second beat in the ` Annotated Beats' listbox, and then delete the second beat using the
Remove Beat button. The second beat is removed from the median beat and calculations:

Note that the * is not present on the second beat indicating that the second beat is no longe
included in the median beat. Now click on the Export Fiducial Point
button in the `

Detection & Annotations' section of the GUI, making sure that the V Include Beats checkbox

is checked (this saves the beat annotations in addition to the anotation parameters).

34
A le named example1.anno appears in the same folder as example1.xml .

Reset all GUI parameters to nominal values with the Reset button which restores the default

GUI/annotation parameters (see Chapter 6) and re-checks V Wavelet Low Pass and

V Wavelet High Pass . Then reload the ECG from scratch with the Reload button.

This time, instead of clicking the Calculate button to process the ECG, we will reproduce what

we did above by loading the .anno le: Click Import and choose example1.anno :

example1.xml is reloaded using the annotation/ltering parameters specied in the .anno le.

Note how 2 Wavelet Low Pass and 2 Wavelet High Pass are now unchecked, and beat 2, which

was manually deleted before saving the .anno le, has been automatically deleted.

Using the Import button is equivalent to placing the le example1.anno in the same folder as

the original ECG le example1.xml and then running batch ECG processing  the

parameters/beats in the .anno le overwrite the default parameters and beat removal. Note that

when using .anno les, after importing, automatic PVC and outlier removal are disabled.

35
5.6 Editing Beats
The ` Annotated Beats' listbox contains ducial point annotations for Qon , R peak, Qoff , and
Toff for each individual beat that was used to create the median beat. To edit a beat's

annotations, click on the row which corresponds to the beat in the listbox. The selected beat

appears in the ` Selected Beat Viewer', the R peak of the selected beat is highlighted with a
green * in the ` X-, Y-, Z-, Vector Magnitude Leads', and the selected beat is highlighted in
green in the ` Median Beats' section. Below the ` Selected Beat Viewer' there is a `Beat
Selection' section that shows the ducial points from the `Annotated Beats' listbox. In the

gure below the 5th beat has been selected:

36
To edit the beats ducial points there are a few options:

1. Drag the dashed lines on the ` Selected Beat Viewer' to their appropriate locations. Black

is Qon , green is R peak, blue is Qoff , and red is Toff . Once the mouse is released, the new location

of the ducial point is updated in the ` Beat Selection' textbox. In the gure below, as an

example, the location of Toff for the beat is moved from sample 2991 to sample 3011 by dragging

the red dashed line to the right:

37
2. Edit the values in the ` Beat Selection' textbox directly:

3. Click on the + and  buttons in the `Shift By 1 Sample' section under the ` Beat
Selection' textbox to increase or decrease the specied ducial point value by 1 sample.:

38
After you use one of these three methods to set the appropriate values for the beat in the ` Beat
Selection' textbox, click Update Beat to update the values and recalculate the new median

beat and measurements.

Note: The Next and Prev buttons can be used to cycle through the beats in the ` Annotated
Beats' listbox without clicking on each beat individually.

5.7 Removing Beats


To remove a beat, click on the beat to be removed in the ` Annotated Beats' listbox. The

selected beat is shown in the ` Selected Beat Viewer' and highlighted in green in the `X-, Y-,
Z-, Vector Magnitude Leads' and `Median Beat' sections as noted in the above examples.
Once the beat to be removed is selected, click the Remove Beat button in the `Add/Remove
Selected Beats' section:

The selected beat is removed, a new median beat is created and annotated, and measurements

are performed on the new median beat.

5.8 Adding Beats


It should be rare to have to add beats manually, but this can be done if needed. Enter the

respective ducial points in the ` Beat Selection' text box and then click Add Beat in the

` Add/Remove Selected Beats' section:

The new beat is added, a new median beat is created and annotated, and measurements are

performed on the new median beat.

Note: Manually added beats are inserted at the end of the ` Annotated Beats' list and not in
the temporal order in which they appear in the ECG. This has no eect on annotation or

39
calculations.

5.9 Removing PVCs and other Non-Dominant Beats


A discussion of the PVC (or any non-dominant QRST morphology) detection and removal

algorithm can be found in Chapter 15.3 and/or the methods manuscript [1]. Additionally,

Example 2 ( Chapter 5.2) shows an example of PVC removal. If V Auto is checked in the

` PVC Removal/Extraction' section, PVCs will be automatically detected and removed when
the Calculate button is clicked. If PVC removal is disabled ( 2 Auto ), PVCs will be detected

but not removed as noted above in Example 2.

After the Calculate button is clicked, PVCs are noted in the ` X-, Y-, Z-, Vector Magnitude
Leads' section with a △
* , and in the `Annotated Beat' list with a `#' following the numbered
ducial points.

40
In the gure above, for illustrative purposes, outlier detection (see Chapter 5.10 and Chapter
15.4) was disabled. In many cases, PVCs also get agged as outliers, and the GUI will note the

beat as both a PVC and outlier as shown in Example 2 ( Chapter 5.2).

Data about how BRAVEHEART is classifying each beat for PVC detection can be displayed in

the GUI by clicking the PVC Data button which displays a gure showing which beats are being

detected as PVCs and why. Further details are available in Chapter 20 and Figure 26.

PVCs that have been detected but not removed can be easily removed all at once by clicking the

Remove PVCs button. Alternatively, PVCs can be manually removed one at a time by selecting

each PVC in the ` Annotated Beat' list and then clicking the Remove Beat button as

described in the previous examples.

If you wanted to analyze the PVC in the example2.xml rather than removing it, use the radio

button which allows you to select if `PVC Removal' will remove or keep PVCs. The default

setting is to `Remove PVCs':

By choosing `Remove Native' in the radio button, note how the Remove PVCs button changes

to the Remove Native button:

After an ECG is processed with the Calculate button, if `Remove Native' is selected in the GUI

radio button, automatic PVC removal and the Remove Native button will actually remove the

non-PVC beats and keep the PVCs/non-dominant beats for analysis.

41
5.10 Removing Outlier Beats
A discussion of the outlier detection algorithm can be found in Chapter 15.4 and/or the
methods manuscript [1]. If V Auto is checked in the ` Outlier Removal' section, outliers will be
automatically detected and removed when Calculate is pressed. If outlier removal is disabled

( 2 Auto ), outliers will be detected but not removed.

Outliers are noted in the ` X-, Y-, Z-, Vector Magnitude Leads' section with a #
* , and in the
` Annotated Beat' list with a `**' following the numbered ducial points:

Data about how BRAVEHEART is classifying each beat for outlier detection can be displayed in

the GUI by clicking on the Outlier Data button. The QR and RT intervals are used for outlier

detection, and beats that are considered as outliers will have their QR and/or RT interval

42
displayed with a red background. The other measures that are displayed, such as the RS, JT,

and QT intervals and area under the QRST complex are displayed for the users information but

are not used to actually ag a beat as an outlier, and are displayed with a black background. See

Chapter 15.4 and Figure 27 for further details.

Outliers that have been detected but not removed can be easily removed all at once by clicking

the Remove Outliers button. Alternatively, outliers can be manually removed one at a time by

selecting each beat in the ` Annotated Beat' list and then clicking the Remove Beat button.

Note that outliers and PVCs are reassessed after each beat is removed, so it is possible that a

beat which is classied as an outlier prior to another beat being removal may no longer be

classied as an outlier after the other beat is removed. Additionally, some outliers may also be

marked as PVCs, and PVC removal may remove them.

5.11 Manually Adjusting Median Beat Annotations


Median beat ducial point annotation nominally utilizes a custom neural network (NN)

developed specically for median beat annotation (see the methods manuscript [1] and Chapter
19 for details). We have demonstrated that the NN has very high accuracy, but rarely

annotations may be inaccurate. There is some subjectivity in annotating QRST ducial points,

especially the Toff , so we would recommend not manually editing the median beat ducial points

unless the provided points are signicantly abnormal to maintain consistency and reproducibility

of the results. In cases where the NN provided ducial points are signicantly abnormal, or in

niche cases where manual annotation is required, the median beat ducial points Qon , Qoff , and

Toff can be manually adjusted as described below.

In the ` Shift Fiducial Points' section below the `Selected Beat Viewer', make sure
V Median is checked. Enter a number of samples (positive numbers shift towards the
right/later, and negative numbers shift towards the left/earlier) in the textbox. Then press the

button for the ducial point you want to shift:

43
For example, to shift the median beat Toff later by 3 samples, enter `3' in the textbox and click

the To button. To shift the median beat Qon earlier by 2 samples enter `-2' in the textbox and

click the Qon button. The ducial points of the median beat are adjusted and calculations are

updated.

5.12 Exporting Measurements to a Text File


BRAVEHEART can output results to a text le for analysis. After you have processed the ECG

and made any manual edits, click the VCG Calculations button in the middle of the GUI as

shown in Example 1 ( Chapter 5.1).

This brings up the ` VCG Calculations' section which displays various VCG measurements and
is used for exporting all calculations. The controls for data export are shown in the bottom right:

The default directory used to save les is the same directory from which the ECG was loaded. To

change the directory for saving click Select and choose a new directory. The default le name for

the saved data le is braveheart_output ; change this to what you want to name the output le.

44
Once your le name and directory are set, click Export Data (.csv) to export the data to a .csv

le located in the directory chosen above and with the specied le name. Once the le is

successfully exported, Success! is displayed in green in the bottom right of the section.

5.13 Exporting Signals


Chapter 5.12 describes how to export calculations into a text le for further analysis.
BRAVEHEART can also export these calculation data, and all ECG, VCG, median beat signals,

and annotation data, in a MATLAB .mat le which contains a data structure with all

results/signals. In the `VCG Calculations' section, click the Export Signals (.mat) button. A

le with the same name as the ECG and with extension .mat is created the the directory

specied for data export.

5.14 Exporting Figures


A variety of gures can be generated and saved by the BRAVEHEART GUI. See Chapter 20
for additional information.

45
6 Annotation Parameters ( Annoparams.m )

Annoparams.m contains parameters which control the behavior of BRAVEHEART's ECG/VCG

signal processing and annotation algorithms. These parameters can be set globally by editing the

Annoparams.m le. In cases where BRAVEHEART is being run via executable and

Annoparams.m cannot be edited, the parameters can be set by editing Annoparams.csv which is

an external le with name/value pairs separated by commas. When the program is run via

executable, calls to pull data from Annoparams.m will instead pull data from Annoparams.csv .

Note that when editing Annoparams.csv , unlike when editing Annoparams.m , strings should not
be enclosed in quotes.

When using the GUI it should be rare to have to edit the Annoparams.m (or Annoparams.csv )

le because almost all of the important parameters that would be set in Annoparams.m (or

Annoparams.csv ) can be set via dropdowns, checkboxes, or textboxes in the GUI. However,

editing Annoparams.m (or Annoparams.csv ) can be used to change the default values when the

GUI loads. The correspondence between GUI elements and specic properties of Annoparams.m

is described in Chapter 12 and Chapter 26.

When using the GUI, values are pulled from Annoparams.m (or Annoparams.csv ) when the GUI

is loaded/initialized for the rst time and when GUI parameters are reset with the Reset button

(see Chapter 12). The actual GUI settings at the time an ECG is processed or a calculation is

run will override any settings within Annoparams.m (or Annoparams.csv ).

The following sections describe the properties within the Annoparams.m class that can be set by

the user (either via editing les or the GUI) to change the behavior of BRAVEHEART.

46
6.1 Annoparams Properties ( Annoparams.m )
Annoparams.m properties are listed here and descriptions of their use follows in Chapter 6.2.
Note: some comments used as headings for groups of similar properties have been omitted.

maxBPM = 150; % Sets window for detecting R peaks


pkthresh = 95; % Percentile of ECG signal above which a peak can be found
lowpass = 1; % Low pass wavelet filter on/off
highpass = 1; % High pass wavelet filter on/off
wavelet_level_lowpass = 1; % LPF freq is > samp freq/2^(wavelet_level_lowpass + 1)
wavelet_level_highpass = 10; % HPF freq is < samp freq/2^(wavelet_level_highpass + 1)
wavelet_name_lowpass = 'sym4'; % Low-pass wavelet (Sym4, Sym5, Sym6, db4, db8, db10, etc)
wavelet_name_highpass = 'db4'; % High-pass wavelet (Sym4, Sym5, Sym6, db4, db8, db10, etc)
baseline_correct_flag = 1; % Corrects baseline offset

transform_matrix_str = 'Kors'; % Kors or Dower transformation matrix

baseline_flag = 'zero_baseline'; % Zero reference for area calculations


origin_flag = 'zero_origin'; % Origin for VCG plotting

autoMF = 1; % Auto estimate QRS width


autoMF_thresh = 20; % Percent Rpeak threshold if autoMF = true
MF_width = 40; % Length of median filter (in ms) used when autoMF = true

QRwidth = 100; % Width of QR search window in ms


RSwidth = 100; % Width of RS search window in ms
STstart = 100; % Distance between Qoff and start of Tend search window in ms
STend = 45; % Length of Tend search window as a percent of RR interval

spike_removal = 1; % Remove pacemaker spikes


pacer_spike_width = 20; % Max width of pacing spike (in ms)
pacer_mf = 4; % Pacer spike detection median filter (in ms)
pacer_thresh = 20; % Percent peak of pacer spike used for spike removal

align_flag = 'CoV'; % Beat alignment method ('CoV' or 'Rpeak')


cov_mf = 40; % width of CoV median filter (in ms)
cov_thresh = 30; % CoV median filter threshold %
shiftq = -40; % Q window expand when calculating median beat (in ms)
shiftt = 60; % T window expand when calculating median beat (in ms)

Tendstr = 'Energy'; % Tend detection method ('Energy', 'Tangent', or 'Baseline')

median_reanno_method = 'NNet'; % 'NNet' for neural network and 'Std' for standard annotations

outlier_removal = 1; % Remove outliers


modz_cutoff = 4; % Cutoff for mod Z-score to flag an outlier (higher less sensitive)
pvc_removal = 1; % Remove PVCs
pvcthresh = 0.95; % Cross correlation threshold for PVC removal
rmse_pvcthresh = 0.1; % Normalized RMSE threshold for PVC removal
keep_pvc = 0; % Set = 1 if PVC removal removes native QRS instead of PVCs

blanking_samples = 0; % Blanking window (in samples) to ignore in speed calculations

debug = 0; % Debug mode (generates debug annotation figures)

47
6.2 Annoparams Property Descriptions
property acceptable values
|

property description
pkthresh | Numeric values between 0 and 100

Cuto percentile above which an R peak can be detected in the vector magnitude (VM)

signal as part of initial R peak detection. This is nominally set to 95 . Higher values may

miss some R peaks, while lower values may inappropriately identify peaked T waves or other

parts of the ECG signal. However, because the R peak detection algorithm also takes into

account a rate related blanking period around each R peak dened by maxBPM (see below)

where only a single R peak can be detected, as long as the maxBPM parameter is set to a

reasonable rate, it is rare to over count R peaks unless pkthresh and maxBPM are both set

very low. In cases where the magnitude of PVCs or paced beats in the VM lead is

signicantly dierent than the magnitude of the dominant QRST morphology, pkthresh
may have to be reduced to detect both the dominant and non-dominant R peaks.

Additional information can be found in Chapter 15.1 and Figure 22 which illustrates R
peak detection using the pkthresh and maxBPM parameters.

maxBPM | Positive numeric values

Length of the blanking window in beats per min (bpm) centered around each dominant R

peak in the VM signal where a second R peak will not be found. This is also the lower limit

of the heart rate (HR) that can be detected by the R peak detector; maxBPM must be set to

a value above the HR on the ECG to avoid missing QRS complexes. The blanking window

in ms (w ) given as w = 60000/ maxBPM . The nominal value of 150 bpm corresponds to a 400

ms window centered on the highest peaks detected in the VM signal. Additional information

can be found in Chapter 15.1 and Figure 22 which illustrates R peak detection using the
pkthresh and maxBPM parameters.

lowpass | Integer 0 or 1

Sets if low-pass wavelet-based ltering is activated ( 1 ) or deactivated ( 0 ). Low-pass ltering

removes frequencies above a cuto frequency and helps remove high-frequency noise.

highpass | Integer 0 or 1

Sets if high-pass wavelet-based ltering is activated ( 1 ) or deactivated ( 0 ). High-pass

ltering removes frequencies below a cuto frequency and helps remove low-frequency

baseline wander and DC oset.

48
wavelet_level_lowpass | Integer values ≥ 1
Corresponds to the low-pass ltering cuto frequency level. The low-pass cuto ltering

frequency (fc ) is given by fc = fs /(2n+1 ), where fs is the ECG sampling frequency and n is

the value of wavelet_level_lowpass . As can be seen, the same wavelet level will

correspond to a dierent low-pass ltering cuto frequency for signals with dierent

sampling frequencies. In general, wavelet_level_lowpass should be a low value ≤ 3 for

most applications (depending on signal sampling frequency) to avoid removing frequencies

contained within the QRST complex (0.5-40 Hz)[3]. The maximum n (maximum value of

wavelet_level_lowpass ) depends on the length of the ECG signal in samples (L) and is

given as nmax = floor(log2 L). The BRAVEHEART GUI nominally sets

wavelet_level_lowpass = 1 for signals sampled at 500 Hz, and

wavelet_level_lowpass = 2 for signals sampled at 1000 Hz when ECG formats are

changed; this corresponds to a nominal low-pass ltering cuto of 125 Hz. See Chapter 7
for further details.

wavelet_level_highpass | Integer values ≥ 1


Corresponds to the high-pass ltering cuto frequency level. The high-pass cuto ltering

frequency (fc ) is given by fc = fs /(2n+1 ), where fs is the ECG sampling frequency and n is

the value of wavelet_level_highpass . As can be seen, the same wavelet level will

correspond to a dierent high-pass ltering cuto frequency for signals with dierent

sampling frequencies. In general, wavelet_level_highpass should be a high value ≥ 9 to

avoid removing frequencies contained within the QRST complex (0.5-40 Hz)[3]. The

maximum n maximum value of wavelet_level_highpass ) depends on the length of the

ECG signal in samples (L) and is given as nmax = floor(log2 L). The BRAVEHEART GUI

nominally sets wavelet_level_lowpass = 10 for signals sampled at 500 Hz, and

wavelet_level_lowpass = 11 for signals sampled at 1000 Hz when ECG formats are

changed; this corresponds to a nominal high-pass cuto frequency of 0.24 Hz. See Chapter
7 for further details.

wavelet_name_lowpass | string values corresponding to MATLAB wavelet names

Corresponds to the specic wavelet used for low-pass ltering. Nominal settings use 'sym4' ,
which corresponds to the Symelets 4 wavelet, and which should be adequate for most ECG

signals. A full list of MATLAB wavelets and their associated strings can be found in the

MATLAB documentation or by typing waveinfo in the MATLAB Command Window.

49
wavelet_name_highpass | string values corresponding to MATLAB wavelet names

Corresponds to the specic wavelet used for high-pass ltering. Nominal settings use 'db4' ,
which corresponds to the Daubechies 4 wavelet, and which should be adequate for most

ECG signals. A full list of MATLAB wavelets and their associated strings can be found in

the MATLAB documentation or by typing waveinfo in the MATLAB Command Window.

baseline_correct_flag | Integer 0 or 1

Sets if physiological baseline correction is activated ( 1 ) or deactivated ( 0 ). This provides

additional baseline correction after high-pass ltering to set the isoelectric TP segment (the

physiological zero voltage reference) as the approximate zero voltage reference for

calculations. Further information can be found in Chapter 15.2 and Figure 24.

transform_matrix_str | 'Kors' or 'Dower'

Sets the transformation matrix used to transform the ECG into a VCG. The nominal

transformation matrix is the Kors transformation matrix [4] which is set by the string

'Kors' . The inverse Dower transformation [5] can be used with the string 'Dower' .
Additional transformation matrices can be added as shown in Chapter 9.

baseline_flag | 'zero_baseline' , 'Tend' , 'QRS Onset' , or 'Avg'

Sets how the zero baseline is dened for area calculations. The nominal setting of

'zero_baseline' takes 0 mV as the reference line and should be used assuming the signals

are zeroed appropriately using ltering and baseline correction. Other options include

'Tend' which sets the end of the T wave, 'QRS Onset' which sets the start of the QRS

complex, and 'Avg' which sets the mean of the QRS onset and T wave end as the zero

reference for area calculations, respectively. In general, the nominal setting

'zero_baseline' should be used (See Chapter 15.2 and Figure 23).

origin_flag | 'zero_origin' , 'Tend' , or 'Avg'

Sets the location of the VCG origin. The nominal setting of 'zero_origin' takes the point

(0,0,0) as the origin and should always be used assuming the signals are zeroed

appropriately using ltering and baseline correction. 'Tend' shifts (0,0,0) to the location of

the end of the 3D T wave loop, and 'Avg' shifts (0,0,0) to the point in space equidistant

between the onset of the 3D QRS loop and the end of the 3D T wave loop.

autoMF | Integer 0 or 1

Sets if median ltering is used to estimate QRS width as part of heuristic rst pass QRS

detection/annotation. If autoMF = 0 , the values of QRwidth and QSwidth (see below) are

50
used to set the QRS ducial point detection window. Setting autoMF = 1 allows

BRAVHEART to dynamically adjust the QRS ducial point search window for each beat

individually rather than relying on a xed window for all beats, and is recommended for

most ECGs. In cases where heuristic rst pass annotation fails (usually due to atypical

QRST morphology), setting autoMF = 0 and manually adjusting QRwidth and QSwidth may

be useful. See Chapter 18 for further details.

autoMF_thresh | Integers between 0 and 100

Sets the percentage of each beat's VM QRS peak voltage that is used to estimate each QRS

peak width as part of rst pass heuristic annotation. If the value of autoMF_thresh is set

too high, the QRS search window will be too short and the true onset/oset of the QRS

complex may be missed. If the value of autoMF_thresh is set too low, parts of the T wave

may be captured in the QRS search window and inaccuracies in the location of QRS

onset/oset may result. The nomimal value of 20 works for the majority of ECGs. Modest

increases or decreases in this value may occasionally be needed based on QRS/T wave

morphologies. See Chapter 18 for further details.

MF_width | Positive integer values

Sets the width of the median lter (in ms) used when autoMF = 1 . The nominal value of 40
should be used for most applications and rarely requires change. Note: This property cannot

be set via the GUI.

QRwidth | Positive integer values

Manually sets the width of the heuristic rst pass annotation QRS search window (in ms)

before the R peak if autoMF = 0 . This search window is used to locate the QRS onset

(Qon ). A description of the windows used for heuristic rst pass annotation is detailed in

Chapter 18 and Figure 30. If autoMF = 1 this has value no eect on annotation.

RSwidth | Positive integer values

Manually sets the width of the heuristic rst pass annotation QRS search window (in ms)

after the R peak if autoMF = 0 . This search window is used to locate the QRS oset (Qoff ).

A description of the windows used for heuristic rst pass annotation is detailed in Chapter
18 and Figure 30. If autoMF = 1 this value has no eect on annotation.

STstart | Positive integer values

Sets the distance (in ms) between the end of the QRS complex and the start of the T wave

end search window. A description of the windows used for heuristic rst pass annotation is

51
detailed in Chapter 18 and Figure 30.

STend | Positive values between 0 and 100

Sets the width of the T wave end search window starting at STstart and going forward by

STend % of the mean RR interval across the full ECG. STend is set as a percentage rather

than as absolute value in ms because the QT interval is highly inuenced by heart rate, and

this reduces the need for frequent adjustment of this parameter. A description of the

windows used for heuristic rst pass annotation is detailed in Chapter 18 and Figure 30.

spike_removal | Integer 0 or 1

Sets if automatic pacemaker spike/artifact removal is on ( 1 ) or o ( 0 ). In general, even if

pacing is not present, this should be left on as the signals and subsequent annotation will

not be aected if pacing is not present. In rare cases, disabling pacemaker spike removal by

setting spike_removal = 0 may resolve errors during ECG loading or annotation and can

assist with trouble shooting ECGs that won't load, usually due to very wide or atypical

pacing spikes/artifact.

pacer_spike_width | Positive integer values

Sets the maximum width of a high-frequency deection (in ms) in the VM lead that can be

dened as a pacing spike. The nominal value of 20 should work in most cases. If there are

issues removing very large/wide pacing spikes, adjusting this value may be useful.

pacer_mf | Integer 0 or 1

Sets the width of the median lter (in ms) used when spike_removal = 1 . The nominal

value of 4 should be used for most applications and rarely requires change. Note: This

property cannot be set via the GUI.

pacer_thresh | Numeric values between 0 and 100

Sets the percentage of the pacemaker spike amplitude that is used to determine if a high

frequency spike is a pacing artifact. In most cases, the nominal value of 20 works well, but

if there are issues removing very large pacing spikes, adjusting this value may be useful.

align_flag | 'CoV' or 'Rpeak'

Sets how individual beats are aligned to create a median beat using either the ltered center

of voltage ( 'CoV' ) or R wave peak ( 'Rpeak' ), respectively. The nominal value of 'CoV'
generally performs better than 'Rpeak' as it is less inuenced by noise or by variations in

QRS morphology such as are sometimes seen in bundle branch blocks, and should be used

52
for most applications. If median beat alignment is poor when using 'CoV' , trying 'Rpeak'
may possibly improve beat alignment.

cov_mf | Positive integer values

Sets the width of the median lter (in ms) used to determine the center of voltage. In

general this should remain at the nominal value of 40 and rarely requires change. Note:

This property cannot be set via the GUI and rarely requires editing.

cov_thresh | Numeric values between 0 and 100

Sets the percentage of the VM QRS peak used for aligning QRST complexes via center of

voltage. Note: This property cannot be set via the GUI and rarely requires editing.

shiftq | Negative integer values

Sets the value in ms by which the window around the median beat is expanded prior to the

onset of the QRS complex. This ensures that the location of the QRS onset is not cut short.

The nominal value of -40 should be used for almost all applications. Making this value

more negative will increase the amount of signal that is included in the median beat before

the onset of the QRS complex, and making this value less negative will decrease the amount

of signal that is included in the median beat before the onset of the QRS complex. Note:

This property cannot be set via the GUI.

shiftt | Poitive integer values

Sets the value in ms by which the window around the median beat is expanded after the end

of the T wave. This ensures that the location of the T wave end is not cut short. The

nominal value of 60 should be used for almost all applications. Making this value larger will

increase the amount of signal that is included in the median beat after the end of the T

wave, while making this value smaller will decrease the amount of signal that is included in

the median beat after the end of the T wave. Note: This property cannot be set via the GUI.

Tendstr | 'Energy' , 'Tangent' , or 'Baseline'

Sets the method for T wave end detection (Toff ) when using the heuristic T wave end

detector. If set to 'Energy' it utilizes a validated method that assesses T wave energy

towards the end of the T wave that is better able to deal with low amplitude or abnormal T

waves than other methods [6]. Setting Tendstr to 'Tangent' utilizes the tangent method,

and setting as 'Baseline' uses baseline crossing. In general, the best results are obtained

with 'Energy' . See Chapter 18 for further details.

53
median_reanno_method | 'NNet' or 'Std'

Once a median beat is created, median beat ducial points are obtained by annotating the

median beat QRST complex. median_reanno_method sets how median beats are annotated,

using either the standard hieuristic annotater ( 'Std' ) or a custom neural network

( 'NNet' ). In almost all cases the nominal value of 'NNet' should be used as it is the most

accurate way to annotate median beats. In rare cases where the neural network fails to

accurately annotate a median beat, switching to 'Std' may work, although usually ECGs

that fail neural network annotation are ECGs with signicant noise and artifact that are

dicult to annotate regardless of method. Details of neural network development and

annotation performance are available in the methods manuscript [1] and Chapter 19.

outlier_removal | Integer 0 or 1

Sets if automatic outlier beat removal is activated ( 1 ) or deactivated ( 0 ). When using the

GUI, if outlier_removal = 0 outlier beats will be identied and marked but not removed.

See Chapter 15.4 for additional details.

modz_cutoff | Integer 0 or 1

Sets the threshold for the modied Z-score that is used to dene a beat as an outlier. If

the modied Z-score for the QR and/or RT interval of an individual beat is above the

modz_cutoff value, the beat is agged as an outlier. Higher values may be needed when

there are few beats; if there are > 15 beats a cut o value of 3.5 is reasonable, although if

there are < 10 beats a cut o value of approximately 4 may be needed [7]. See Chapter
15.4 for additional details.

pvc_removal | Integer 0 or 1

Sets if automatic PVC/non-dominant beat removal is activated ( 1 ) or deactivated ( 0 ).

When using the BRAVEHEART GUI, if pvc_removal = 0 PVCs/non-dominant beats will

be identied and marked but not removed. The keep_pvc parameter (see below) controls

whether the dominant or non-dominant beats are kept for analysis. See Chapter 15.3 for
further details.

pvcthresh | Numeric values

Sets the cuto (as a percentage) for normalized cross correlation (NCC) as used for

PVC/non-dominant beat detection. The nominal value of 95 works well for most

applications. The contribution of NCC to PVC/non-dominant beat detection can be

disabled by setting pvcthresh = 0 . See Chapter 15.3 for further details.

54
rmse_pvcthresh | Numeric values

Sets the cuto for root-mean square error (RMSE) as used for PVC/non-dominant beat

detection. The nominal value of 0.1 works well for most applications. The contribution of

RMSE to PVC/non-dominant beat detection can be disabled by setting

rmse_pvcthresh = -1 . See Chapter 15.3 for further details.

keep_pvc | Integer 0 or 1

Sets if PVCs/non-dominant beats are removed ( 0 ) or if dominant beats are removed to

allow analysis of the PVCs/non-dominant beats ( 1 ).

blanking_samples | Positive integers

Sets the window (in samples) after QRS onset which is not included in calculations of VCG

loop speed (See Chapter 12.7). In general this can be left at the nominal value of 0, but

in certain paced ECGs where there is some contamination of the start of the QRS complex

with a high amplitude/frequency pacing spike, increasing this value may be useful. In

certain situations it may be desirable to also look at speed at specic parts of the QRST

complex, and increasing the blanking window can also assist with this by excluding the

signal contained within the blanking window from any speed calculations.

debug | Integer 0 or 1

Sets if BRAVEHEART generates debug gures during ECG signal annotation. This can be

useful for troubleshooting. Further details can be found in Chapter 28.7, Figure 30, and
Figure 49.

55
7 Adjusting Denoising/Filtering Settings

Adjusting signal denoising/ltering appropriately is important for the overall quality of ECG

analysis. BRAVEHEART utilizes wavelet based signal denoising/ltering to remove

high-frequency artifact and low-frequency baseline wander. Wavelet based denoising/ltering

decomposes the signal, removes either high-frequency or low-frequency noise/wander, and then

reconstructs the noise free signal. This process is dierent than standard linear ltering, and

helps preserve the underlying features of the ECG with minimal distortion while removing the

unwanted noise/wander. The actual denoising process is explained in more detail in our methods

manuscript [1], and more information on wavelet decomposition and denoising can be found in

other references [8].

The denoising/ltering settings are controlled in the ` Filtering and Peak Detection' section
of the GUI, but the same principles for adjusting these settings apply when using the command

line version of BRAVEHEART via Annoparams.m (see Chapter 6 for additional details).

Additional details on controlling denoising/ltering via the GUI can be found in Chapter 12.2.

7.1 High-frequency Denoising (Low-pass Filtering)


High-frequency noise removal is enabled/disabled with the checkbox for V Wavelet Low Pass :

56
To the right of this checkbox there is a dropdown to choose a mother wavelet (see Chapter 6
information on wavelet_name_lowpass ). In the vast majority of cases this can be left alone at

the default value of `Sym4', but this can be changed if needed. The dropdown to the right with

selectable integer values sets the wavelet decomposition level that controls the minimum

frequency of noise that is removed (see Chapter 6 information on wavelet_level_lowpass ):

The Low-pass ltering frequency cuto (fc ) removes frequencies above a cuto given by the
equation fc = fs /2n+1 , where fs is the ECG sampling frequency and n is a positive, non-zero

integer. For example, if the ECG is sampled at 500 Hz, a level (n) of 2 corresponds to a

frequency cuto of fc = 500/23 = 62.5 Hz. Therefore, if the level is set = 2, the low-pass ltering

will remove frequencies higher than 62.5 Hz. Similarly, level 1 with an ECG sampled at 500 Hz

corresponds to a frequency cuto of fc = 500/22 = 125 Hz, and level 2 with an ECG sampled at

1000 Hz also corresponds to a frequency cuto of fc = 1000/23 = 125 Hz. A table of wavelet

decomposition levels and ltering frequency cutos is shown here:

Table 1: Denoising/ltering frequency cutos based on wavelet decomposition level (n) and ECG sampling fre-
quency of 500, 1000, and 2000 Hz.

Level (n) 500 Hz 1000 Hz 2000 Hz


1 125.00 250.00 500.00

2 62.50 125.00 250.00

3 31.25 62.50 125.00

4 15.63 31.25 62.50

5 7.81 15.63 31.25

6 3.91 7.81 15.63

7 1.95 3.91 7.81

8 0.98 1.95 3.91

9 0.49 0.98 1.95

10 0.24 0.49 0.98

11 0.12 0.24 0.49

12 0.061 0.12 0.24

13 0.031 0.061 0.12

14 0.015 0.031 0.061

The BRAVEHEART GUI low-pass ltering/denoising defaults to level 1 for ECGs sampled at

500 Hz, and level 2 for ECGs sampled at 1000 Hz, corresponding to a low-pass cuto of 125 Hz

(note the wavelet level in the example gures is set to level 2, which corresponds to a frequency

cuto of 62.5 Hz, not the nominal value of level 1). For ECGs of other sampling frequencies, the

level defaults to 1. The Command line version of BRAVEHEART does not automatically adjust
the wavelet levels based on ECG frequency, and the correct level (not frequency!) must be set in

Annoparams.m (see Chapter 6).

57
7.2 Low-frequency Denoising (High-pass Filtering) for Baseline Wander
Removal
Low-frequency baseline wander removal is enabled/disabled with the checkbox for

V Wavelet High Pass :

To the right of this checkbox there is a dropdown to choose a mother wavelet (see Chapter 6
information on wavelet_name_highpass ). In the vast majority of cases this can be left alone at

the default value of `db4', but this can be changed if needed, and sometimes mother wavelets

with a higher number of vanishing moments (such as db10) may more eectively remove baseline

wander. The drop down to the right with selectable integer values sets the wavelet

decomposition level that controls the maximum frequency of baseline wander that is removed

(see Chapter 6 information on wavelet_level_highpass ):

Similar to low-pass ltering, the high-pass ltering frequency cuto (fc ) removes frequencies

below a cuto given by the equation fc = fs /2n+1 , where fs is the ECG sampling frequency and

n is a positive, non-zero integer. Compared to the values of n used for low-pass

denoising/ltering which are usually going to be low numbers between 1 and 3 depending on the

ECG sampling frequency, to remove low-frequency baseline wander, we have to use higher values

of n, usually > 9, depending on ECG sampling frequency (See Table 1 above). The maximum

wavelet decomposition level depends on the length of the signal in samples (L) and is given as

nmax = floor(log2 L); for a 10 second ECG sampled at 500 Hz, nmax = 12. If you choose an n
above nmax the software will give an error and the ECG will not process.

For example, if the ECG is sampled at 500 Hz, a level of 10 corresponds for a frequency cuto of

fc = 500/211 = 0.244 Hz, and a level of 9 corresponds for a frequency cuto of

fc = 500/210 = 0.488 Hz. If the ECG sampling frequency is 1000 Hz, a level of 11 corresponds

for a frequency cuto of fc = 1000/212 = 0.244 Hz and a level of 10 corresponds for a frequency

cuto of fc = 1000/211 = 0.488 Hz (see Table 1 above).

58
Importantly, high-pass ltering can distort the ST segment and T wave due to the fact that

these parts of the ECG signal can contain low frequency components with the same frequencies

as the baseline wander. In general, you should keep the high-pass ltering frequency as low as

possible, and use of values > 0.67 Hz is not recommended [9]. We have found that a value of

0.24 Hz works well for most applications, and that this could be increased to ∼ 0.5 Hz if needed

without signicant distortion. When using the GUI, when an ECG is loaded, the high-pass

wavelet level is automatically chosen as the highest level with a cuto frequency < 0.25 Hz based

on the frequency noted in the external le ecg_formats.csv (see Chapter 8.3). If other

levels/frequencies are needed, the levels can be changed and the ECG can be reloaded.

7.3 Denoising/Filtering Frequencies and Visualizing Results


After the the ECG is loaded, text to the right of the wavelet level selection dropdowns will show

the ltering frequency that corresponds to the ECG sampling frequency and chosen wavelet

decomposition level:

This section will also display an error if you choose a wavelet level greater than the maximum.

Note that in this example, the ECG is sampled at 500 Hz (see `Signal Data' in the upper right),

the low-pass wavelet level of 2 corresponds to a frequency cuto of 62.5 Hz, and the high-pass

wavelet level of 10 corresponds to a frequency cuto of 0.24 Hz. The wavelet based

denoising/ltering will therefore remove high-frequency noise above 62.5 Hz and will remove

baseline wander below 0.24 Hz. In reality, these frequency cutos are not absolute, and there will

be some leakage of frequencies around these cuto points. Additionally, a signicant benet of

wavelet based denoising over standard linear ltering is that wavelet based denoising is able to

remove noise while preserving the original signal even if the signal shares frequencies that are to

be removed with denoising. Further details can be found in our methods manuscript [1] and

other wavelet references [8].

59
The Filtering button displays the original signals and the ltered and baseline corrected signals so

that you can visualize the denoising process:

Further details can be found in Chapter 20.12 and Chapter 12.2.

7.4 Denoising/Filtering Using braveheart_batch.m

The command line version of BRAVEHEART braveheart_batch.m does NOT automatically


adjust any denoising/ltering settings based on ECG frequency as occurs when using the

BRAVEHEART GUI. To set the ltering settings, set the relevant values in Annoparams.m
before running braveheart_batch.m :

...
lowpass = 1; % Low pass wavelet filter on/off
highpass = 1; % High pass wavelet filter on/off
wavelet_level_lowpass = 1; % LPF freq is > samp freq/2^(wavelet_level_lowpass + 1)
wavelet_level_highpass = 10; % HPF freq is < samp freq/2^(wavelet_level_highpass + 1)
wavelet_name_lowpass = 'sym4'; % Low-pass wavelet (Sym4, Sym5, Sym6, db4, db8, db10, etc)
wavelet_name_highpass = 'db4'; % High-pass wavelet (Sym4, Sym5, Sym6, db4, db8, db10, etc)
...

Note that you will have to do your own calculation (see Table 1) to determine what frequency
cuto corresponds to the values of wavelet_level_lowpass and wavelet_level_highpass based

on the ECG sampling frequency.

60
8 Adding New ECG Formats

BRAVEHEART can read a variety of ECG data formats (see Chapter 23). However, if you are

using an ECG le format which cannot be read by BRAVEHEART currently, you will have to

supply your own load module and modify the relevant part of the ECG12 constructor in the le

ECG12.m . Fortunately, adding new ECG formats to BRAVEHEART is straightforward, and only

2 les ( ECG12.m and ecg_format.csv ) need to be edited as described in the following sections:

8.1 The ECG12 Object


12-lead ECG data is stored in an ECG12 object which contains the following 14 properties:

ˆ hz  the ECG sampling frequency in Hz

ˆ units  an optional string describing ECG voltage units (usually 'mV' )


ˆ I  voltage data for ECG lead I

ˆ II  voltage data for ECG lead II

ˆ ... III, avR, avL, aVF, V1, V2, V3, V4, V5, V6  voltage data for these leads

Note that only 2 of the 6 frontal leads ( I, II, III, avR, avL, aVF ) contain unique

information.

The data within an ECG12 object is accessed by querying its properties as if it were a normal

data structure in MATLAB; for example, if you have an ECG12 object named ecg , lead II would

be accessed as ecg.II , and the sampling frequency would be accessed as ecg.hz .

61
8.2 Editing ECG12.m

We will start by adding a new format (called New Format) to BRAVEHEART. At line 66 of

ECG12.m you will see a switch statement which constructs ECG12 objects based on a source

format string ( format ), such as 'bidmc_format' or 'muse_xml' , and a function to load the

ECG data from a le:

% ADD NEW ECG FORMATS TO THIS SWITCH STATEMENT


switch format

case 'bidmc_format'
obj.hz=500;
unitspermv=200;
[obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, ...
obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6] = load_ecg(filename, unitspermv, format);

case 'muse_xml'
[obj.hz, obj.I, obj.II, ...
obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6] = load_musexml(filename);
obj.III = -obj.I + obj.II;
obj.avF = obj.II - 0.5*obj.I;
obj.avR = -0.5*obj.I - 0.5*obj.II;
obj.avL = obj.I - 0.5*obj.II;

...

end

We will add a new case statement with a function that generates all of the parts of an ECG12
object (the units property is optional).

For example, if you have a function load_new_format.m which loads an ECG in 'new_format'
format from a .txt le (input variable name filename ), the outputs of the function should

include the frequency ( obj.hz ) and the 12 ECG leads ( obj.<lead> ). Note that you can supply

all 12 leads as the output of the load function (see 'bidmc_format' in the code block above), or

you can supply the 8 independent leads in the load function and then reconstruct the 4

additional frontal plane leads in ECG12.m itself (see 'muse_xml' in the code block above).

62
After this addition, you will have something that looks like this

% ADD NEW ECG FORMATS TO THIS SWITCH STATEMENT


switch format

case 'bidmc_format'
obj.hz=500;
unitspermv=200;
[obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, ...
obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6] = load_ecg(filename, unitspermv, format);

case 'muse_xml'
[obj.hz, obj.I, obj.II, ...
obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6] = load_musexml(filename);
obj.III = -obj.I + obj.II;
obj.avF = obj.II - 0.5*obj.I;
obj.avR = -0.5*obj.I - 0.5*obj.II;
obj.avL = obj.I - 0.5*obj.II;

case 'new_format'
[obj.hz, obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, ...
obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6, obj.avL] = load_new_format(filename);

...

end

Editing of ECG12.m is now complete.

8.3 Editing ecg_formats.csv

In addition to the ECG constructor, you will need to modify ecg_formats.csv to use your new

format. ecg_formats.csv is an external, comma delimited, editable le that links the ECG

format with associated le extensions and labels. ecg_formats.csv is also the way that new

ECG formats are added to the BRAVEHEART GUI without the hassle of needing to edit the

GUI gure.

MUSE .xml, muse_xml, .xml, 500


BIDMC .txt, bidmc_format, .txt, 500
Prucka .txt, prucka_format, .txt, 997
Philips .xml, philips_xml, .xml, 500
ISHNE .ecg, ISHNE, .ecg, 1000
GE .mrq, mrq_ascii, .mrq, 500
DICOM .dcm, DICOM, .dcm, 500
HL7 .xml, hl7_xml, .xml, 500
Unformatted .txt, unformatted, .txt, 500
Cardiosoft .xml, cardiosoft_xml, .xml, 500

63
The rst column in ecg_formats.csv is the text that shows up in the GUI when selecting the

ECG format (New Format .txt). This can be a string with punctuation or spaces. Column 2 is

the ECG format string ( format ) which was added to the switch statement above

( 'new_format' ), column 3 is the new ECG format le extension ( .txt ), and column 4 is the

sampling frequency of the ECG signals which is used by the GUI to select the nominal wavelet

levels for ltering. The actual frequency used in calculations is determined when the ECG is

actually loaded from the le (see section Chapter 8.1 describing the ECG12 class which includes

sampling frequency ( hz ) as a property), and the frequency in column 4 of ecg_formats.csv is

only used to update the nominal ltering settings in the GUI when a dierent format is chosen

from the `ECG format' dropdown. The frequency in column 4 has no eect when

BRAVEHEART is being run from braveheart_batch.m where all ltering is set in

Annoparams.m (or Annoparams.csv if the program is compiled).

For example, if ECGs of the format ( 'new_format' ) are sampled at 1000 Hz, but the

ecg_formats.csv le column 4 lists the sampling frequency for this format at 500 Hz, the

low-pass ltering wavelet level will be set to 1 (nominal for 500 Hz) instead of 2 (nominal for

1000 Hz) when you choose the ( 'new_format' ) format in the GUI dropdown (see Chapter 7).
The dierence in wavelet ltering settings will slightly change the ltered ECG/VCG signals and

therefore slightly change subsequent calculations, but all calculations will use the correct

sampling frequency of 1000 Hz, because the correct sampling frequency would be pulled from the

ECG12 object hz property when the le is loaded (note that some le formats have the sampling

frequency hard coded when they are loaded by ECG12 if that information is not part of the ECG

data le). As the command line version of BRAVEHEART does not utilize any part of the GUI,

the frequencies in column 4 of ecg_formats.csv are ignored when using braveheart_batch.m .

To add the 'new_format' ECG format as shown above to ecg_formats.csv , you would add a

new line to ecg_formats.csv including a name for the GUI, format name, format le extension,

and sampling frequency as shown here:

64
MUSE .xml, muse_xml, .xml, 500
BIDMC .txt, bidmc_format, .txt, 500
Prucka .txt, prucka_format, .txt, 997
Philips .xml, philips_xml, .xml, 500
ISHNE .ecg, ISHNE, .ecg, 1000
GE .mrq, mrq_ascii, .mrq, 500
DICOM .dcm, DICOM, .dcm, 500
HL7 .xml, hl7_xml, .xml, 500
Unformatted .txt, unformatted, .txt, 500
Cardiosoft .xml, cardiosoft_xml, .xml, 500
New Format .txt, new_format, .txt, 500

This will now link the format 'new_format' to the le extension .txt . When the GUI is used

the string  New Format .txt will show up in the ECG format dropdown, and choosing this

format in the dropdown will automatically choose nominal ltering settings for an ECG sampled

at 500 Hz.

8.4 Using Newly Added ECG File Formats


If you are using the command line version of BRAVHEART (see Chapter 13), simply use your
new format string (in the above example 'new_format' ) in the header of BRAVEHEART_batch.m
or batch_settings.csv if you are using the compiled version (remember that when editing

batch_settings.csv that strings should NOT be surrounded by quotes).

If you are using the GUI version of BRAVEHEART, simply choose the new format from the

`ECG format' dropdown (see GUI item 1.1 in Chapter 12).

The default ECG format selected when loading the GUI is the rst row in ecg_formats.csv .

If your ECG format includes data such as age and sex, you can add the relevant data to

xml_demographics.m to automatically pull this data into the GUI for use when viewing normal

ranges of various VCG parameters (see Chapter 22).

65
9 Adding New Transformation Matrices

BRAVEHEART includes the Kors [4] and inverse Dower [5] transformation matrices to convert

the 12-lead ECG into a VCG using 8 independent ECG leads. In certain situations, alternative

transformation matrices may be needed. This section will illustrate how it is straightforward to

add a new transformation matrix to BRAVEHEART. For illustrative purposes we will add a new

transformation matrix called the NewMatrix transformation.

9.1 Create a Function for The New Transformation Matrix


We will start by creating a function newmatrix() in a le newmatrix.m which simply contains

the coecients for the new transformation matrix. This should be a 3 × 8 matrix with rows

corresponding to X, Y, and Z, and columns ordered as V1, V2, V3, V4, V5, V6, I, and II:

function M = newmatrix()
% Note: These are random numbers
% V1 V2 V3 V4 V5 V6 I II
M = [ -0.23 0.15 -0.02 0.13 0.10 0.62 0.44 -0.09 ; % X
0.10 -0.12 -0.12 0.10 -0.11 0.13 -0.11 0.98 ; % Y
-0.32 -0.36 0.12 -0.23 -0.05 0.22 0.21 -0.14 ]; % Z
end

9.2 Editing ecgtransform.m

The actual transformation between ECG to VCG is performed by the function

ecg_transform.m . The new transformation matrix will have to be added to this le.

Start by opening ecg_transform.m :

function [X, Y, Z, VM] = ecgtransform(L1, L2, V1, V2, V3, V4, V5, V6, transform_matrix)

% Create matrix of leads V1, V2, V3, V4, V5, V6, I, II = Matrix E
E = [ V1, V2, V3, V4, V5, V6, L1, L2 ];

% Choose transformation matrix

switch transform_matrix
case 'Dower'
M = dowermatrix();
case 'Kors'
M = korsmatrix();
otherwise
error('Unknown transform_matrix: %s', transform_matrix);
end

...

66
Add a new case statement to the switch statement with a string that is the name of the

transformation matrix ( 'NewMatrix' ) and which assigns M = newmatrix() .

switch transform_matrix
case 'Dower'
M = dowermatrix();
case 'Kors'
M = korsmatrix();
case 'NewMatrix'
M = newmatrix();
otherwise
error('Unknown transform_matrix: %s', transform_matrix);
end

9.3 Editing transform_mat.csv

Finally, to add the new transformation matrix to the GUI dropdown, edit transform_mat.csv to

include the new string used in the switch statement (in this example NewMatrix ). Strings in

transform_mat.csv need to be in the order they appear in the switch statement. As with

editing the contents of all BRAVEHEART .csv les, do not include quotes around strings.

Kors
Dower
NewMatrix

9.4 Using Newly Added Transformation Matrices


If using the command line version of BRAVHEART (see Chapter 13), open Annoparams.m (or

Annoparams.csv if you are using the compiled version) and assign the newly created

transformation matrix string to the parameter transformation_matrix_str (e.g.

transformation_matrix_str = 'NewMatrix' ).

If you are using the GUI version of BRAVEHEART, simply choose the new format from the

`Transform. Matrix' dropdown (see GUI item 1.2 in Chapter 12).

67
68
10 Adding New ECG/VCG Parameters

New ECG/VCG measurements or parameters can easily be added to BRAVEHEART. To

illustrate the process we will add a new measurement called newvar to BRAVEHEART. Note

that although this parameter will be automatically added to BRAVHEART's output les,

adding new measurements to the GUI output panels requires more extensive editing of the GUI

gure and other functions that are beyond the scope of this guide.

10.1 Result Classes


BRAVEHEART currently has 3 results classes which are used to store dierent ECG/VCG

measurements. These classes automatically update the output les at the time of data export, so

minimal coding is required to add a new measurement. The 3 existing results class objects are

somewhat arbitrarily divided into VCG_Calc.m which contains mostly ECG and VCG

measurements such as ECG intervals, and vector measurements, Lead_Morphology.m which

contains mostly ECG/VCG QRST complex measurements, and VCG_Morphology.m which

contains mostly VCG loop morphology measurements. We suggest that you add your new

measurement to one of these existing results classes to minimize the need for coding. Each of

these 3 results classes takes slightly dierent inputs, so make sure the class you add to has the

required inputs for your new measurement. If your new function is extremely complicated and

requires more than the ECG/VCG median beat signals, ECG median beat ducial point

annotations, or annotation parameters (which are the inputs to the existing results classes),

addition of your parameter might require more extensive coding which is beyond the scope of

this guide. Descriptions of the dierent calculations that are performed by each result class and

the variable names which store the results internally and in output les are shown in Chapter
24. All results classes operate on median beats.

We review the 3 results classes in the following sections:

69
10.1.1 VCG_Calc.m

VCG_Calc.m takes the following inputs:

ˆ A Beats class object

ˆ A VCG class object

ˆ An Annoparams class object

A Beats class objects is used to describe individual beat annotations after rst pass heuristic

ECG annotation or median beat annotation. The Beats class object contains the following 7

properties which describe the locations of ducial points and other features:

ˆ Q  location (in samples) of QRS onset (Qon ) for the median beat

ˆ QRS  location (in samples) of the R wave peak for the median beat

ˆ S  location (in samples) of QRS oset (Qoff ) for the median beat

ˆ T  location (in samples) of T wave peak for the median beat

ˆ Tend  location (in samples) of T wave oset (Toff ) for the median beat

ˆ outlier  index of outlier beats (not applicable for median beats)

ˆ pvc  index of PVCs/non-dominant beats (not applicable for median beats)

The data within a Beats object is accessed by querying its properties as if it were a normal data

structure in MATLAB; for example, if you have an Beats object named median_beat , the

location of the T wave end would be accessed as median_beat.Tend . This is critically important

for any new functions that are added to the results classes, because the location of the ducial

points on the median beat signal need to be accounted for in all calculations; the median beat

signals have variable amounts of signal before and after the QRST complex which should NOT

be included in calculations.

A VCG class object is analogous to the ECG12 class object (see Chapter 8.1) and contains the
following 7 properties:

ˆ hz  the VCG sampling frequency in Hz

ˆ units  an optional string describing VCG voltage units (usually 'mV' )

ˆ X  voltage data for VCG lead X

ˆ Y  voltage data for VCG lead Y

ˆ Z  voltage data for VCG lead Z

70

ˆ VM  voltage data for the VM VCG lead (VM = X2 + Y2 + Z2 ).
ˆ endspikes  data on location of pacemaker spikes (if present)

The data within a VCG object is accessed by querying its properties as if it were a normal data

structure in MATLAB; for example, if you have an VCG object named vcg , lead X would be

accessed as vcg.X .

An Annoparams class object is described in detail in Chapter 6. The data within an

Annoparams object is accessed by querying its properties as if it were a normal data structure in

MATLAB; for example, if you have an Annoparams object named aps , the parameter lowpass

would be accessed as aps.lowpass .

In VCG_Calc.m the VCG class object is a variable named v_uncropped , the Beats class object is a

variable named medianbeat , and the Annoparams class object is a variable named aps .

VCG_Calc contains a function called crop which cuts out the median QRST complex from the

full median VCG signal. The variable v_cropped is the VCG class object which only contains the

actual QRST complex. v_cropped.X is equivalent to

v_uncropped.X(medianbeat.Q:medianbeat.Tend) (and the same for leads Y, Z, and VM).

10.1.2 Lead_Morphology.m

Lead_Morphology.m includes the following inputs:

1. An ECG12 class object

2. A VCG class object

3. A Beats class object

4. An Annoparams class object

The parameters in each of these class objects have been previously described above.

In Lead_Morphology.m the ECG12 class object is a variable named ecg , the VCG class object is a

variable named vcg , and the Annoparams class object is a variable named aps . When the

Lead_Morphology class is called, the median beat Beats class object input is converted to a

1×4 vector named fidpts , which contains the values of

[beats.Q, beats.QRS, beats.S, beats.Tend] in that order which is analogous to the values of

71
[Qon , R peak, Qoff , Toff ]. The location of Qon can therefore be called as fidpts(1) , the location

of the R peak can be called as fidpts(2) , the location of Qoff can be called as fidpts(3) , and

the location of Toff can be called as fidpts(4) . As another example, the QRS complex in lead X

would be obtained as vcg.X(fidpts(1):fidpts(3)) , and the full QRST complex in lead Y

would be obtained as vcg.Y(fidpts(1):fidpts(4)) . There is no crop function in

Lead_Morphology.m , although it could be added if needed.

10.1.3 VCG_Morphology.m

VCG_Morphology.m includes the following inputs:

1. An ECG12 class object

2. A VCG class object

3. A Beats class object

The parameters in each of these class objects have been previously described above.

In VCG_Morphology.m the ECG12 class object is a variable named ecg , and the VCG class object

is a variable named vcg . Similar to the Lead_Morphology class, when the VCG_Morphology class

is called, the median beat Beats class object input is converted to a 1×4 vector named fidpts

which contains the values of [beats.Q, beats.QRS, beats.S, beats.Tend] in that order (see

Chapter 10.1.2 above).

72
10.2 Adding a New Calculation
We will add our new measurement to VCG_Calc.m . We start by opening VCG_Calc.m and nding

the properties section at the top.

classdef VCG_Calc
%
properties (SetAccess=private)
% SVG
svg_x
svg_y
svg_z

% SAI
sai_x
sai_y
sai_z

...

% QRS/QT intervals (in ms)


qrs_int
qt_int
end

Further down in the methods section of VCG_Calc.m you will see a busy chunk of code starting

around line 184 with the comment % ADD NEW MEASUREMENTS IN THIS SECTION assigning various

values to the members of the VCG_Calc class:

% ADD NEW MEASUREMENTS IN THIS SECTION


...

obj.vcg_length_qrs = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, 1, qend);


obj.vcg_length_t = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, qend, length(v_cropped.X));
obj.vcg_length_qrst = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, 1, length(v_cropped.X));

...

In this code snippet (which is a small part of the VCG_Calc class property assignments), the

values of vcg_length_qrs , vcg_length_t , and vcg_length_qrst (see Chapter 24) are assigned
their respective properties in the class, obj.vcg_length_qrs , obj.vcg_length_t , and

obj.vcg_length_qrst , respectively. Again, note how the calculations use the cropped VCG lead

signals (just the QRST complex) ( v_cropped.X , v_cropped.Y , and v_cropped.Z ) rather than

v_uncropped which is the QRST complex with additional signal before Qon and additional signal

after Toff .

73
Our new measurement newvar is calculated from a function called calc_newvar(x,y,z,beats)
which is saved in a le calc_newvar.m :

newvar = calc_newvar(x,y,z,beats)

This function takes in median X, Y, and Z QRST complexes and a Beats object and outputs the

value of newvar . We start by adding newvar to the properties section of VCG_Calc.m :

classdef VCG_Calc
%
properties (SetAccess=private)
% SVG
svg_x
svg_y
svg_z

% SAI
sai_x
sai_y
sai_z

% New Measurement
newvar
...

% QRS/QT intervals (in ms)


qrs_int
qt_int
end

We then insert the function which is used to calculate newvar into the methods section of

VCG_Calc.m , assigning its output to obj.newvar :

% ADD NEW MEASUREMENTS IN THIS SECTION


...

obj.vcg_length_qrs = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, 1, qend);


obj.vcg_length_t = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, qend, length(v_cropped.X));
obj.vcg_length_qrst = curve_length(v_cropped.X, v_cropped.Y, v_cropped.Z, 1, length(v_cropped.X));

obj.newvar = calc_newvar(v_cropped.X, v_cropped.Y, v_cropped.Z, beats);

...

Once the new variable is added to a result class, no further les require editing. The functions

for exporting data will now automatically include a variable called newvar and assign it the

value calculated by the calc_newvar function.

Chapter 24 lists the dierent parameters that are included in each of the results classes.

74
11 Adding New Denoising/Filtering

BRAVEHEART utilizes wavelet based high-frequency and low-frequency denoising/ltering (see

Chapter 7 which have many benets over conventional linear lters [1, 8]. However, if you have

need for an alternative denosing/ltering scheme, this can be added to BRAVEHEART by

editing the ecgfilter.m and ECG12.m les.

11.1 Calling the ECG Denoising/Filtering Function from ECG12.m

Lines 153180 of ECG12.m (see Chapter 8 for further details on the ECG12 class) are devoted to

the denoising/ltering class function called filter . There is no analogous denoisng/ltering

function within the VCG class because the ECG is ltered prior to transformation into a VCG.

function [obj, highpass_lvl_min] = filter(obj, maxRR_hr, aps)

...
[obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6,
highpass_lvl_min] = ...
ecgfilter(obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, obj.V1, obj.V2, obj.V3, obj.V4,
obj.V5, obj.V6, ...
obj.hz, maxRR_hr, ...
aps.lowpass, aps.wavelet_level_lowpass, aps.wavelet_name_lowpass, ...
aps.highpass, aps.wavelet_level_highpass, aps.wavelet_name_highpass);
...
end

This calls the function ecgfilter() on the ECG12 object. If you have an ECG12 class object

named ecg , the ltered ECG class object is generated as:

filtered_ecg = ecg.filter(NaN, aps);

where aps is an Annoparams object (see Chapter 6) that includes the ltering settings which
are passed into the function. The rst NaN is a placeholder for some additional high-pass ltering

settings that may be incorporated in a future release of BRAVEHEART, but for now the value

has no eect. When using the GUI there is a second optional output ( highpass_lvl_min ) that is

used to show the level used for high-pass wavelet decomposition in the GUI (see line 3233 in

braveheart_gui.m ).

75
11.2 Editing ecgfilter.m

To add new ltering schemes you will need to edit the function ecgfilter() in the le

ecgfilter.m :

function [L1, L2, L3, avR, avF, avL, V1, V2, V3, V4, V5, V6, final_lf_wavelet_lvl_min] = ...
ecgfilter(L1, L2, L3, avR, avF, avL, V1, V2, V3, V4, V5, V6, freq, maxRR_hr, ...
wavelet_filt, wavelet_level, wavelet_name, wavelet_filt_lf, wavelet_level_lf, wavelet_name_lf)

This function takes the inputs of the 12 ECG leads individually ( L1 , L2 , L3 , avF , avL , avR , V1 ,
V2 , V3 , V4 , V5 , V6 ), the sampling frequency freq , the placeholder variable for future

functionality as noted above ( maxRR_hr = NaN ), and variables which describe if high/low pass

ltering should be performed, and if so, which mother wavelet and decomposition level should be

used ( wavelet_filt , wavelet_level , wavelet_name , wavelet_filt_lf , wavelet_level_lf ,


wavelet_name_lf ).

The outputs of the function include the 12 ltered leads, and a numeric variable

final_lf_wavelet_lvl_min which encodes the level of decomposition used for high-pass

denoising/ltering that is used for GUI display only.

Our suggestion would be to NOT alter the output variable structure of the ecgfilter function

so that there is still an numeric output variable called final_lf_wavelet_lvl_min even if it is

not being used. This will save you some trouble integrating with the GUI even if you are

utilizing a new ltering method that has nothing to do with wavelets, although this is not an

issue if you are using the command line version of BRAVEHEART. Updating the GUI to reect

use of the new ltering scheme is beyond the scope of this guide.

Edit ecgfilter.m as needed to implement your new ltering scheme with the requisite outputs

as noted above. To control your new lter you can edit Annoparams.m and simply add any new

parameters and default values that you want. These parameters will obviously not be editable in

the GUI unless you edit the GUI gure/code. You can then edit the inputs as needed when

calling the ltering function within ECG12.m at the location noted above. The only place

ecgfilter is called within the entire BRAVEHEART software package is within ECG12.m , so

you will not have to edit any other sections of code to fully integrate the new ltering function

with BRAVEHEART. You should leave the parameters reecting the nominal wavelet based

denoising/ltering in Annoparams.m because the output les will throw errors if these values are

undened when using the GUI. Any new parameters that are added to Annoparams.m will

automatically be exported with their values during ECG processing.

76
For example, lets add a simple low-pass lter with a passband frequency of 150 Hz and a simple

high-pass lter with a passband frequency of 0.2 Hz. NOTE: these simple types of lters will
likely cause signicant phase shifts in the signal and are not recommended for actual use! - this

is just an illustrative example of how to edit the BRAVEHEART denoising/ltering source code.

We rst add new parameters to Annoparams.m to control our new lters:

% New filtering parameters


newlowpass = 1; % Low-pass filter on/off
newhighpass = 1; % High-pass filter on/off
lowpassfreq = 150; % Low-pass passband (Hz)
highpassfreq = 0.2; % High-pass passband (Hz)

Next, we edit ecgfilter.m so that it looks like this (remember we left

final_lf_wavelet_lvl_min in the output to avoid breaking the GUI). In the interest of space

all 12 leads were not included in this code snippet:

function [L1, L2, L3, avR, avF, avL, V1, V2, V3, V4, V5, V6, final_lf_wavelet_lvl_min] = ...
ecgfilter(L1, L2, L3, avR, avF, avL, V1, V2, V3, V4, V5, V6, freq, ...
newlowpass, lowpassfreq, newhighpass, newhighpassfreq)

% High-pass
if newhighpass == 1
L1 = highpass(L1, highpassfreq, freq);
...
V6 = highpass(V6, highpassfreq, freq);
end

% Low-pass filter
if newlowpass == 1
L1 = lowpass(L1, lowpassfreq, freq);
...
V6 = lowpass(V6, lowpassfreq, freq);
end
final_lf_wavelet_lvl_min = 0; % This needs a value to not break GUI as noted above

end

77
11.3 Editing ECG12.m

Finally, we edit ECG12.m starting at line 164 to incorporate the new ecgfilter function into the

ECG12 class function filter , leaving highpass_lvl_min in the output of the function to avoid

breaking the GUI as noted above. Note the need to use the prex obj. to assign these values to

the ECG12 class object.

function [obj, highpass_lvl_min] = filter(obj, maxRR_hr, aps)

[obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, obj.V1, obj.V2, obj.V3, obj.V4, obj.V5, obj.V6,
highpass_lvl_min] = ...
ecgfilter(obj.I, obj.II, obj.III, obj.avR, obj.avF, obj.avL, obj.V1, obj.V2, obj.V3, obj.V4,
obj.V5, obj.V6, ...
obj.hz, ...
aps.newlowpass, aps.lowpassfreq, aps.newhighpass, aps.highpassfreq);
...
end

Enabling/disabling these new high- and low-pass lters, and adjusting their frequency

passbands, is now controlled via setting the parameters in Annoparams.m . Although the default

wavelet-based denoising/ltering parameters are still present in Annoparams.m these parameters

will be ignored and the new ltering scheme will be used.

78
12 Using the BRAVEHEART GUI

12.1 GUI Overview


In addition to batch processing of ECGs via braveheart_batch.m (see Chapter 13), the
BRAVEHEART GUI facilitates control over each step of ECG/VCG processing and can generate

additional gures and data visualizations. In this chapter we provide an overview of the dierent

functions of the GUI and how to process ECGs from les to measurements saved for further

processing.

To run the BRAEHEART GUI, type braveheart_gui in the MATLAB Command Window if

the program is being run via source code within MATLAB, or open the executable if running via

a compiled version of the GUI.

The BRAVEHEART GUI window immediately after opening is shown below in Figure 1. The

appearance on your computer may vary slightly based on your operating system. A screen

resolution of at least 1920 x 1080 is required.

Figure 1: GUI when BRAVEHEART is rst loaded.

The GUI is organized into 10 dierent sections which, in general, have dierent functions. The

79
dierent sections of the GUI are shown below in Figure 2; a general description of each section
is provided followed by detailed descriptions of GUI items within each section.

Figure 2: GUI Sections 110.

Many of the parameters that are set using the GUI correspond to the properties in the

Annoparams.m class, and users are referred toChapter 6 for further details of each property. A
summary of the link between Annoparams.m and sections of the GUI is provided in Chapter 26.

The GUI also contains other functions and visualization that are unique to the GUI and which

allow ne control and/or visualization of dierent steps in ECG/VCG processing.

Throughout the guide, to denote a specic section/item within the GUI, the term `GUI item

N.M' with numbers in red text will be used; N refers to the GUI section (110) as noted in
Figure 2 above, and M refers to the numbered item within the section as detailed in the
subsequent sections. For example, the Load button would be denoted as GUI item 1.9 as it is
item 9 in GUI section 1, and the Calculate button would be similarly denoted as GUI item 3.6.

Section 6 is unique in that what is displayed depends on what button is selected in Section 5.

For Section 6 alone, there is an extra number to denote the specic part of the GUI that is being

shown. For example, the Vectorcardiogram button (GUI item 5.1) loads GUI section 6.1, and
the rst item in this section is noted as GUI item 6.1.1, while the the VCG Morphology button

80
loads GUI section 6.4 and the rst item in this section is noted as GUI item 6.4.1.

12.2 GUI Section 1  ECG Loading, Filtering, R Peak Detection, and


Baseline Correction
Section 1:
Choose an ECG le and load (or reload) the ECG data. Choose options for transformation of

the ECG into a VCG, QRS peak detection, signal ltering, and pacemaker spike removal.

Figure 3: GUI Section 1

1. Dropdown to select the format of the ECG to be loaded. Sets the value of format in the

ECG constructor ECG12.m . The link between the text shown in the dropdown and the

actual format that is utilized by the GUI is contained in the external le

ecg_formats.csv (see Chapter 8). Additional information on ECG formats that can be

read by BRAVEHEART and how to add new formats can be found in Chapter 23 and
Chapter 8, respectively.

2. Dropdown to select the VCG transformation matrix used to transform the ECG into a

VCG. Sets the value of transform_matrix_str in Annoparams.m . BRAVEHEART includes

the Kors [4] and inverse Dower [5] transformation matrices. Additional transformation

matrices can be added as described in Chapter 9.

3. Select and choose options for low-pass ltering. The V Wavelet Low Pass checkbox

enables/disables low-pass ltering by setting lowpass = 1 (checked) or lowpass = 0


(unchecked) in Annoparams.m . The dropdowns allows you to choose the wavelet used for

low-pass ltering ( wavelet_name_lowpass ) and the level of ltering

( wavelet_level_lowpass ) in Annoparams.m (see Chapter 6.2 and Chapter 7).

After the ECG is loaded, the text to the right of GUI item 1.3 shows the low-pass cuto

81
frequency which corresponds to the chosen wavelet level based on the equation fs /(2n+1 )
where fs is the ECG sampling frequency and n is the chosen level

( wavelet_level_lowpass ). In this example, the low-pass lter has a cuto frequency of

62.5 Hz which corresponds to level 2 at a sampling frequency of 500 Hz. In general try to

avoid choosing a level that results in low-pass ltering cuto < 40 Hz as the QRST complex
tends to include frequencies between 0.5-40 Hz [3]. Filtering can be visualized with a gure

generated with the Filtering button (GUI item 1.15) as shown in Figure 46.

4. Select and choose options for high-pass ltering. The V Wavelet High Pass checkbox

enables/disables high-pass ltering by setting highpass = 1 (checked) or highpass = 0


(unchecked) in Annoparams.m . The dropdowns allow you to choose the wavelet used for

high-pass ltering ( wavelet_name_highpass ) and the level of ltering

( wavelet_level_highpass ) in Annoparams.m (see Chapter 6.2 and Chapter 7).

After the ECG is loaded, the text to the right of GUI item 1.4 shows the high-pass cuto
frequency which corresponds to the chosen wavelet level based on the equation fs /(2n+1 )
where fs is the ECG sampling frequency and n is the chosen level

( wavelet_level_highpass ). In this example, the high-pass lter has a cuto frequency of

0.24 Hz which corresponds to level 10 at a sampling frequency of 500 Hz. In general try to

avoid choosing a level that results in high-pass ltering cuto > 0.5 Hz as the QRST

complex tends to include frequencies between 0.5-40 Hz [3]. Filtering can be visualized with

a gure generated with the Filtering button (GUI item 1.15) as shown in Figure 46.

5. Checkbox to enable/disable physiological baseline correction. This part of ECG/VCG

processing adjusts the baseline after ltering to remove any residual osets so the TP

segment (or the TQ segment in atrial brillation) of the ECG signal approximates 0 mV as

this segment of the ECG is truly isoelectric. The V Baseline Correction checkbox sets

baseline_correct_flag = 1 (checked) or baseline_correct_flag = 0 (unchecked) in

Annoparams.m . Setting the 0 mV reference correctly is critical for accurately calculating

areas under median QRST complexes. Further details about baseline correction can be

found in Chapter 15.2, Figure 23, Figure 24, and Figure 25.

6. Textbox to set maxBPM in Annoparams.m for QRS peak detection. See Chapter 15.1 and
Figure 22 for additional details of how this parameter controls QRS peak detection.

7. Textbox to set pkthresh in Annoparams.m for QRS peak detection. See Chapter 15.1
and Figure 22 for additional details of how this parameter controls QRS peak detection.

82
8. Adjust parameters for automatic pacemaker spike/artifact removal. The V On checkbox

enables/disables pacemaker spike removal by setting spike_removal = 1 (checked) or

spike_removal = 0 (unchecked) in Annoparams.m . The `Peak %' textbox sets the value of

pacer_thresh in Annoparams.m which sets the percentage of the pacing spike maximum

amplitude used to estimate pacing spike width. The `Pk Width' textbox sets the value of

pacer_spike_width in ms in Annoparams.m . See Chapter 6.2 and ECG Example 5


Chapter 5.4) for further details.
(

9. The Load button opens a dialog box so the user can choose an ECG le to process. If

the V Load Dir checkbox (GUI item 1.11) is checked, the load process also loads a list of
all les in the same directory with the same extension as the loaded le so the user can

quickly cycle through multiple les in a directory using GUI item 1.12 (see below).

10. Textbox which shows the full path of the ECG le which has been loaded. This can be

manually edited; to load the le after manually editing the le path click the

Reload button (See GUI item 1.13) below.

11. The V Load Dir checkbox loads an alphabetized list of all les of the same format within

the directory the chosen le is loaded from to allow use of the ← and → buttons (GUI

item 1.12) to easily cycle through les within a directory. If 2 Load Dir if unchecked, only

a single le is loaded and the ← and → buttons have no eect. Checking V Load Dir
without subsequently loading an ECG using the Load button (GUI item 1.9) has no
eect as the list of les is loaded when the callback triggered by Load is activated. If

there are a very large number of ECG les in the directory, disabling 2 Load Dir may

signicantly speed up loading an individual ECG.

12. The ← and → buttons cycle through all of the les with the same extension as the le

chosen with the Load button if V Load Dir is also checked as noted in GUI item 1.11
above. Files are sorted alphabetically.

13. After the ECG has been initially loaded using the Load button, the Reload button will

reload the current ECG from scratch without having to select the le again. The

Reload button is also used after manually editing the le path textbox (GUI item 1.10
above) to load the le in the path textbox. The Reload button does NOT reset the GUI

parameters to the default values in Annoparams.m ; this function is performed by the

Reset button (GUI item 3.7).

83
14. The Osets button displays a gure that shows the baseline osets in all leads and how

ltering and baseline correction have performed physiological re-zeroing of the ECG signal

voltage. See Figure 25 for additional information.

15. The Filtering button displays a gure that shows the eect of the selected ltering on the

ECG signal. See Figure 46 for additional information.

16. The Threshold button displays a gure that shows how the parameters pkthresh and

maxBPM are working to identify R peaks in the VM lead as part of rst pass VCG ducial

point processing. Further details are available in Chapter 15.1 and Figure 22.

17. Summary of ECG signal data that was loaded, including the sampling frequency, number

of ms between samples, and signal duration in seconds and samples.

18. Settings for running BRAVEHEART_batch() . The Batch button brings up a dialog box

that allows the user to choose a folder of ECGs for batch processing. Checkboxes control

output of batch processing. Further details of batch processing via the GUI can be found

in Chapter 14.

84
12.3 GUI Section 2  VCG Display
Section 2:
Display the X, Y, Z, and VM leads for the loaded 12-lead ECG after processing based on

parameters set in GUI Section 1.

Figure 4: GUI Section 2

1. Display of the ltered and baseline corrected VCG (X, Y, and Z leads) and VM leads.

Detected QRS peaks are shown with a magenta * with the exact location based on the VM
lead R wave peak. After rst pass annotation is complete (user clicked Calculate  GUI

item 3.6), dashed black lines show the locations of Qon , Qoff , and Toff (see Figure 5
below). When a beat is selected in the `Selected Beat Viewer' (GUI item 8.2), the

magenta * is changed to a green * as shown in Figure 5 below where the rst beat has

been selected:

85
Figure 5: A: The * corresponds to each detected R peak in the VM lead. After rst pass annotation, dashed
vertical lines mark the Qon , Qoff , and Toff for each beat. B: When a beat is selected in the `Annotated Beats'
8.1), the selected beat (dashed rectangle)
section (GUI item is highlighted with a green * and displayed in the
`Selected Beat Viewer' in GUI item 8.2 (inset panel).

Beats that are identied as `PVCs' or other non-dominant QRST morphologies (see

Chapter 15.3) will be marked with a triangle around the * (△ * ), and beats that are
identied as `outliers' will be marked with a circle around the * (#* ). These symbols
correspond to the `#' and `**' symbols in the `Annotated Beats' section of Section 8 (GUI

item 8.1). Note that a beat can be labeled as both a PVC and an outler, in which case

it is labeled with both a triangle and circle in the `X-, Y-, Z-, Vector Magnitude

Leads' section, and with both a `#' and `**' in the `Annotate Beats' list. See Chapter
15.3 and Chapter 15.4 for further information.

2. the Export button exports the VCG signal data (X, Y, Z, and VM leads) as .mat and .csv
les. The exported les will appear in the same directory as the ECG le with the naming

convention <filename>_xyz_beats.mat and <filename>_xyz_beats.csv . The .mat le

contains a structure xyz_beats that contains a n×4 matrix with columns corresponding

to the X, Y, Z, and VM leads in that order, and each row corresponding to a sample. The

.csv le contains 4 columns corresponding to the X, Y, Z, and VM leads in that order. In

both le formats, exported signals are in units of mV.

86
12.4 GUI Section 3  Fiducial Point Annotation and Median Beat
Creation/Annotation
Section 3:
Choose options for rst pass ducial point annotation and median beat creation and annotation.

Figure 6: GUI Section 3

1. Select and set options for using automatic QRS width estimation during rst pass heuristic

annotation. V Auto Width sets the value of autoMF = 1 (checked) or autoMF = 0


(unchecked) in Annoparams.m . The textbox `% Rpeak' sets the value of autoMF_thresh in

Annoparams.m . If autoMF = 1 the rst pass annotation algorithm dynamically estimates

the QRS search window for each beat individually rather than using a xed window as

specied by QRwidth and RSwidth 3.2 below). Further details of annotation


(see GUI item

parameters can be found in Chapter 6.2, Chapter 18, and Figure 30.

2. Textboxes to set the value of QRwidth , RSwidth , STstart , and STend in Annoparams.m .
Note that QRwidth and RSwidth can only be changed if 2 Auto Width (GUI item 3.1) is
unchecked, as otherwise the QRwidth and RSwidth are dynamically set for each beat

individually based on QRS width estimation, which is usually the best option. For further

details on these parameters and their relation to ducial point annotation, see Chapter
6.2, Chapter 18, and Figure 30.

3. Dropdown to select the method of rst pass T wave end (Toff ) annotation by setting

Tendstr in Annoparams.m . The nominal value of `Energy' should be used in most cases as

this method is more robust to abnormal T wave morphologies than are the other options of

`Tangent' (which uses the tangent method) and `Baseline' (which nds the baseline

crossing). Further details can be found in Chapter 6.2, Chapter 18, and Figure 30.

4. Dropdown to select the method of beat alignment for median beat construction by setting

align_flag in Annoparams.m . `CoV' uses the ltered center of voltage of the QRS complex

87
to align beats, while `Rpeak' uses the location of the R wave peak voltage to align beats.

See Chapter 6.2 for additional details.

5. Dropdown to select preset values for pkthresh , maxBPM , QRwidth , RSwidth , STstart , and

STend . This can be useful when you have certain types of ECGs (such as ECGs with very

long QT intervals or frequent PVCs) and you want to quickly adjust the annotation

settings and save them for future use. The dropdown pulls values from the external le

search_presets.csv . Further details can be found in Chapter 21.

6. The Calculate button begins processing of the ECG/VCG after it has been loaded and

ltered. Press this once all ltering and annotation parameters are set appropriately.

7. The Reset button resets all GUI parameters to their nominal values which are pulled from

Annoparams.m .

8. The Import button overrides the set GUI/annotation parameters and pulls annotation

parameters and ducial point annotations from an external .anno le. Further details can

be found in quick start Example 5 ( Chapter 5.5) and Chapter 17.

9. Checkbox to enable/disable debug gures for both rst pass and median beat annotation.

The V Debug checkbox sets debug = 1 (checked) or debug = 0 (unchecked) in

Annoparams.m . Further details on using debugging can be found in Chapter 28.7, Figure
30, and Figure 49.

10. Checkbox to easily enable/disable automatic outlier and automatic PVC removal using a

single click. When V All Auto is checked, the V Auto checkboxes for both outlier removal

(GUI item 9.4), and PVC removal (GUI item 9.10) are also checked, and
pvc_removal = 1 and outlier_removal = 1 in Annoparams.m , thus enabling automatic

outlier and PVC removal during ECG/VCG processing. When 2 All Auto is unchecked,

the 2 Auto checkboxes for outlier removal and PVC removal both get unchecked,

disabling both automatic outlier removal and automatic PVC removal ( pvc_removal = 0
and outlier_removal = 0 in Annoparams.m ).

11. Summary of rst pass annotation statistics. The median (`Med'), minimum (`Min'),

maximum (`Max'), and interquartile range (`IQR') are displayed. This is one way of

quickly assessing the quality and consistency of rst pass annotation.

88
12. Dropdown to set baseline_flag in Annoparams.m . In general, this should not be changed

from the nominal value of `Zero Baseline' if ECGs are ltered and baseline corrected

appropriately. Further details can be found in Chapter 6.2.

13. Dropdown to set origin_flag in Annoparams.m . In general, this should not be changed

from the nominal value of `Zero Baseline' if ECGs are ltered and baseline corrected

appropriately. Further details can be found in Further details can be found in Chapter
6.2.

14. This section is used to export annotation (extension .anno ) les. The Export button

generates an .anno le that contains the annotation parameters used to process the le. If

the V Include Beats checkbox is checked, the .anno le also contains information on the

beats used to construct the median beat. See quick start Example 5 ( Chapter 5.5) and
Chapter 17 for additional information.

15. Sets the method of annotating the median beat using either the standard heuristic

annotator `Std' or the custom BRAVEHEART neural network (NN) median beat

annotater `NNet'. In almost all cases the nominal value of `NNet' should be used as it is

the most accurate way to annotate median beats. In rare cases where the NN fails to

accurately annotate a median beat, switching to `Std' may work, although usually ECGs

that fail NN annotation are ECGs with signicant noise and artifact that are dicult to

annotate regardless of method. Details of neural network development and annotation

performance are available in the methods manuscript [1] and Chapter 19.

16. The Parameter Info button opens a le which contains information on annotation parameters

and heuristic rst pass annotation.

89
12.5 GUI Section 4  Median Beat Display and Quality Assessment
Section 4:
Visualize median X, Y, Z, and VM beats, the individual beats that make up the median beat,

and information about the quality of ECG processing, median beat construction, and median

beat annotation.

Figure 7: GUI Section 4

1. Display of the X, Y, Z, and VM median beats. The actual median beats are shown in blue

for leads X, Y, and Z, and in red for lead VM. For leads X, Y, and Z, the individual beats

that were aligned to construct the X, Y, and Z median beats are shown with black dotted

lines. There are no individual beats shown for the VM median beat because the median

VM beat (VMmed ) is created only with the median X, Y, and Z beats as

* corresponds the location of the


p
VMmed = Xmed 2 + Ymed 2 + Zmed 2 . The location of the

maximum T wave amplitude in the VM lead. When a beat is selected in the `Annotated

Beat Viewer' (GUI item 8.1), the selected beat is highlighted in green:

90
Figure 8: A: When a beat is not selected the individual beats that make up each of the X, Y, and Z median beats
are shown in black dashed lines. B: When a beat is selected in the `Annotated Beats' section (GUI item 8.1),
the selected beat in the X, Y, and Z leads is highlighted in green.

2. Mean normalized cross correlation (NCC/`X-Corr') for the X, Y, and Z beats, respectively.

Values close to 1.0 indicate that all beats in that lead which were used to construct the

median beat were very similar in morphology and alignment, while low values suggest that

there are multiple beat morphologies that dier signicantly from each other and/or poor

beat alignment which might impact the quality of median beat construction and

subsequent calculations. This is used primarily as a quality control, and the lowest of the

normalized cross correlation values for the X, Y, and Z leads is used as part of the quality

assessment after ECG processing (see Chapter 16).

3. The X Stats , Y Stats , and Z Stats buttons display information on the individual beats

used to create the median beat in the X, Y, and Z leads, respectively. This information can

be useful to assess for outlier beats or beats that are causing issues with median beat

construction. An example of the gure produced when clicking these buttons is shown in

Figure 44.

4. The Quality button opens a gure that shows various quality metrics for the processed

ECG. Further information can be found in Chapter 16 and Figure 29.

5. Measures of ECG processing/annotation quality (see Chapter 16). The `Prob (%)' value

is a predicted probability between 0 and 1 (expressed as a percentage) that is the output of

a logistic regression which takes various morphologic features of the processed median beat

as input and outputs the probability of the processed median beat being good quality.

91
Values above a set cuto in quality_presets.csv are shown with a green background,
while values below this cuto are shown in red background. If the value is `NaN' this

signies a signicant issue with annotation that should be investigated (or an ECG has not

been processed). See Chapter 16 for further details.

The `Counts' value reports the number of quality parameters that are outside of the bounds

set in quality_presets.csv . green, while values > 0 are shown


Values of 0 are shown in

in red. The gure opened by clicking on the Quality button (see Figure 29), displays the

individual quality parameters that are used for this metric. See Chapter 16 for details.

6. The Export button exports the 16 median beats and median beat annotations as .mat
and .csv les. The exported les will appear in the same directory as the ECG le with

the naming convention <filename>_xyz_medians.mat and <filename>_xyz_medians.csv .


The .mat le contains a structure medians that contains elds corresponding to all 16

leads (12 leads, X, Y, Z, and VM) (eg medians.V1 loads the lead V1 median beat). The

.csv le contains 16 columns corresponding to the 16 leads in the order I, II, III, avR,

avF, avL, V1, V2, V3, V4, V5, V6, X, Y, Z, and VM. In both le formats, exported signals

are in units of mV. In the .mat le, the median beat annotations are saved as median.Q
(Qon ), median.S (Qoff ), and median.Tend (Toff ) in samples. Median beat annotations are

not saved to the .csv le.

12.6 GUI Section 5  Select Displayed Information


Section 5:
Select what information is shown in the GUI information display (GUI Section 6).

Figure 9: GUI section 5.

1. The Vectorcardiogram button displays the 3D VCG. See GUI Section 6.1 in Chapter
12.7 for further details.

2. The VCG Calculations button displays a set of measurements obtained from the median

ECG/VCG, and the majority of results contained in VCG_Calc results class. See GUI

Section 6.2 in Chapter 12.7 and Chapter 24 for further details.

92
3. The Lead Morphology button displays a pop-out window with all 16 median beats, ducial

points, and the measurements of the R, S, and T waves. The QRS axis is also displayed.

This displays the majority of results contained in the Lead_Morphology results class. See

GUI Section 6.3 in Chapter 12.7 and Chapter 24 for further details.

4. The VCG Morphology button displays information on the morphology of the QRS and T

loops, including coplanarity, total cosine R-to-T (TCRT), roundness, area, and perimeter,

including the majority of results contained in the VCG_Morphology results class. See GUI

Section 6.4 in Chapter 12.7 and Chapter 24 for further details.

5. The VCG Speed button displays measurements of median VCG speed and allows

graphical display of median VCG speed and acceleration. See GUI section 6.5 in Chapter
12.7 for further details.

6. The Utilities button brings up a set of ECG/VCG utilities and allows additional

control over GUI function and output. See GUI Section 6.6 in Chapter 12.7 further
details.

93
12.7 GUI Section 6  GUI Information Display
Section 6.1:
The Vectorcardiogram button displays the median beat VCG with various visualization options.

The gure can be rotated in 3D.

Figure 10: GUI Section 6.1

1. The median beat VCG is shown in the ` Vectorcardiogram' section of the GUI. The QRS
loop is shown in blue and the T wave loop is shown in red. `Visualization Options' (GUI

item 6.1.2) contains options for visualizing the VCG. When new options are
checked/unchecked, clicking Refresh (GUI item 6.1.7) will update the VCG graph without

recalculating values. The VCG can be rotated with the mouse by using the rotation tool

(GUI item 10.2) or the `Orbit Camera' in GUI item 6.1.4.

94
2. VCG Visualization Options:

ˆ V Propogation : When checked this option shows a set of green circles at the start of

the QRS loop and a set of yellow circles at the start of the T wave loop. This can be

useful to visually determine the direction of rotation around each VCG loop.

ˆ V Speed : When checked, this option shows the instantaneous speed (mV/ms) of the

VCG loop. The loop coloring changes to reect the relative speed according to the

color key that is displayed. Faster sections of the loops are shown in red, and slower

sections of the loops are shown in blue (see GUI section 6.5 in Chapter 12.7).
ˆ V Vectors : When checked, this option shows the peak and area QRS (blue), T wave

(red), and QRST/SVG (green) vectors. Peak vectors are shown as solid lines, while

area vectors are shown as dashed lines.

ˆ V Axes at Origin : When checked, this option moves axes labeling inside the 3D gure

as opposed to being on the outside of the gure.

ˆ V Square Axes : When checked, this option makes the X, Y, and Z axes all have the

same scaling. If this is not checked the loop morphology may be distorted, but it may

be easier to visualize some parts of the VCG loops.

ˆ V Legend : Turns on or o the gure legend on the right hand side of the gure.

ˆ Full VCG : Clicking this button shows the plot of the full VCG throughout the entire

VCG tracing, not just the median beat (see Figure 45).
ˆ Pop Out : Clicking this button allows visualization/manipulation of the VCG in a

new, larger window.

3. The Animate button opens an animated gure of the VCG loop. The animation steps are in

samples set by the `Step' textbox.

4. The Orbit Camera opens a second toolbar that can be used to manipulate the camera for the

3D VCG. See https://www.mathworks.com/help/matlab/creating_plots/


view-control-with-the-camera-toolbar.html for additional details.

5. This section is used to rotate the 3D VCG without using the rotation tool (GUI item

10.2). All movements are relative to the user.

ˆ ← Rotates the VCG towards the left of the user.


ˆ → Rotates the VCG towards the right of the user.

ˆ ↶ Rotates the VCG counterclockwise relative to the user.

ˆ ↷ Rotates the VCG clockwise relative to the user.

ˆ ↑ Rotates the VCG cranial relative to the user.

ˆ ↓ Rotates the VCG caudal relative to the user.

95
6. This section is used to rotate the 3D VCG to common viewing angles.

ˆ Frontal Displays the VCG in the XY plane.

ˆ Transverse Displays the VCG in the XZ plane.

ˆ L Sagital Displays the VCG in the YZ plane.

ˆ View/Hide Body Orientation Shows a head/face to orient the VCG loops in 3D space. The

rotation of the VCG and this face are linked, so rotating one will also rotate the other

by the same amount and to the same viewing angle.

7. The Refresh button reloads the VCG with the active VCG visualization options set in GUI

item 6.1.1 above.

8. The Save button saves the current VCG as a .png image.

Section 6.2:
The VCG Calculations button displays results from the VCG_Calc results class and sets options

for data export.

Figure 11: GUI Section 6.2

96
1. Displays values of various ECG/VCG calculations from the VCG_Calc.m results class based

on the median beat. If V Show Normal Ranges is checked in the Utilities section (GUI

item 6.6.6) then for select values, if they are out of range, to the right of the value there
will be an arrow reecting if the value is above (↑) or below (↓) the normal range (see

Figure 40 and Chapter 22). Denitions for azimuth and elevation can be found in

Figure 50.

2. Textbox that shows the working directory for saving les. All saved les are stored in the

directory displayed here. When an ECG is loaded, the working directory for saving data is

set to the directory which contains the ECG le that was loaded. To change the working

directory, click on the Select button and choose a new directory.

3. Textbox that species the name of the le used to export calculations/data from the

current ECG/VCG. The dropdown allows the user to choose .csv or .xlsx format.

4. The Export Data button exports all of the current data from the active ECG/VCG

(including all calculations from all 3 results classes, Annoparameters, and beat

annotations), to a text le with the le name and extension as specied in GUI item 6.2.3.
The button text changes to reect the value in the le extension dropdown box ( .csv or

.xlsx ).

If a le with the same name/location as specied in the saving directory (GUI item 6.2.2)
and lename (GUI item 6.2.3) does not exist, a new le is created. If a le with the same

name/location as specied already exists, the current data is appended to the next empty

row in the existing le. In this way the user can create a singular le with the results from

multiple ECGs, or results from the same ECG with dierent processing

parameters/included beats.

When the export is successful, Success! appears to the right of the buttons.

5. The Export Signals (.mat) button exports the signal data (ECG/VCG signals, median beat

signals, individual beats, and results) in a .mat format le which contains a data structure

with all of the exported data that can be analyzed outside of BRAVEHEART.

97
Section 6.3:
The Lead Morphology button opens a gure which contains the median beat R, S, and T wave

measurements (all units in mV) for all 16 leads. The information displayed here is from the

Lead_Morphology.m results class. The QRS frontal axis is also displayed.

Figure 12: Figure displayed when the Lead Morphology button is pressed. The gure displays the R, S, and T wave
measurements for all 16 leads. All values are in units of mV.

98
Section 6.4:
The VCG Morphology button displays information on VCG loop morphology and associated

parameters. The information displayed here is contained in the VCG_Morphology.m results class.

Figure 13: GUI Section 6.4

1. Displays values of various VCG morphology calculations such as coplanarity (how planar

the QRS and T loops are), Total Cosine R-T, and QRS and T wave loop roundness and

area which are part of the VCG_Morphology results class. All variables calculated in the

VCG_Morphology results class are not displayed here. Further details can be found in the

methods manuscript [1] and in Chapter 24.

2. The View QRS Loop button shows the best t plane for the QRS loop and projections of

the loop into the best t plane. Vectors that span the best t plane can be displayed as

noted in GUI item 6.4.4. The gure can be rotated.

3. The View T Loop button shows the best t plane for the T loop and projections of the

loop into the best t plane. Vectors that span the best t plane can be displayed as noted

in GUI item 6.4.4. The gure can be rotated.

99
4. These checkboxes control the appearance of the displayed QRS or T loop gure:
ˆ V Legend : shows the gure legend
ˆ V Square Axes : makes the X, Y, and Z axes have equal spacing.
ˆ V Show Basis : shows the orthogonal basis vectors for the best t plane

Section 6.5:
The VCG Speed button displays information on VCG loop speed.

Figure 14: GUI Section 6.5

1. Textbox to set the value of blanking_samples in Annoparams.m . This corresponds to the

length of the gray shading after QRS start (black vertical dashed line) in the gure above

(GUI item 6.5.6). Any part of the QRST signal within the gray shading is ignored when

calculating maximum speed. This can be useful to isolate specic parts of the QRST

complex, or to deal with large/wide pacing artifact that contaminates the QRS complex.

See Chapter 6.2 for additional details.

2. The Refresh 6.5.3 (see below) based on the


button updates the speed values in GUI item

value set in the `Speed Blanking Time' textbox (GUI item 6.5.1 which sets the value of

100
blanking_samples in Annoparams.m ). Use the Refresh button to recalculate values of

speed using new values of blanking_samples without having to reprocess the entire ECG.

3. Values for speed calculations of the entire QRST complex, QRS complex alone, and T

wave alone.

4. The Graph button displays the gure in GUI item 6.5.6 based on the value of
blanking_samples set in GUI item 6.5.1 and the value of the V dV/dt checkbox set in

GUI item 6.5.5.

5. The V dV/dt checkbox sets if acceleration is also shown in the speed gure (GUI item

6.5.6).

6. Figure showing speed (and acceleration if V dV/dt is checked). The blanking period, which

is assigned by GUI item 6.1.1 above is shown as gray shading after QRS onset (dashed
vertical black line). The ducial points for Qon , Qoff , and Toff are shown with colored,

dashed lines. The locations of the fastest segment of the QRS complex and T wave are

noted with shaded circles as shown in the legend.

7. The Popout button opens the speed gure displayed in GUI item 6.5.6 in a new window.

8. The 2 Save checkbox saves the speed gure shown in GUI item 6.5.6 as a .png le
named <filename>_speed.png when the Graph button (GUI item 6.5.4) is clicked.

101
Section 6.6:
The Utilities button brings up BRAVEHEART utilities and options which can be used to

control ECG processing and utilize other useful functions and links.

Figure 15: GUI Section 6.6

1. If needed, BRAVEHEART can convert vectors dened by magnitude, azimuth, and

elevation (see Figure 50) into Cartesian coordinates. If 2 vectors are entered, the 3D

angle between them can also be calculated by clicking the Calculate Angle button.

2. By default, BRAVEHEART calculates parameters in all 3 result classes (see Chapter 24).
In certain cases the user may only care about some of the results classes. The 3 checkboxes

here allow the user to enable/disable processing of specic results classes to speed up batch

processing of large volumes of ECGs if the data contained in one or more specic results

classes is not needed:

ˆ V Calculate Standard Vectors enables/disables the VCG_Calc results.


ˆ V Calculate 12-Lead ECG Morphology enables/disables the Lead_Morphology results.

ˆ V Calculate VCG Morphology enables/disables the VCG_Morphology results.

These checkboxes set the values of vcg_calc_flag , lead_morph_flag , and

vcg_morph_flag (see Chapter 13).

3. The 2 Error Logging checkbox enables error logging to assist with troubleshooting ECGs

that will not process correctly. Further details can be found in Chapter 28.

102
4. BRAVEHEART includes data on estimated normal limts for a selection of VCG parameters

based on age, gender, body mass index (BMI), and race (see Chapter 22). This section of

textboxes and checkboxes allows the user to specify the age, gender, BMI, and race (white

or not white) to generate expected normal limits for these select parameters.

ECG les (usually .xml ) that contain information on patient age and gender can have this

information automatically pulled from the ECG le and extracted to this location of the

GUI. If information on age and gender are not available, the default is to use a 50 year old

man. To obtain the most accurate normal ranges for the ECG being processed, the BMI

and race (white or not white) can be entered here as well. The software defaults to white
2
race with BMI = 30 m/kg if values are not specied by the user. BRAVEHEART is

currently able to extract age and gender from GE MUSE .xml and Philips .xml les (see

Chapter 23).

If the V Highlight select of of range values (GUI item 6.6.8 below) is checked, values
outside of the normal ranges determined by the demographics entered in this section are

noted on the GUI results displayed in the ` VCG Calculations' section of the GUI (GUI
item 6.2.1) with ↑ or ↓ reecting if the value is above or below the normal range,
respectively. Further details of displaying values outside of the normal range can be found

in the documentation for GUI item 6.6.8 and Chapter 22.

5. This section is used to open various utility programs that may be useful to the user:

In certain situations the user may want to split an ECG le into 2 separate les to remove

an area of signicant noise/artifact, or to isolate a specic nding. Clicking on

ECG Splitter allows the user to split the current le into 2 separate les by specifying a

sample at which to split the ECG. In a future release we plan to allow the user to maintain

the current le format when splitting ECGs, but in the current version of BRAVEHEART

all split ECGs are in the 'unformatted' format which encodes the 12 leads as 12 columns

in units of mV (see Chapter 23).

The current ECG can be converted into a dierent format using the Convert ECG
button. This function is currently only able to convert into 'unformatted' ECGs,

although additional formats will be added in the future.

The Sensitivity button performs sensitivity analysis on the current ECG to determine how

much changes in ducial point annotations aect the reported measurements. The textbox

next to the Sensitivity button is used to specify an interval in ms by which the Qon , Qoff ,

103
and Toff ducial points are adjusted, and all results recalculated. For example, if the

textbox is set to the nominal value of `20' ms, clicking the Sensitivity button will calculate

results with all ranges of Qon from Qon - 20 ms to Qon + 20 ms, and similarly for Qoff ±20
ms and Toff ±20 ms. Results are saved to the working directory with the lename

<filename>_sensitivity_analysis.csv .

6. This section can be used to display and obtain various useful information:

ˆ The Check Updates button opens the BRAVEHEART GitHub website,

http://www.github.com/BRAVEHEART, so the user can check for any software updates.

ˆ The Equations button displays various equations used for calculations.

ˆ The User Manual button displays this document.

ˆ The Angle Info button displays a gure explaining the conventions used for angles

in BRAVEHEART calculations (see Figure 50).


ˆ The Variables button displays the variable names and descriptions for output les.

7. Occasionally ECGs will throw errors when they are being loaded into BRAVEHEART.

When checked, the 2 Safe Mode checkbox disables rst pass ECG processing and

annotation after initial ltering is complete. This can help trouble shoot ECGs that throw

errors. The ECGs can be viewed by clicking on the 12L ECG and other buttons in the

`View/Save ECG' section (GUI section 7). Further details of Safe Mode can be found in

Chapter 28.

8. The V Highlight select out of range values checkbox displays marks next to select

measurements that are out of range in the ` VCG Calculations' section (GUI item 6.2.1).
Values that are above the normal range are displayed with an ↑, and values that are below

the normal range and displayed with a ↓. If 2 Highlight select out of range values is not

checked, the arrows to visualize out of range values are not displayed. Further details of

which parameters have normal ranges calculated are available in Chapter 22.

104
12.8 GUI Section 7  Display Various Figures
Section 7:
View/Save ECGs, VCGs, and other gures.

Figure 16: GUI Section 7

This section of the GUI is used to display and save various ECG/VCG gures and visualizations.

1. Generate various gures of ECGs, VCGs, and other visualizations:

ˆ The 12L ECG button displays the 12-lead ECG as 12 continuous rhythm strips. The

12-lead ECG can be displayed after the ECG is loaded and before the

Calculate button has been pressed. An example 12-lead ECG gure is shown in

Figure 37.
ˆ The X, Y, Z VCG button displays continuous rhythm strips of the X, Y, Z, and VM

leads. The VCG ECG can be displayed after the ECG is loaded and before the

Calculate button has been pressed. An example VCG gure is shown in Figure 38.
ˆ The Med. Beats button displays all 16 median beats. This only works if the

Calculate button has been pressed and the median ECG has been processed. An

example median beats gure is shown in Figure 39.


ˆ The Summary button displays measurements of the summary gure (See Figure 35
and Figure 36). This only works if the Calculate button has been pressed and the

median ECG has been processed.

ˆ The Polar SVG button brings up a plot that shows orientation of the spatial

ventricular gradient (SVG) and QRST angles. This only works if the

Calculate button has been pressed and the median ECG has been processed.

ˆ The Normal Vals. button brings up a gure that shows age, gender, race, and body

mass index specic values for various VCG parameters. An example gure is shown in

Figure 40. See Chapter 22 for further details.


ˆ The VCG Loops button brings up a gure that shows the median X, Y, and Z beats

and the corresponding VCG loops. This only works if the Calculate button has been

pressed/median ECG has been processed. An example gure is shown in Figure 41.

105
2. Dropdown to choose what gridlines are displayed when using 12L ECG , X, Y, Z VCG , or

Med. Beats . `All Grid' enables major and minor grids (large and small boxes), `Maj Grid'

enables only the major grid (large boxes), `Min Grid' enables only the minor grid lines

(small boxes), and `No Grid' disables the grid completely.

3. When checked, the V Save checkbox saves the gures generated by any of the buttons in

this section. Files are saved to the same directory that the ECG le is in and are saved in

.png format.

106
12.9 GUI Section 8  Beat Editing, Addition, and Removal
Section 8:
Edit the ducial point annotations of individual beats, remove unwanted beats, or manually add

new beats. After editing, adding, removing beats, a new median beat is created and calculations

are performed on the new median beat.

Figure 17: GUI Section 8.

1. The ` Annotated Beats' window lists the annotations for all individual beats that are
included in the median beat. The order of anotations is shown at the top of the box as

Qon , R peak, Qoff , and Toff (in samples). Beats that are detected as PVCs/non-dominant

beats will have a ` #' next to their annotations. Beats that are detected as outliers will

have a ` **' next to their annotations. Some beats may be detected as both a a PVC and

Annotated Beats'
an outlier, and will have both symbols. Clicking on a beat in the `

window displays the beat and ducial points in the `Selected Beat Viewer' (GUI item

7.2 below), highlights it in green in the Median Beat Viewer (GUI item 4.1) and

107
highlights the individual beat with a green * in the `X-, Y-, Z-, Vector Magnitude
Leads' section (GUI item 2.1).

2. Selected Beat Viewer' shows a zoomed in view of the beat that is selected in the
The `

`Annotated Beats' window along with its annotations visualized as a black dashed line

(Qon ), green dashed line (R peak) , blue dashed line (Qoff ) , and red dashed line (Toff ).

These lines can be dragged to adjust the respective ducial point locations. The sample

values that correspond to the location of the 4 colored dashed lines are reected in the

`Beat Selection' textbox below the `Selected Beat Viewer' (GUI item 7.3). As the
lines are moved, the values in the `Beat Selection' textbox will reect the new location of

the ducial points (see Chapter 5.6).

3. The ` Beat Selection' textbox updates with the selected beat's ducial points in the order
of Qon , R Peak, Qoff , and Toff as they are adjusted. The ducial points can be edited by

dragging the colored dashed lines that correspond with Qon , R peak, Qoff , and Toff as noted

above, manually by updating their values in the textbox, or by shifting values by ±1


sample using the + and  buttons corresponding to Qon , Rpeak , Qoff , or Toff in GUI

section 7.4. See Chapter 5.6 for additional information.

Once the adjusted ducial points are in the ` Beat Selection' textbox, clicking the
Update Beat button (GUI item 7.5) or Remove Beat button (GUI item 7.8) will
update the ducial points or remove the beat entirely, respectively.

4. The `Shift by 1 Sample' section shifts one of the 4 ducial points by ±1 sample. For

example, to shift Qon by +1 sample, click on the + button below Qon, and to shift
Toff by -1 sample, click on the  button below To .

5. The Update Beat button takes the 4 values in the ` Beat Selection' textbox
corresponding to Qon , R peak, Qoff , and Toff (in that order), saves these new values for the

selected beat, and then recalculates the median beat and associated measurements using

the updated beat ducial points.

6. The Prev and Next buttons can be used to cycle through beats in the ` Annotated Beats'
listbox without clicking on them.

7. The Remove Beat button removes the selected beat from the analysis and then

recalculates the median beat and associated measurements. See the quick start guide

( Chapter 5.7) for an example.

108
8. The Add Beat button takes the values in the ` Beat Selection' textbox, creates as new
beat using these ducial points, and then recalculates the median beat and associated

measurements. In general, there are few uses for this function, as beats should be

automatically detected, but in rare cases where a beat needs to be added manually, it can

be done this way.

9. The ` Shift Fiducial Points' textbox allows manual shifting of a ducial point for all
individual beats simultaneously, or manual shifting of the median beat ducial points. This

section can be used for manual adjustment of median beat annotations when necessary:

If V Median is checked, placing an integer n in the textbox and clicking on one of the

buttons below ( Qon , Rpk , Qo , or To ), will shift the relevant median beat dicual point

by n samples. This is useful if manual adjustments on median beat annotations are needed.

After annotation adjustment calculations are updated using the new median beat ducial

points. See Chapter 5.11 for an example of median beat annotation adjustment.

If 2 Median is unchecked, placing an integer n in the textbox and clicking on one of the

buttons below ( Qon , Rpk , Qo , or To ), will shift the relevant ducial point of ALL

individual beats by n samples. In practice, this is useful if the median beat is being

truncated before the end of the T wave which is preventing annotation of the median beat

Toff ; shifting Toff (click To ) by n samples in all individual beats has the eect of

extending the window for median beat creation by n samples. The window before Qon can

be similarly extended by using a negative value and clicking Qon .

109
12.10 GUI Section 9  PVC/Non-Dominant and Outlier Beat Removal
Section 9:
Analyze and remove PVCs/non-dominant beats and outlier beats. Detailed descriptions of PVC

and outer identication/removal can be found in Chapter 15.3 and Chapter 15.4.

Figure 18: GUI Section 9

1. The Remove Outliers button removes all beats that have been agged as outliers and then

recalculates the median beat and associated measurements. Further details can be see in

quick start Example 3 ( Chapter 5.3), Chapter 5.10, and Chapter 15.4.

2. The Outlier Data button displays information on each beat and the values that are used for

outlier determination. Further details can be found in Chapter 15.4 and Figure 27.

3. The `Cuto ' textbox sets the value of modz_cutoff in Annoparams.m which determines the

modied Z-score cuto that is used to determine if a beat is an outlier. See Chapter 15.4
for further details.

4. V Auto sets if outliers are automatically removed when Calculate has been pressed. If

2 Auto is unchecked, outliers are marked but not removed.

5. The `X-Corr Thresh' textbox sets the value of pvcthresh in Annoparams.m . See Chapter
15.3 for further details.

6. The `RMSE Thresh' textbox sets the value of rmse_pvcthresh in Annoparams.m . See

Chapter 15.3 for further details.

7. Radio buttons that sets the value of keep_pvc in Annoparams.m . If `Remove Native' is

checked keep_pvc = 1 , and if `Remove PVCs' is checked keep_pvc = 0 . See Chapter


15.3 for further details.

110
8. The PVC Data button displays a gure that summarizes the data that is used for PVC

detection. Further details can be found in Chapter 15.3 and Figure 26.

9. the Remove PVCs button removes all beats that have been agged as PVCs and then

recalculates the median beat and associated measurements. Further details can be see in

quick start Example 2 ( Chapter 5.2), Chapter 5.9, and Chapter 15.3.

10. V Auto sets if PVCs are automatically removed when Calculate has been pressed. If

2 Auto is unchecked, PVCs are marked but not removed.

12.11 GUI Section 10  GUI Toolbar for Interacting with Figures


Section 10:
GUI Toolbar for interacting with gures. The GUI toolbar can be used to navigate within

various gures that are displayed in the GUI. Click on an icon in the toolbar and then use in the

selected GUI gure.

ˆ : Pan gure

ˆ : Rotate gure

ˆ : Select point in gure

ˆ : Zoom in on gure

ˆ : Zoom out of gure

ˆ : Print gure

111
13 Batch Processing ECGs with braveheart_batch.m

BRAVEHEART allows rapid batch processing of a directory of ECGs via braveheart_batch.m .


This can be called directly without using the GUI. In batch processing mode there is less

graphical output compared to the BRAVEHEART GUI, but when batch processing a large

number of ECGs, the batch processing mode of BRAVEHEART is more ecient than manually

processing multiple ECGs sequentially in the GUI.

Batch processing of ECGs can be launched from within the GUI (see Chapter 14) or via the
braveheart_batch() function directly from the MATLAB command line. The command line

mode is useful for large and complex datasets that may require running multiple batches with

dierent parameters. braveheart_batch.m output includes a single .csv or .xlsx le with

ECG/VCG measurements for all batched ECGs, and optional summary gures (See Figure 35
and Figure 36), .anno Chapter 17), and/or ECG/VCG signals and data
annotation les (see

in MATLAB .mat format (See Chapter 13.4).

13.1 Batch Processing Parameters


The parameters that govern how BRAVEHEART_batch.m functions can be adjusted at the

beginning of the le:

% Parameters controlling batch behavior -> Edit as needed

folder = ''; % ECG Folder; set as '' to use system dialog box
format = 'muse_xml'; % ECG format string
output_ext = '.csv'; % Output file extension; '.csv' or '.xlsx'
output_note = 'batch'; % Note added to output

parallel_proc = 0; % Use parallel processing; 1 = yes, 0 = no


progressbar = 1; % Display progress bar; 1 = yes, 0 = no

save_figures = 0; % Save figure of processing/annotation; 1 = yes, 0 = no


save_data = 0; % Save .mat file of signals/annotations; 1 = yes, 0 = no
save_annotations = 0; % Save beat annotation file (.anno); 1 = yes, 0 = no

vcg_calc_flag = 1; % Process VCG_Calc module; 1 = yes, 0 = no


lead_morph_flag = 1; % Process Lead_Morphology module; 1 = yes, 0 = no
vcg_morph_flag = 1; % Process VCG_Morphology module; 1 = yes, 0 = no

112
The parameters that can be set to control batch ECG processing include:

parameter possible values


|

parameter description
folder | string

Sets the path of the folder of ECGs to batch process. If this value is set empty as '' , the

program will bring up a dialog box to allow the user to choose the folder. This parameter is

only used when running the command line version of BRAVEHEART from the source code,

and is primarily designed for cases when passing in these parameters into the function as

shown in Chapter 13.2. All other ways of running batch processing (via compiled

command line version or via GUI) require the folder input to be via dialog box.

format | string

String which describes the ECG format to be used. See Chapter 23 for details of included
formats. Formats that are included by default include:

ˆ 'muse_xml' - GE MUSE .xml

ˆ 'bidmc_format' - Space delimited ASCII .txt (legacy BIDMC format)

ˆ 'prucka_format' - GE Prucka recording system ASCII .txt

ˆ 'ISHNE' - International Society for Holter & Noninvasive Electrocardiology .ecg

ˆ 'DICOM' - DICOM .dcm

ˆ 'hl7_xml' - HL7 .xml

ˆ 'philips_xml' - Philips .xml

ˆ 'mrq_ascii' - GE Marquee ASCII .mrq

ˆ 'unformatted' - Unformatted column data in units of mV .txt

output_ext | '.csv' or '.xlsx'

Sets the format of the output le that contains all measurements after batch processing is

complete. If set to '.csv' the program will generate a comma separated values le, and if

set to '.xlsx' it will generate a Microsoft Excel spreadsheet le. The information

contained in the output le is the same with either output format.

output_note | string

Sets a string that is included in the measurement output le. This can be used to indicate

something about the dataset that is being processed.

113
parallel_proc | 0 or 1

Sets if MATLAB's parallel computing toolbox is used to process ECGs in parallel. If

parallel_proc = 1 and the user does not have MATLAB's parallel computing toolbox

installed, the ECGs will process sequentially without throwing an error. When parallel

computing is used, the program uses the maximum number of workers that are available.

progressbar | 0 or 1

Sets if a progress bar pop-up is generated to show the progress of ECG processing.

save_figures | 0 or 1

Sets if output includes a summary gure for each processed ECG. If the number of ECGs to

process is large and if gures are not needed, setting save_figures = 0 can signicantly

reduce the time required for ECG processing. Examples of summary gures can be seen in

Figure 35 and Figure 36.

save_data | 0 or 1

Sets if output includes the raw and ltered signals (individual beats and median beats),

annotations, and calculated parameters saved as a .mat le. If this data is not needed,

setting save_data = 0 can speed up ECG processing.

save_annotations | 0 or 1

Sets if output includes annotation les for each processed ECG. Annotation les (extension

.anno ) contain the annotation parameters used to process the ECG (from Annoparams.m -

see Chapter 6) and individual beat ducial point annotations for each ECG. If an .anno
le is placed in the same directory as an ECG with the same name (eg ecg_name.xml and

ecg_name.anno ), the BRAVEHEART command line program overrides the nominal

annotation parameters and beat annotations, loading these from the .anno le instead.

.anno les therefore allow ne control over individual ECG processing via

braveheart_batch.m without needing to use the GUI. For further details on .anno les see

Chapter 17. .anno les behave slightly dierently when used with the GUI and more

information on use of .anno les and the GUI can be found in Chapter 17.

vcg_calc_flag | 0 or 1

Sets if data from the VCG Calculation results class VCG_Calc.m , which primarily includes

vectorcardiographic measurements, is included in the measurement output le. Further

details of the data included in the VCG Calculation results class can be found in Chapter
24.

114
lead_morph_flag | 0 or 1

Sets if data from the Lead Morphology results class Lead_Morphology.m , which primarily

includes data on R, S, and T wave measurements, is included in the measurement output

le. Further details of the data included in the Lead Morphology results class can be found

in Chapter 24.

vcg_morph_flag | 0 or 1

Sets if data from the VCG Morphology results class VCG_Morphology.m , which primarily

includes vectorcardiographic morphology measurements, is included in the measurement

output le. Further details of the data included in the VCG Morphology results class can be

found in Chapter 24.

13.2 Batch Processing via MATLAB Command Line


Once the parameters noted above in Chapter 13.1 have been set at the beginning of
braveheart_batch.m , the program is ready to run. In MATLAB, type braveheart_batch() in

the MATLAB command window and press Enter. If folder = '' , a dialog box will appear to

choose the directory which contains the ECGs to be processed, otherwise the specied folder is

used. The script will then loop through all of the ECGs with format format and the appropriate

le extension in the specied directory until complete. Once processing is complete a message

will display in the command window noting the number of ECGs processed and if there were any

errors during ECG processing. The output will include the folders and les as noted in Chapter
13.4.

Alternatively, the parameters can be passed directly into BRAVEHEART_batch.m as:

BRAVEHEART_batch(folder, source_str, output_ext, output_note, parallel_proc, ...


progressbar, save_figures, save_data, save_annotations, ...
vcg_calc_flag, lead_morph_flag, vcg_morph_flag, aps ) where the rst 12 inputs are as

noted above, and aps passes in a set of annotation parameters. If aps is not passed in (only 12

inputs are specied), the program uses the default values contained within Annoparams.m .
Passing in specic annotation parameters allows the user to run multiple batches with dierent

annotation parameters wihtout needing to manually reset each time.

115
To construct an Annoparams class simply call the Annoparams constructor without any inputs.

Next, to change a specic annotation parameter, assign it a new value as follows:

aps1 = Annoparams();
aps1.lowpass = 0;
aps1.pkthresh = 90;
aps1.STend = 55;
...

13.3 Batch Processing Using the Command Line Stand-Alone Executable


The parameters that need to be set when running the executable version of braveheart_batch.m
are the same as when running it via source code (see Chapter 13.1 for detailed descriptions of
the variables that must be set). The only dierence is that because braveheart_batch.m is not

directly editable when the program is run via executable, the parameters are edited in an

external le, batch_settings.csv , where the rst column is the parameter name, and the

second column is the parameter value (with columns separated by commas).

Open batch_settings.csv :

format, muse_xml
output_ext, .csv
output_note, batch
parallel_proc, 1
progressbar, 1
save_figures, 1
save_data, 1
save_annotations, 1
vcg_calc_flag, 1
lead_morph_flag, 1
vcg_morph_flag, 1

and simply edit the values in column 2 as noted in Chapter 13.1. Unlike when setting string

variables in MATLAB, the string values for format , output_ext , and output_note should not
be enclosed in quotes. The exact order of variables in batch_settings.csv is not important, but

all 11 variables must be included with appropriate values to avoid any errors. As noted in

Chapter 13.1, the parameter folder is only used when running BRAVEHEART via source

code in MATLAB, and it is therefore not set in batch_settings.csv . When running the

command line version of BRAVEHEART via executable, the ECG folder can only be chosen via

dialogue box after starting the program, and the annotation parameters can only be set via

editing Annoparams.csv or or using the GUI.

116
Once the parameters noted above in Chapter 13.1 have been set in batch_settings.csv and
annotation parameters have been set in Annoparams.csv (see Chapter 6) make sure these les

are saved. The program is now ready to run. Run the executable le. Choose the directory

which contains the ECGs to be processed. The script will then loop through all of the ECGs

with format format in the chosen directory until complete. Once processing is complete text will

display how many ECGs were processed, the number of ECGs that were agged for quality (see

Chapter 16), and the number that caused errors. The output will include the folders and les

as noted in Chapter 13.4.

13.4 braveheart_batch.m Output


Once batch processing is complete, the output will include:

processed_ecgs_<timestamp>.csv (or .xslx )

Contains electrocardiographic/vectorcardiographic measurements for every ECG that was

processed from the directory (1 row per ECG). If specic results classes are disabled (e.g.

vcg_calc_flag = 0 ), those values are replaced with NaN .

Folder figures_<timestamp>/

Location where summary gures (see Figure 35) are saved if save_figures = 1 .
Summary gure les are named <ecg_name>.png .

Folder data_<timestamp>/

Location where signal and annotation data are stored if save_data = 1 .


Data les are named <ecg_name>.mat .

Folder annotations_<timestamp>/

Location where annotation les are stored if save_annotations = 1 .


Annotation les are named <ecg_name>.anno .

check_ecg_list_<timestamp>.csv

Lists ECGs that tripped the quality detector and the specic reason for being agged (see

Chapter 16) .

Folder figures_<timestamp>_check_ecg_list/

Folder where summary gures are copied for ECGs whose annotations tripped the quality

detector (see Chapter 16).

117
errors_<timestamp>.csv

Lists ECGs that threw an exception during processing and information on the specic

exception.

118
14 Batch Processing ECGs via GUI ( braveheart_gui.m )

BRAVEHEART can process a batch of ECGs within the same directory from the command line

or GUI versions of BRAVEHEART. For information on running BRAVEHEART on a batch of

ECGs from the command line version of BRAVEHEART see Chapter 13. The outputs and

functions of batch processing are identical when batch processing ECGs from the command line

or GUI; the GUI is just a wrapper for passing parameters into the command line batch

processing program braveheart_batch.m .

When using the GUI for batch processing, the settings within the GUI (ltering, annotation

parameters, etc.) are used as the annotation parameters (see Chapter 12 and Chapter 6.2)
instead of pulling data from Annoparams.m (or Annoparams.csv if running via executable).

When using the GUI, batch ECG processing can be controlled from GUI Sections 1, 6.2, and 6.6.

Parameters in other sections are used to set annotation parameters as noted in prior sections,

which is similar to setting values within Annoparams.m when using the command line version of

BRAVEHEART for batch processing.

Figure 19: GUI items used to control batch processing in GUI section 1.

format is set using the `ECG Format' dropbox box in GUI item 1.1.

Instead of setting parameters to control batch processing in braveheart_batch.m , in the GUI

these are set using checkboxes in GUI item 1.18:


ˆ V Figs  sets value of save_figures as 1 (checked) or 0 (unchecked).
ˆ V Parallel  sets value of parallel_proc as 1 (checked) or 0 (unchecked).
ˆ V Annos  sets value of save_annotations as 1 (checked) or 0 (unchecked).
ˆ V Data  sets value of save_data as 1 (checked) or 0 (unchecked).

119
Figure 20: GUI items used to control batch processing in GUI Section 6.2.

ˆ output_ext is set using the VCG Calculations section in dropdown GUI item 6.2.3.
ˆ output_note is set using the VCG Calculations section in the `Note:' textbox GUI item

6.2.4.

120
Figure 21: GUI items used to control batch processing in GUI Section 6.6.

Control over what data is processed is set by checkboxes in the Utilities section and GUI

item 6.6.2:
ˆ V Calculate Standard Vectors  sets value of vcg_calc_flag as 1 (checked) or 0 (unchecked).
ˆ V Calculate 12-Lead ECG Morphology  sets value of lead_morph_flag as 1 (checked) or 0
(unchecked).

ˆ V Calculate VCG Morphology  sets value of vcg_morph_flag as 1 (checked) or 0


(unchecked).

There is no way to disable the progress bar via the GUI.

Once all batch parameters and annotation parameters have been set in the GUI, click on the

Batch button (GUI item 1.18). A dialog box will appear; select the directory that contains

the ECGs and click `Open'. Batch will begin. A progress bar displays the progress of batch ECG

processing. Once nished, a pop-up will display how many ECGs were processed, the number of

ECGs that were agged for quality (see Chapter 16), and the number that caused errors.
Output directory structure and le naming conventions are the same as noted in Chapter 13.4.

121
15 BRAVEHEART ECG/VCG Processing

15.1 R Peak Detection


QRS Complexes (R peaks) are detected in the vector magnitude (VM) lead by nding peaks in

the top n% of values (where n = pkthresh in Annoparams.m ) subject to a minimum R-R

interval constraint ( maxBPM in Annoparams.m ) which helps prevent incorrect detections of

fractionated R peaks within the same QRS or large amplitude T waves. The VM lead is used for

R peak detection because it is always positive, and the QRS complex peak amplitude is usually

signicantly larger than the T wave peak amplitude. In general, the nominal value for

peakthresh = 95 works well for most applications, but may have to be slightly adjusted in

ECGs that have signicant artifact (see Chapter 28), ECGs with ectopic/paced beats with a
large range of QRS amplitude in dierent beats, or ECGs with very large amplitude T waves.

Figure 22 below illustrates how the parameters peakthresh and maxBPM can be adjusted for R

peak detection. Issues with R peak detection (usually due to large artifact) are a common cause

of ECGs failing to load properly (see Chapter 28).

122
A

Figure 22: Examples of how peak thresholding ( pkthresh ) works in the context of heart rate constraints ( maxBPM ).
The same results can be obtained with dierent combinations ofpkthresh and maxBPM . A: Nominal settings with
pkthresh = 95 and maxBPM = 150 . The R peaks are appropriately identied (red and blue circles), but even though
the T wave peak also is above the 95th percentile (green signal above the blue dashed line), this is not identied
as a R peak because it falls within the blanking period (red and blue shaded areas) dened by
maxBPM . In this
case,maxBPM = 150 corresponds to an interval of 400 ms or 200 samples at 500 Hz on each side of the detected
R wave. B: The same ECG with pkthresh = 80 . The R peak detection does not change because the majority
of the QRST complex that is above the 80th percentile (green signal above dashed blue line) still falls with the
appropriate blanking period. C: In this example pkthresh = 80 but maxBPM = 250 . In this case, because the
blanking windows are signicantly shorter (120 samples on each side of each detected peak), the peak of the T
wave which is above the 80th percentile (green signal above dashed blue line) is now detected as a R peak (red dots).
D: Using maxBPM = 250 , R peaks are now appropriately identied without detecting T wave peaks by increasing
the threshold to pkthresh = 99 . Although the blanking window is short, the T wave peak is now below the 99th
percentile (green signal above blue dashed line), so even though the T wave peak falls outside the blanking window,
it is no longer detected as an R wave peak because its amplitude is below the 99th percentile (dashed line).

123
15.2 Baseline Correction
ECG machines do not usually set the zero voltage reference at the isoelectric interval of each

lead. Setting the zero voltage reference correctly on an ECG lead is critically important to

accurate measurements of the area under an ECG/VCG lead. The true isolectric (zero voltage)

part of an ECG/VCG signal is the segment between the end of ventricular repolarization (Toff ),

and the start of the P wave (TP segment). The importance of setting the zero voltage reference

appropriately can be seen in this gure, where incorrectly setting the zero voltage can result is

very large dierences in measured areas:

Figure 23: Signicant dierences in QRST area calculations due to dierent denitions of the vectorcardiographic
origin point.A: Median VCG beats (X, Y, Z) without any baseline processing where the onset of the QRS complex
(arrow) is dened as zero voltage. B: After baseline correction using the method described in the text, the TP
segment, a physiologically isoelectric interval is now set as the zero voltage (arrow). C and D: Physiological baseline
correction results in a 30% decrease in area under the X median beat. Reproduced with permission from [10].

124
High-pass ltering does remove DC osets, but after ltering, the TP segment is not necessarily

going to be set to approximate zero voltage. BRAVEHEART baseline correction adds a constant

to the ECG lead such that the TP segment approximates zero voltage. This can be seen in

Figure 24 below, where high-pass ltering removes a signicant amount of DC oset, but
additional baseline correction is needed to set the TP segment as the zero voltage reference:

1.2
Unfiltered Signal
1 High-pass Filtered
Filtered + Baseline Corrected
0.8 0 mV
0.6

0.4

0.2

-0.2

-0.4
0 500 1000 1500 2000 2500

Figure 24: Eect of baseline correction after high-pass ltering. The green signal is unltered and has a large oset
from the physiologic zero voltage. After high-pass ltering (blue), a large amount of this oset and low-frequency
baseline wander is removed, but the TP segment, which is the true isoelectric interval of the ECG lead, is still not
approximately zero voltage as the lters have no way to know to set the TP segment at 0 mV. After additional
baseline correction (red), the TP segment approximates 0 mV (dashed black line).

Details of the procedure for baseline correction are available in the methods manuscript [1].

The eect of baseline oset correction can be seen by clicking on the Osets button (GUI item

1.14). The original signals are shown in black, and the baseline corrected signals are shown in

red. Two gures are generated  one shows all 16 leads and their basline corrections, and the

other is a zoomed in view of the VM lead. An example of the osets gure is shown here:

125
Figure 25: Eect of ltering and baseline correction on an ECG with signicant baseline DC oset. The original
signals are shown in black, and the ltered and baseline corrected signals are shown in red. The zero voltage
line is shown in blue. Note that especially in leads I (L1), II (L2), V1, and X, there is signicant deviation from
zero baseline originally, and after ltering and baseline correction the TP segments now approximate zero votage.
The vector magnitude (VM) lead is signicantly distorted (black signal in the bottom right) without appropriate
baseline correction as inappropriate DC osets in the X, Y, and Z leads are amplied when calculating the VM =

X2 + Y 2 + Z 2 .

15.3 PVC and Non-Dominant Beat Morphology Detection


Accurate median beat construction and measurements depend on having a single QRST

morphology among the beats that make up the median beat. Although median beat construction

can deal with a few beats with disparate QRST morphology as long as these beats make up a

low percentage of the total beats, results are more accurate if non-dominant beats such as PVCs

or aberrant beats are excluded from analysis prior to median beat creation. In more extreme

cases such as ventricular bigeminy with equal numbers of PVCs and normal QRST beats, if

PVCs are not removed from analysis, the median beat will be a superposition of the normal

QRST complex and the PVC, and calculated results will be highly inaccurate. For this same

reason, it is not possible to rely on comparing each individual beat morphology to the median

126
beat morphology in order to determine what beats are PVCs or other non-dominant beats that

should be excluded. BRAVEHEART has a module to automatically detect (and remove) PVCs

and other non-dominant beats (from this point on the term PVC will refer to PVCs or other

non-dominant QRST morphologies which could be due to aberration or ventricular pacing).

A detailed technical discussion of the methods used for PVC detection is available in the

methods manuscript [1]. In brief, PVC detection utilizes normalized cross correlation (NCC) and

normalized root mean squared error (RMSE) to compare the QRST morpholgies between pairs

of QRST complexes. All pairs of beats are compared with NCC and RMSE, and the beat that

has the best correlation with the most of the other beats is chosen as the dominant QRST

morphology template. Compared to this template, beats that are outside of limits set by the

user in the parameter pvcthresh for NCC (nominally 95%) and the parameter rmse_pvcthresh
for RMSE (nominally 0.1) in Annoparams.m , are agged as PVCs. BRAVEHEART compares

morphologies like this in the X, Y, and Z leads, and given that a PVC can look similar to a

native beat in a single lead, if a PVC is detected in 2 out of the 3 orthogonal X, Y, and Z leads,

the beat is agged as a PVC. The user can then set if PVCs should be removed, or if the

non-PVC beats should be removed (see keep_pvc in Chapter 6.2). In this way it is possible to

analyze PVCs rather than dominant beats, automatically. In an analysis of the BRAVEHEART

PVC identication algorithm, using NCC = 95% and RMSE = 0.1, sensitivity was 98.2%,

specicity was 99.5%, and F1 was 97.7% for PVC detection (see methods manuscript [1] for

additional details).

PVC detection and removal are controlled by the following parameters in Annoparams.m which

are described in detail in Chapter 6.2.


ˆ pvc_removal which enables or disables automatic PVC removal.

ˆ pvcthresh which sets the valve for NCC (range 01).

ˆ rmse_pvcthresh which sets the value for RMSE.

ˆ keep_pvc which determines if PVCs are removed and retained for analysis.

When the GUI is used to control PVC detection/removal, as shown in Chapter 12.10, values
for the above annotation parameters can be set in GUI section 9. The GUI additionally has a

function which is called by the PVC Data button (GUI item 9.8). This brings up a gure which

summarizes PVC detection in the X, Y, and Z leads, and can be useful for troubleshooting if

needed:

127
Figure 26: Summary of PVC detection algorithm generated by clicking the PVC Data button (GUI item 9.8).
NCC and RMSE are displayed relative to a reference beat which is the beat that has the best correlation with
most of the other beats in the lead (in this case beat 1 in all 3 leads). This reference can vary by ECG lead.
Beat 10 is identied as a PVC based on NCC below threshold ( pvcthresh = 0.95 ) and RMSE above threshold
( rmse_pvcthresh = 0.1 ) in all leads (red box), and is agged as a PVC (red box in the lowest row, `Final PVC
Markers').

15.4 Outlier Beat Detection


After PVCs, aberrant beats, paced beats, or other abnormal QRST morphology beats are

removed, there may still be some beats that are contaminated with noise that are detrimental to

median beat creation and subsequent calculations. This can occur because the PVC detector

algorithm cannot look at the entire QRST complex since beats are of dierent length, and the

algorithm therefore looks primarily around the QRS peak (see the methods manuscript [1] for

additional details). Some beats that pass PVC detection can still have signicant artifact in

128
other parts of the QRST complex that prevent accurate annotation and alignment to create the

median beat. BRAVEHEART attempts to deal with this issue through removal of these outlier

beats.

A detailed technical description of the outlier identication algorithm is presented in the

methods manuscript [1]. In brief, to identify outliers, BRAVEHEART looks at the QR and RT

intervals of all remaining beats after rst pass annotation and PVC removal. A modied Z-score

is calculated for each beats' QR and RT intervals. Beats that have a modied Z-score for the QR

or RT interval above a threshold set by modz_cutoff in Annoparams.m are identied as outliers

and can then be automatically removed based on the value of outlier_removal in

Annoparams.m (see Chapter 6.2).

When using the GUI, Section 9 (see Chapter 12.10) is used to control outlier
detection/removal. The GUI additionally has a function which is called by the Outlier Data
button. This brings up a gure which summarizes outlier detection and can be useful for

troubleshooting if needed:

Figure 27: Summary of outlier detection algorithm generated by clicking the Outlier Data button in GUI item 9.2
for example3.xml . The rst 2 rows display the QR and RT intervals for each beat, with each column representing
a beat. QR or RT intervals that have a modied Zscore above the cuto set in Annoparams.m are noted in red. In
this example, beat 6 is classied as an outlier because the QR interval is out of range. Rows 36 can help diagnose
issues with annotation, but are not used for classify a beat as an outlier, and beats with a modied Zscore above
the set cuto for rows 36 are displayed in black rather than red.

129
16 ECG Quality Assessment

BRAVEHEART was designed to allow ecient batch processing of large numbers of ECGs. The

sample of the full batch of ECGs which are of overall poor quality, however, may not be known

ahead of time, and with large ECG datasets it may not be feasible to manually review every

processed ECG to ensure there is no signicant artifact or other problems that may result in

incorrect measurements reported by BRAVEHEART. To address this issue, BRAVEHEART has

a module that assesses the quality of each processed ECG so that ECGs with the highest

probability of being poor quality can be manually reviewed, while ECGs that are likely good

quality without processing errors will not require manual review. All ECGs that trip the quality

detector will not be of such poor quality that they need to be excluded from an analysis, but

they likely should be reviewed to ensure they are of adequate quality. The quality assessment is

designed to allow the user to easily customize the sensitivity and specicity of detection based on

the quality of the ECG data being processed (e.g. data from a trial vs clinically acquired data),

and quality detection can be completely disabled if wanted.

16.1 Quality Probability


BRAVEHEART quality assessment takes place in 2 ways. First we developed a logistic

regression model where the output was ECG quality (good quality or needs review) and the

inputs were various features of the processed median ECG/VCG signals. Further details can be

found in the methods manuscript [1]. After each ECG is processed, a probability (range 01) is

reported in the BRAVEHART output les as variable quality_prob , and as a percentage (range

0100) in GUI item 4.5 (`Prob (%)') where values above a set threshold (see below) are shown in
green indicating good quality, while values shown in red indicate needs review. The cuto

used to distinguish good quality and needs review ECGs can be adjusted to increase/decrease

sensitivity or specicity as needed for a specic project. In general, a cuto of ∼80% tends to

have a good mix of sensitivity and specicity, with both values >90%. Values >90% have higher

specicity at the expense of lower sensitivity, and values <70% have higher sensitivity at the

expense of lower specicity (see methods manuscript [1] for additional details). An example of

ECG quality estimation using this regression method is shown here:

130
Figure 28: Example of changes in predicted quality in the setting of a PVC. A: Prior to PVC removal. The PVC
(last beat) is highlighted in green. Because the PVC is not removed, the predicted probability of the median beat
being good quality is low at 3.7%. B: Once the PVC is removed via automated PVC removal (see Chapter
15.3), the predicted probability of the median beat being good quality is now excellent at 94.8%. Additionally,
in panel A, when the PVC is present, 2 quality ags (low predicted probability and low NCC) are triggered, while
in B, after PVC removal, 0 quality ags are triggered (see Chapter 16.2 below and Figure 29).

16.2 Quality Filters


The second way BRAVEHEART assesses quality is by using a set of lters that look at the

results from ECG/VCG processing. Annotated median beats are checked for possible processing

errors or missannotation by checking metrics including the heart rate, QT interval, QRS

duration, number of beats included in the median beat construction, number of beats removed

during PVC and outlier exclusion, T peak to QT ratio, T wave magnitude, average NCC between

beats that make up the median beat, and low neural network annotation condence. If any of

these values are outside of a range which can be set by the user, the ECG is agged for review.

131
16.3 Editing Quality Filtering Parameters - Qualparams.m

Note: In version 1.1.0 the method of adjusting quality ltering parameters was changed. The

parameters are now editable via a MATLAB le Qualparams.m instead of editing the previous

external le quality_presets.csv . The external le quality_presets.csv has also been

renamed Qualparams.csv and is used only when running BRAVEHEART via a compiled

executable when Qualparams.m cannot be edited.

Quality ltering is controlled by parameters in the le Qualparams.m . In cases where

BRAVEHEART is being run via executable and Qualparams.m cannot be edited, the parameters

can be set by editing Qualparams.csv which is an external le which contains the data

contained within Qualparams.m in comma separated columns. When the program is run via

executable, calls to pull data from Qualparams.m will instead pull data from Qualparams.csv .

The 12 Qualparams.m properties are listed here with their descriptions. Each of the 12

properties is assigned 2 numeric values as a vector enclosed in square brackets per MATLAB

syntax. Each parameter's values are in the format [min max] , where the range of min to max is

considered the acceptable range of values for that parameter. Therefore, values < min or >

max will result in that quality ag being triggered.

qrs = [60 200]; % Min/max range of QRS duration


qt = [250 700]; % Min/max range of QT interval
tpqt = [0.5 Inf]; % Min/max range of T peak/QT ratio (nominal is min only)
t_mag = [0.05 Inf]; % Min/max range for T wave magnitude (nominal is min only)
hr = [30 150]; % Min/max range for HR
num_beats = [4 Inf]; % # of beats left after PVC and outlier beats are removed
pct_beats_removed = [-Inf 60]; % of total number of beats removed to trigger
corr = [0.8 1]; % Min/max range for average normalized cross correlation
baseline = [-Inf 0.1]; % Min/max range for baseline at the end of the T wave
hf_noise = [10 Inf]; % SNR for HF noise cutoff
lf_noise = [-Inf 0.02]; % mV for cutoff in variance in LF noise
prob = [0.8 1]; % Logistic regression probability (range 0-1)

Note that some of the commented descriptions were shortened to t on one line.

As shown below in Chapter 16.4 and Chapter 16.5, 3 additional quality parameters,
missing_lead , NNet_prob_flag , and NNet_NaN exist, but do not have user adjutable parameters.

You can use ± Inf to signify ±∞; [0.5 Inf] will only trigger a quality ag for values < 0.5.

Similarly, [-Inf 10] will only trigger for values > 10. A lter can be completely disabled by

setting the min/max values to [-Inf Inf] .

When using a compiled version of BRAVEHEART, Qualparams.m is not editable, and to adjust

132
the quality ltering parameters, you can edit Qualparams.csv . This le contains the quality

parameter in the rst column, the minimum value in the second column, the maximum value in

the third column, and a description of the parameter in the fourth column, with columns

separated by commas:

qrs, 60, 200, Min/max range of QRS duration


qt, 200, 700, Min/max range of QT interval
tpqt, 0.5, Inf, Min/max range of T peak/QT ratio
t_mag, 0.05, Inf, Min/max range for T wave magnitude
hr, 30, 150, Min/max range for HR
num_beats, 4, Inf, # beats left after PVC and outlier removal
pct_beats_removed, -Inf, 60, % of total number of beats removed
corr, 0.8, Inf, Min/max range for average NCC
baseline, -Inf, 0.1, Min/max range for baseline at the end of the T wave
hf_noise, 10, Inf, SNR for HF noise cutoff
lf_noise, -Inf, 0.02, mV for cutoff in variance in LF noise
prob, 0.8, Inf, Logistic regression probability (range 0-1)

Brackets are not needed/used when editing Qualparams.csv like they are when editing

Qualparams.m . When editing Qualparams.csv you can input -Inf and Inf. Blank values are

loaded as ±∞ depending on which column they are in.

Adding new variables to the quality agging can be done without too much diculty, although

doing so is beyond the scope of this guide.

16.4 Quality Output Files During Batch Processing


To facilitate review of ECGs that are potentially of poor quality during batch ECG processing, if

any ECG is agged for quality, a le named check_ecg_list_<timestamp>.csv is created

which lists the ECGs which were agged and the reason for agging. The le contains columns

which correspond to specic quality ags in quality_presets.csv :


ˆ qt_error  qt (QT interval) is out of range.

ˆ qrs_error  qrs (QRS duration) is out of range.

ˆ tpeakqt_error  tpqt (ratio of T peak time to QT interval) is out of range.

ˆ tmag_error  t_mag (T wave magnitude) is out of range.

ˆ HR_error  hr (heart rate) is out of range.

ˆ num_beats_error  num_beats (number of beats in the median beat) is out of range.

ˆ num_removed_beats_error  pct_beats_removed (% of beats removed with PVC/outlier

removal) is out of range.

ˆ median_sig_corr_error  corr (NCC) is out of range.

ˆ baseline  baseline (median VM voltage after Toff ) is of out of range.

133
ˆ missing_lead  A lead appears to be missing (Note: not editable in Qualparams.m ).
ˆ hf_noise  hf_noise (estimate of high-frequency noise) is out of range - see Chapter
20.12.
ˆ lf_noise  lf_noise (estimate of low-frequency baseline wander) is out of range.

ˆ probability  probability (predicted probability for good quality) is out of range - see

Chapter 20.12.
ˆ NNet_prob_flag  NNet_prob_flag was activated due to low NN median beat annotation

condence (see Chapter 19). (Note: not editable in Qualparams.m ).


ˆ NNet_NaN  NNet_NaN was activated because the NN was unable to nd all median beat

ducial points (see Chapter 19). (Note: not editable in Qualparams.m ).

Values of 1 indicate that the specic quality metric was agged, while values of 0 are normal.

If batch processing is set to save summary gures, BRAVEHEART also creates a separate

directory of summary gures (folder named figures_<timestamp>_check_ecg_list/ ) only for

the ECGs which are agged for quality. In this way, it is easier to look through only the agged

ECGs rather than having to manually nd agged ECGs from within the full dataset.

16.5 Quality Output When Using the GUI


When the Quality button (GUI item 4.4) is pressed, it brings up a gure that shows which
quality ags are normal in green (value = 0 ), and which quality ags are abnormal in red (value

= 1) for the processed ECG:

Figure 29: Example of changes in quality ags in the setting of a PVC as shown in Figure 28. A: Prior to PVC
removal, 2 quality ags (low predicted probability and low NCC) are triggered, while in B, after PVC removal, 0
quality ags are triggered.

Note that the GUI combines the results of NNet_prob_flag and NNet_NaN into a single bar

called NNet Flag.

134
16.6 Other Uses for Quality Filtering
Although the quality lters are designed primarily for catching poor quality ECGs, they can also

be used for other purposes including selecting ECGs from a large unlabeled dataset that meet

certain morphologic criteria such as those with a certain heart rate range, prolonged QRS

duration, or large T wave amplitude, among others.

135
17 Using .anno Files

.anno les have 2 main uses within BRAVEHEART. They are used to store the specic

annotation parameters and beats that were used to process a specic ECG (these parameters are

stored within the BRAVEHEART output data les as well), and to allow specic ECGs that

don't conform to the standard parameter values within Annoparams.m or ECGs that require

manual beat adjustment or removal, to be easily reprocessed within a batch of ECGs without

having to manually adjust them over and over.

.anno les are .csv les that have the .anno extension to avoid issues with potential ECG le

formats or results les that could also have the .csv extension. An example (and truncated)

.anno le is shown below, and use of .anno les in the batch processing mode of BRAVHEART

is shown in quick start Example 5 ( Chapter 5.5).


Table 2: Example .anno le

275, 299, 326, 502


925, 949, 974, 1153
1533, 1558, 1585, 1757
2160, 2184, 2212, 2396
2768, 2792, 2814, 2991
3370, 3393, 3419, 3610
3991, 4015, 4042, 4223
4626, 4650, 4675, 4858
maxBPM, 150, ,
pkthresh, 95, ,
lowpass, 1, ,
highpass, 1, ,
wavelet_level_lowpass, 2, ,
wavelet_level_highpass, 10, ,
wavelet_name_lowpass, Sym4, ,
wavelet_name_highpass, db4, ,
...
keep_pvc, 0, ,
blanking_samples, 0, ,
debug, 0, ,

The rst n rows are the individual ducial points for the n beats which were used to create the

median beat. If 2 Include Beats is not checked in the GUI, the beats are omitted. When .anno
les are generated during batch processing of ECGs, the ducial points are always included. The

remaining rows starting with maxBPM correspond the all of the parameters in Annoparams.m and

the parameter values that were used to process the ECG (see Chapter 6).

136
17.1 Generating .anno Files
There are 2 ways to generate an .anno le. In the GUI, item 3.14 includes an Export button to

generate an .anno le for the ECG that is loaded. If the V Include Beats checkbox is checked,

the individual beats/ducial points which make up the median beat are also saved in the .anno
le. This can be useful if you had to manually remove a beat for some reason such as noise, if

the automated outlier and PVC detection/removal was not eective, or other projects that

involve looking at specic beats.

When performing batch ECG processing, checking the V Annos box in the GUI, or setting

save_annotations = 1 in either BRAVEHEART_batch.m or batch_settings.csv when running

via command line, will generate an .anno le, which includes beat ducial points and annotation

parameters, for each processed ECG. These les are stored in a folder called

annotations_<timestamp>/ . The annotation les within will have the same name as the

processed ECG with the .anno extension.

17.2 Using .anno Files


An example of using .anno les with the GUI is shown in quick start Example 5 ( Chapter
5.5). To use an .anno le within the GUI, rst load the ECG as normal. Then click Import
(GUI item 3.8). A dialogue box will appear; choose the .anno le you want to load and click

`Open'. The current GUI settings are overwritten by the parameters in the .anno le, and if

beat ducial point annotations are included in the .anno le, only the included beats will be

used to construct the median beat. ECG measurements are then calculated without needing to

press the Calculate button. If you are processing other ECGs in the GUI after processing an

ECG that included loading an .anno le, remember to reset the default annotation parameters

with the Reset (GUI item 3.7) before processing other ECGs.

When in batch processing mode via command line or GUI, BRAVEHEART checks the ECG le

directory for any les with the same name as the ECG being processed with the le extension

.anno . If an .anno le with the same name as the ECG being processed is present in the same

directory as the ECG le, the ECG is processed using the annotation parameter values within

the .anno le rather than Annoparams.m , and only using the beats specied in the le. In this

way, if there is an ECG that requires a specic non-nominal values of a parameter such as STend
to process properly, you can process the ECG and generate an .anno le. Edit the .anno le

with the correct value of STend or whatever other parameters need to be adjusted. Likewise, if

outlier and PVC detection and removal are having an issue with a specic ECG and you want to

137
manually exclude a specic beat, simply delete that beat from the .anno le. Then the next

time you run a batch using BRAVEHEART with the same ECG (perhaps you want to run the

batch of ECGs with a dierent transformation matrix or ltering parameters, or if you added a

new parameter and want to calculate it on the same batch of ECGs), the dierent value of

STend will load for that ECG ONLY, and the specic beat in question will be deleted. This

can save time when running batch analyses multiple times.

138
18 First Pass Annotation

18.1 First Pass Annotation Algorithm


First pass annotation uses a heuristic algorithm to nd Qon , Qoff , and Toff for each QRST

complex in the VM lead. The VM lead is used for rst pass annotation because it is always

positive and the QRS magnitude tends to be larger than the T wave magnitude which helps

simplify calculations. First pass annotation is controlled with the following parameters in

Annoparams.m (see Chapter 6.2):


ˆ autoMF
ˆ autoMF_thresh
ˆ MF_width
ˆ QRwidth
ˆ RSwidth
ˆ STstart
ˆ STend
ˆ Tendstr

First pass annotation is controlled by the autoMFannotate.m subroutine which uses these

parameters, the locations of the dominant R peaks in the VM lead (see Chapter 15.1), and any
pacing spikes (see Chapter 5.4), in order to set the search windows for the beginning and
ending of the QRS complex and T wave. If autoMF = 1 the QRS search algorithm dynamically

estimates the QRS search window by estimating the the width of the QRS peak in the VM lead

after median ltering with a lter width of MF_width . Using autoMF = 1 is usually better than

manually setting a static QRS search window using QRwidth and RSwidth because all beats are

not necessarily the same width, and a xed search window may not work for all beats. The

search window is set for each individual peak to twice the the width of the region of points

greater than the percentage autoMF_thresh of the height of the median-ltered dominant

R-wave peak. If autoMF = 0 , the provided, and static, values of QRwidth and RSwidth are used

to set the QRS search window for all peaks.

Once the QRS search window is established, for each QRS complex, the start (Qon ) and end

(Qoff ) are determined as follows. First, the algorithm determines if there is an additional peak in

the VM lead before the dominant R wave peak within a short distance (i.e. a Q wave). Two

methods are then used to determine the start of the peak. Method A nds the maximum slope

and walks out until it nds a point where the absolute value of the derivative is 2% of the

maximum slope (or the smallest value found if not 2%). Method B looks for the rst local

minimum and labels this as the ducial point. The point closest to dominant R-wave from

methods A and B is chosen as the ducial point.

139
After Qon and Qoff are located, a blanking window equal to STstart ms is set after the location

of Qoff during which the T wave cannot be detected to avoid issues if Qoff is not detected

correctly. At the end of this STstart window, the T wave search window starts and is extended

by STend % of the mean RR interval. STend is set as a % of the mean RR interval rather than

an absolute value in ms to minimize the need to change parameter values as QT interval is

related to RR interval. The location of Toff is then detected by the method specied in Tendstr .


If Tendstr is ’baseline’ or ’tangent’ , the second half of the T-wave is t to A exp (t/σ)B .

The intersection of the function, or the tangent to the maximum negative slope with the

baseline, is then calculated. If Tendstr is ’energy’ , the T-wave oset is chosen by a method

based on the derivative of the signal (see reference [6]).

18.2 First Pass Annotation Figure


First pass annotation is summarized in the following gure:

Figure 30: First pass annotation and search windows. The upper panel shows annotation search windows/detected
points for the entire VM lead. The bottom panel shows a zoomed in view of the second beat (dashed box). If
auto_mf = 1 , the values of QRwidth and RSwidth (grey) are disabled and the QRS search window is dynamically
estimated for each beat as twice the width of the median ltered QRS complex at autoMF_thresh % of the R peak
voltage (nomimally 20% - yellow dots/line) for that beat centered on the R peak. If auto_mf = 0 the values of
QRwidth and RSwidth are used to set the width of the QRS search window before and after the R peak, respectively.
The blue | symbols denote the beginning and end of the QRS search window and can help determine if the QRS
detection window is too wide/narrow. Within the bounds of the QRS search window, Qon and Qoff are detected
as noted in the text with locations noted as [ and ], respectively. Once Qoff is detected, a blanking period set by
STstart (nominally 100 ms) extends forward from the location of Qoff , marking the start of the T wave search
(
window ( ). The T wave search window extends forward by STend % of the mean RR interval (nominally 45%)
and ends at the ) symbol. Within the T wave search window bounds, the location of Toff is marked with a }.

140
18.3 Common Annotation Parameter Problems
The nominal value of autoMF_thresh = 20 . Consider what can happen if autoMF_thresh is set

too low:

Figure 31: autoMF_thresh = 5 is set too low. See text for details.

As shown in Figure 31, if autoMF_thresh = 5 is set too low, more than the true QRS complex

may be detected as part of the QRS complex (see orange circles and line), resulting in the

estimated QRS width and the QRS search window (|) being too wide. This prevents accurate

annotation of Qon ([) and Qoff (]), but also can interfere with the T wave search window ( to ) ( )
and locating Toff (}) because the onset of the T wave search window starts STstart ms after the

location of Qoff .

As shown in Figure 32, if autoMF_thresh is set too high, the QRS search window is likely to be

too narrow:

Figure 32: autoMF_thresh = 80 is set too high. Se text for details.

Note that in this example, Qon [


(( )) is annotated later than the true QRS onset because the

search window is not wide enough.

In cases where atypical QRST morphology is causing issues with rst pass annotation, setting

autoMF = 0 in Annoparams.m or by unchecking the 2 Auto Width checkbox, can allow manually

setting the QRS search window by setting the values of QRwidth and RSwidth .

As shown in Figure 33, if STend is too short, the end of the T wave may not be found:

141
Figure 33: STend = 20 is set too short. Se text for details.

)
In this example, the end of the T wave search window ( ) is too short to include the entire T

wave, and the location of Toff (}) is therefore not accurate. If STend is longer than necessary this

usually does not cause as many issues as if STend is too short, as long as the end of the T wave

search window does not encroach on the start of the next PQRST complex.

142
19 Neural Network Median Beat Annotation

Accurate annotation of the median beat is important for obtaining accurate measurements. We

found that the heuristic methods which are used for rst pass annotation were not accurate

enough for median beat annotation, especially when QRST complexes had abnormal or very low

amplitude T waves. This accuracy is less important for rst pass annotation because rst pass

annotation needs to be just good enough to properly align each beat for median beat creation.

We therefore trained and validated a custom bidirectional Long-Short Term Memory (LSTM)

neural network (NN) designed specically to annotate median VM beats. The technical details

of NN training and validation are available in the methods manuscript [1].

The NN included with BRAVEHEART is highly accurate when compared to board certied

cardiac electrophysiologists and its accuracy was tested in 2 separate datasets.

Testing set 1 was performed at the time of NN training using data that was not used for training

or validation of the NN, and showed excellent agreement with ground truth, well within

acceptable limits for computer based automatic ducial point annotation [11, 12, 13, 14]. Testing

set 2 was performed using a completely dierent dataset collected for dierent purposes. The NN

also had an excellent accuracy with this second, independent dataset. Results are summarized

here:

Table 3: Neural Network Annotation Accuracy

Result Qon Qo To QRS duration QT interval


Set 1 Error Mean ± SD (ms) -0.3 ± 3.9 -1.2 ± 5.1 -0.1 ± 7.0 -0.9 ± 6.2 0.2 ± 7.9

Set 2 Error Mean ± SD (ms) -0.1 ± 3.3 -1.7 ± 4.0 1.2 ± 5.8 -1.6 ± 5.4 1.3 ± 6.7

As can be seen, the mean dierence between NN predicted and ground truth ducial point

locations were < ±2 ms (1 sample at 500 Hz) for all points in both testing datasets. The

methods manuscript [1] contains extensive information about NN architecture, training, and

testing results.

The output of the NN can be visualized by viewing the `Debug' gures enabled with the

V Debug checkbox (GUI Section 3 Chapter 12) and generated after pressing Calculate which

shows the probability scores for each sample being either a QRS complex, T wave, or other:

143
Figure 34: Debug gure for median beat annotation. The dashed lines are the NN predicted probabilities of a
sample being a QRS complex (red), T wave (blue), or other (black). Each sample in the median beat signal
is assigned the label that is the highest of the 3 probabilities. Qon is set as the sample where other transitions
to QRS complex, Qoff is set as the sample where QRS complex transitions to T wave, and Toff is set as the
sample where T wave transitions to other. Qon [ Qoff
is marked with a , ]
is marked with a , andToff is marked
with a } similarly to rst pass debug gures. In rare cases where multiple potential ducial points are detected,
logic is used to select the best point  see the methods manuscript [1] for additional details.

144
20 Figures

BRAVEHEART allows visualization of ECG and VCG data in numerous ways. The following

section describes the gures/visualizations that can be generated primarily by the

BRAVEHEART GUI. When batch processing, normally only summary gures ( Figure 35 and
Figure 36) are generated, although with code modication it is possible to generate any of the
gures in this section during batch ECG processing.

20.1 Summary Figure


The summary gure is generated by batch processing for each ECG that is processed if

save_figures = 1 or when V Figs is checked (GUI item 1.18).

When using the GUI to analyze individual ECGs, the summary gure can be generated using

the Summary button in GUI item 7.1. To save the summary gure as a .png le click the

V Save checkbox (GUI item 7.3) prior to clicking Summary . Two examples and descriptions of

the Summary Figure are shown here:

145
example1.xml
2
VM
X
X / Y / Z Cross Correlation = 0.995 / 0.993 / 0.990 Y
1.5
QRS = 94 ms Z
QT = 446 ms QRS Start
QRS End
1 Tend
0.05 mV
mV

0.5

-0.5
0 50 100 150 200 250
X (mV)

0 1000 2000 3000 4000 5000


Y (mV)

0 1000 2000 3000 4000 5000


Z (mV)

0 1000 2000 3000 4000 5000


VM (mV)

0 1000 2000 3000 4000 5000


Samples

Figure 35: Summary gure for example1.xml generated when save_figures = 1 when set in braveheart_batch.m ,
when V Figs is checked prior to running batch ECG processing from the BRAVEHEART GUI, or when clicking
Summary View/Save ECGs' section of the GUI after ECG/VCG processing.
in the ` The summary gure shows
the median X, Y, Z, and VM beats in the upper half, and the individual beats used to create the median beats in
the lower half. Beats that are included in the median beat are marked with an orange circle on the VM R peak.
Beats that are not included do not have an orange circle on the VM R peak. Beats that are removed due to PVC
or outlier detection are marked with `PVC' or `Out', respectively. Beats that do not have an orange circle and were
not annotated as either a PVC or outlier were removed either due to being too close to the start/end of the ECG
signal, due to manual beat removal, or due to being missed by initial QRS detection (below threshold or within the
blanking period). The summary gure is useful to give you a quick view of which beats are included, which beats
were excluded and why, the quality of median beat creation (via cross correlation values) at the top, and median
beat intervals and annotations.

146
example2.xml
1.5
X / Y / Z Cross Correlation = 0.993 / 0.980 / 0.994 VM
X
QRS = 98 ms Y
QT = 378 ms Z
1
QRS Start
QRS End
Tend
0.05 mV
mV

0.5

-0.5
0 50 100 150 200 250
PVC
X (mV)

0 1000 2000 3000 4000 5000


PVC
Y (mV)

0 1000 2000 3000 4000 5000


Z (mV)

PVC
0 1000 2000 3000 4000 5000
VM (mV)

PVC

0 1000 2000 3000 4000 5000


Samples

Figure 36: Summary gure for example2.xml . The gure layout is the same as noted in Figure 35. In this example
the PVC has been removed by automatic PVC detection and removal. Note that the PVC does not have an orange
circle on the VM R peak, indicating the the beat is not included in the median beat. The PVC is labeled as PVC
indicating that the beat was removed with PVC detection/removal. For illustrative purposes beat 4 has also been
manually removed and therefore does not have an orange circle on the VM R peak. Beats that were detected and
removed as outliers are labeled as Out (not present in this example).

20.2 12-Lead ECG/VCG


Once an ECG is loaded, the 12-Lead ECG and/or VCG can be displayed with the ( 12L ECG )

and VCG ( X,Y,Z VCG ) buttons in GUI item 7.1. The inclusion of major/minor grid lines can be

enabled/disabled by choosing an option in dropdown in GUI item 7.2. To save the ECG/VCG

as a .png le click the V Save checkbox (GUI item 7.3) prior to clicking the 12L ECG or

X,Y,Z VCG buttons. The 12-lead ECG and VCG for example1.xml are shown here:

147
Figure 37: 12-lead rhythm strips for example1.xml .

Figure 38: VCG and VM rhythm strips for example1.xml .

20.3 Median Beats


The 16 median beats can be displayed by clicking the Med. Beats button in GUI item 7.1. The

inclusion of major/minor grid lines can be enabled/disabled by choosing an option in the

148
dropdown in GUI item 7.2. To save the median beat gure as a .png le click the V Save
checkbox (GUI item 7.3) prior to clicking the Med. Beat button. The median beat gure for

example1.xml is shown here:

Figure 39: 16 median beats for example1.xml .

Detailed measurements of the median beats can be shown by clicking the Lead Morphology
button (GUI item 5.3). See Figure 43 for additional information.

20.4 Normal Values


BRAVEHEART can display age, sex, BMI, and race specic normal ranges for certain

parameters Chapter 22, and show if calculated values are within normal range by clicking on
the Normal Vals. button. Values in black are within normal range, and values in red are outside

the normal range. The parameters shown in this gure are the same parameters that will have ↑
or ↓ next to them in the ` VCG Calculations' section (GUI item 6.2.1) to indicate if the value
is above or below the normal range, respectively. To save the normal values gure as a .png le

click the V Save 7.3) prior to clicking the Normal Vals. button. Further
checkbox (GUI item

details on normal values/ranges can be found in Chapter 22. The normal values gure for

example1.xml is shown here:

149
Figure 40: VCG calculations and their relationship with age, sex, BMI, and race specic normal values for
example1.xml . The normal ranges are shown in yellow, with the upper and lower bounds shown with grey text.
In this example, SVG X, SVG Y, SVG magnitude, SAI VM, and SAI QRST are out of range (red lines and text),
while the other parameters which are within the normal range with black lines and black text.

20.5 VCG Loops


The VCG loops gure displays the X, Y, and Z median beats and the associated VCG loops

displayed in orthogonal views, and can be generated by clicking the VCG Loops button. To save

the VCG loops gure as a .png le click the V Save checkbox (GUI item 7.3) prior to clicking
the VCG Loops button. The VCG Loop gure for example1.xml is shown here:

Figure 41: VCG loop gure for example1.xml .

150
20.6 3D VCG
The 3D VCG is displayed in GUI section 6.1 by clicking on the Vectorcardiogram button (GUI
item 5.1). This gure can be rotated by using the rotation tool (GUI item 10.1), and options in

GUI item 6.1.1 can be used to change what information is displayed in the gure (see Chapter

12.7). To save the 3D VCG gure in the current orientation, click on the Save button in the
lower right of the gure (GUI item 6.2.8).

Figure 42: 3D VCG as displayed in GUI item 6.1. The QRS loop is shown in blue and the T wave loop is shown
in red. In this specic situation various vectors are shown as described in the legend. Options for VCG display are
shown in GUI item 6.1.1

20.7 Lead Morphology


The Lead Morphology button (GUI item 5.3) displays a pop-out window with all 16 median
beats, ducial points, and the measurements of the R, S, and T waves. This displays the

majority of results contained in the Lead_Morphology results class. The lead morphology gure

for example1.xml is shown here:

151
Figure 43: Measurements on 16 median beats. Values are in mV.

20.8 Animated VCG


An animated VCG can be generated by clicking the Animate button (GUI item 6.1.3). The

`Step' textbox sets the number of samples that are advanced per frame.

20.9 X-, Y-, Z- Stats Figures


The X-, Y-, and Z- stats gures display information on the beats that make up the median X,

median Y, and median Z beats, respectively. These gures are generated by clicking on the

X Stats , Y Stats , or Z Stats buttons (GUI item 6.4.3). Beat-by-beat QRS duration, QT

interval, QRST area (SVG), absolute QRST area (SAI), and the individual beats (black

tracings) that make up the median beat (green tracing) are shown with normalized cross

correlation (NCC). The X-stats gure for example1.xml is shown here:

152
Figure 44: Individual beat stats for lead X in example1.xml . The QRS duration, QT interval, area under the QRST
complex (SVG), and absolute area under the QRST complex (SAI) are shown. The right panel shows the median
beat in green and the individual beats the make up the median beat in black. The NCC (0.995) is displayed.

20.10 Full VCG


This displays the rhythm strip VCG rather than the median beat VCG.

Figure 45: Raw VCG plotted in 3D for example1.xml .

153
20.11 Osets
The Osets button shows the eect of baseline correction, which is a process that attempts to set

the TP segment, which is a true isoelectric interval of the ECG, to 0 voltage. An example of the

osets gure is shown in Figure 25. Further details can be found in Chapter 15.2.

20.12 Filtering
The Filtering button displays how the selected ltering parameters aects the loaded ECG. The

original, unltered ECG signals are shown in black, and the signal post ltering (and baseline

correction) is shown in red. The approximation of baseline wander is shown as a dashed blue

line. An example ltering gure is shown here:

Figure 46: Filtering gure. The original, non-ltered, raw signal is shown in black, and the ltered signal is shown
in red. The dashed blue line is the estimated baseline wander. In this example, note how leads II, III, avF, and
V6 have signicant baseline wander that is successfully removed with high-pass ltering. See ltering sub-gure
( Figure 47) for additional detail.

In addition to the ltering gure shown above, clicking on the Filtering button beings up a

sub-gure that displays the estimated signal to noise ratio (SNR) to estimate high frequency

noise, and an estimation of low frequency noise/wander. High values of SNR are indicative of
minimal high frequency noise, and low values of baseline wander estimates indicate minimal

154
baseline wander. The cutos that are used to indicate good quality (green boxes) vs poor quality

(red boxes) are set with quality parameters ( hf_noise and lf_noise ) in the external le

quality_presets.csv . See Chapter 16 for additional information.

Figure 47: Filtering sub-gure for Figure 46. Note how in Figure 46 leads II, III, avF, and V6 have signicant
baseline wander, and the sub-gure shows these leads have low-frequency noise above the set cuto of 20 µV (red
bars).

20.13 Threshold
The Threshold button displays the R peak threshold gure which is described in detail in

Chapter 15.1 and Figure 22.

20.14 Debug Figures


The V Debug checkbox enables debug gures that show information on rst pass and median

beat annotation that can help troubleshoot ECGs that are not processing to see if specic

annotation parameters need to be adjusted. When V Debug is checked, clicking

Calculate brings up a gure showing the annotation markings/search windows for the full VM

lead:

155
Figure 48: First pass annotation parameters and search windows. See Chapter 18 for details.

As the median beat is annotated by a NN, the debug gure for median beat annotation shows

the scores for each segment of the QRST complex being a QRS complex, T wave, or other:

Figure 49: Debug gure for median beat annotation. The dashed lines are the NN predicted probabilities of a
sample being a QRS complex (red), T wave (blue), or other (black). Each sample in the median beat signal
is assigned the label that is the highest of the 3 probabilities. Qon is set as the sample where other transitions
to QRS complex, Qoff is set as the sample where QRS complex transitions to T wave, and Toff is set as the
sample where T wave transitions to other. Qon [ Qoff
is marked with a , ]
is marked with a , andToff is marked
with a } similarly to rst pass debug gures. In rare cases where multiple potential ducial points are detected,
logic is used to select the best point  see methods manuscript [1] for additional details.

156
20.15 Angle Conventions
The 3D angle conventions are shown visually in Figure 50 below:

Azimuth
Range -180 to 180°

Eleva�on
Range 0 to 180°

Magnitude: Length of vector


Azimuth: Angle between +X axis and vector in the XZ (transverse) plane
Eleva�on: Angle up from the feet (+Y axis)

Figure 50: The following conventions for 3D angles are used by BRAVEHEART: Azimuth is the angle in the
transverse (XZ) plane that can be between 0 and ±180◦ . Positive azimuth angles are posterior, and negative
◦ ◦
azimuth angles are anterior. Elevation is the angle up from the feet that can be between 0 and 180 . 0 points

towards the feet and 180 points towards the head. Magnitude is the length of the vector.

This gure can be displayed in the GUI by clicking on the Angle Info button in GUI item

6.6.6 (see Chapter 12.7).

157
21 Annotation Parameter Presets

Presets for rst pass ducial point detection can be saved to allow rapid switching between

multiple parameters if needed. For example, if you are looking at ECGs with long QT syndrome,

the nominal value of STend which is `45%' may result in missing the true ends of T waves, or if

you want to look looking at tightly coupled PVCs, you may need to increase maxBPM from its

nominal value of `150 bpm' and decrease pkthresh from its nominal value of `95'. You could

manually adjust the value of STend , maxBPM , and/or pkthresh in Annoparams.m or using the

GUI, but using presets allows you to save certain groups of parameters for later use.

Presents can only be used with the GUI version of BRAVEHEART. An alternative to use of

manual adjustment of annotation parameters or use of presets is to specify non-nominal

annotation parameters in an .anno le which allows much ner control over ECG/VCG

processing and annotation than can be set with a preset (see Chapter 17).

Presets are set via the external le search_presets.csv . The le contains 7 columns separated

by commas. Column 1 is the preset name that shows up in the BRAVEHEART GUI, and the

next 6 columns correspond to the values of pkthresh , maxBPM , QRwidth , RSwidth , STstart , and

STend , in that order as shown here:

name, pkthresh, maxBPM, QRwidth, RSwidth, STstart, STend


Standard, 95, 150, 100, 100, 100, 45
PVCs, 85, 200, 150, 150, 150, 35
BBB/Paced, 95, 150, 150, 150, 150, 45
Bigeminy, 85, 170, 150, 150, 150, 70

To add a new preset, simply add a new line with a preset name and the appropriate values of

pkthresh , maxBPM , QRwidth , RSwidth , STstart , and STend in the appropriate columns, save the

le, and restart BRAVEHEART (presets are only loaded when the BRAVEHEART GUI

initializes).

To use a preset, select the preset name from dropdown GUI item 3.5:

158
Figure 51: Preset dropdown in GUI

159
22 Normal Ranges

The BRAVEHART GUI can calculate normal ranges for a select number of VCG parameters

based on age, gender, race, and BMI. Normal ranges were obtained by measuring VCG

parameters on 3,292 patients with normal ECGs and no history of cardiovascular, pulmonary, or

renal disease, and no abnormal cardiovascular imaging [2].

The following parameters have normal ranges which can be displayed in the GUI:

ˆ SVG area magnitude  svg_area_mag Figure 50)


(see

ˆ SVG area azimuth  svg_area_az (see Figure 50)


ˆ SVG area elevation  svg_area_el (see Figure 50)
ˆ SVG area X  svg_x
ˆ SVG area Y  svg_y
ˆ SVG area Z  svg_z
ˆ SAI QRST  sai_qrst
ˆ SAI VM  sai_vm
ˆ Area (mean) QRST angle  qrst_angle_area
ˆ Peak QRST angle  qrst_angle_peak

Further details of each parameter can be found in Chapter 24.

The BRAVEHEART GUI can extract age and sex from ECG formats that contain this data,

such as .xml or .dcm , using xml_demographics.m .

160
23 ECG Format Information

BRAVEHEART can read a variety of ECG le formats. This section includes brief descriptions

of the le formats that can be read by BRAVEHEART without modication. Additional le

formats can be added as described in Chapter 8. Some formats may have multiple versions that

are formatted slightly dierently and which may result in errors when loading ECGs.

Unformatted .txt
Unformatted text les (extension .txt) use format = 'unformatted' and load via the le

load_ecg.m . These les contain 12 columns with data in the order of lead I, II, III, avR, avL,

avF, V1. V2, V3, V4, V5, and V6. The sampling frequency is encoded in the le as the rst

value in each column, and the ECG signal data starts in row 2 for each column. The le's units

are mV, so no conversion is needed. This is a simple le format, but the downside is that le

sizes tend to be larger than if the same signals were stored using encoded .xml or other formats.

BIDMC .txt
BIDMC formatted text les (extension .txt) use format = 'bidmc_txt' and load via the le

load_ecg.m . This le format is used to export ECGs using the legacy ECG system at BIDMC.

Files contain 13 columns with the rst column being the sample number starting at 1, and the

next 12 columns being the data in the order of lead I, II, III, avR, avL, avF, V1, V2, V3, V4, V5,

and V6. Sampling frequency is 500 Hz and is not encoded in the le. The values at each sample

are in units where 1 unit = 5 µV.

Prucka .txt
General Electric (GE) Prucka recording system formatted text les (extension .txt) use

format = 'prucka_txt' and load via the le load_ecg.m . This le format is generated when

exporting ECGs from the GE MacLab/Prucka electrophysiology recording system. These les

contain 12 columns with data in the order of lead I, II, III, avR, avL, avF, V1, V2, V3, V4, V5,

and V6. Sampling frequency is 997 Hz and is not encoded in the le. The le units are mV, so

no conversion is needed.

MUSE .xml
GE MUSE XML les (extension .xml) use format = 'muse_xml' and load via the le

load_musexml.m . Sampling frequency is usually 500 Hz and is encoded in the XML. Lead data

are stored in the relevant XML sections in base64 encoding in units where 1 unit = 4.88 µV
which is also encoded in the XML. Files that have not been deidentied or had identiers

removed include age and gender encoded in the XML.

161
Philips .xml
Philips XML les (extension .xml) use format = 'philips_xml' and load via the le

load_philipsxml.m . Sampling frequency is usually 500 Hz and is encoded in the XML. Lead

data are stored in the relevant XML sections in base64 encoding followed by LZW compression,

in units where 1 unit is usually 5 µV which is also encoded in the XML. Files that have not been

deidentied or had identiers removed include age and gender encoded in the XML. We have

found multiple versions of the Philips XML format; some include 10 seconds of data, while

others contain 11 seconds of data which includes a 10 second ECG signal followed by a 1 second

calibration signal which is cut o during loading.

HL7 .xml
HL7 XML les (extension .xml) use format = 'hl7_xml' and load via the le load_hl7xml.m .
Sampling frequency, units per mV, and leads are all encoded within the XML le. Details of the

HL7 format standards can be found at

https://www.amps-llc.com/uploads/2017-12-7/aECG_Implementation_Guide.pdf [ ? ].

DICOM .dcm
DICOM les (extension .dcm) use format = 'DICOM' and load via the le load_dicom.m .
Sampling frequency, units per mV, and leads are all encoded in the DICOM le. Details of the

DICOM format standards can be found at

https://www.dicomstandard.org/News-dir/ftsup/docs/sups/sup30.pdf.
Note: load_dicom.m requires the MATLAB Image Processing Toolbox. If this toolbox is not

available you will need to write your own function to load DICOM les.

ISHNE .ecg
International Society for Holter and Noninvasive Electrocardiology (ISHNE) les (extension .ecg)

use format = 'ISHNE' and load via the le load_ISHNE.m . Sampling rate, signal resolution, and

lead data are all encoded in the le. Details of the format can be found at

http://thew-project.org/papers/Badilini.ISHNE.Holter.Standard.pdf.

GE .mrq
GE Marquee ASCII les (extension .mrq) use format = 'mrq_ascii' and load via the le

load_mrq.m . Sampling frequency is 500 Hz and is not encoded in the le. Units are in µV.

162
Unformatted .csv
Unformatted comma separated value les (extension .csv) use format = 'generic_csv' and

load via the le load_generic_csv.m . These les contain 12 columns with data in the order of

lead I, II, III, avR, avL, avF, V1, V2, V3, V4, V5, and V6. Sampling frequency and units are not

encoded in the le and must be specied in ECG12.m after loading.

Cardiosoft .xml
General Electric (GE) Cardiosoft version 6 XML les (extension .xml) use

format = 'cardiosoft_xml' and load via the le load_cardiosoftxml.m . Sampling frequency

is usually 500 Hz and is encoded in the XML. Lead data are stored in the relevant XML sections

in units where 1 unit = 5 µV which is also encoded in the XML. Files that have not been

deidentied or had identiers removed include age and gender encoded in the XML.

163
24 Result Class Variables

Variables and their denitions for the 3 results classes are presented here. Detailed mathematical

explanations and associated equations are available in the Methods Manuscript.

24.1 VCG Morphology Class ( VCG_Morphology.m )


Variable Description Units
TCRT Total Cosine R to T (range 0 - 1) 

TCRT_angle Angle from TCRT = acos(TCRT) deg

qrsloop_residual SVD variance from tting QRS loop to a plane (0 = perfect t) = qrs_S32 

qrsloop_rmse RMSE for t of QRS loop to best t plane (0 = perfect t) mV

qrsloop_roundness QRS loop roundness. 1 = perfect circle, larger values are increasingly elliptical = qrs_S1/qrs_S2 

qrsloop_area Area of QRS loop mV

qrsloop_perimeter Length of QRS loop projected into best t plane mV2

tloop_residual SVD variance from tting T loop to a plane (0 = perfect t) = t_S32 

tloop_rmse RMSE for t of T loop to best t plane (0 = perfect t) mV

tloop_roundness T loop roundness. 1 = perfect circle, larger values are increasingly elliptical = t_S1/t_S2 

tloop_area Area of T loop mV

tloop_perimeter Length of T loop projected into best t plane mV2

qrs_loop_normal Unit vector normal to best t QRS loop plane 

t_loop_normal Unit vector normal to best t T loop plane 

qrst_dihedral_ang Dihedral angle between best t QRS loop and T loop planes deg

qrs_S1 1st singular value of QRS loop 

qrs_S2 2nd singular value of QRS loop 

qrs_S3 3rd singular value of QRS loop 

t_S1 1st singular value of T loop 

t_S2 2nd singular value of T loop 

t_S3 3rd singular value of T loop 

qrs_var_s1_total % of total variance made up by 1st QRS singular value %

qrs_var_s2_total % of total variance made up by 2nd QRS singular value %

qrs_var_s3_total % of total variance made up by 3rd QRS singular value %

t_var_s1_total % of total variance made up by 1st T singular value %

t_var_s2_total % of total variance made up by 2nd T singular value %

t_var_s3_total % of total variance made up by 3rd T singular value %

164
24.2 VCG Calculation Class ( VCG_Calc.m )
Variable Description Units
qrs_int QRS duration ms

qt_int QT interval ms

svg_x X component of SVG = XQ_area + XT_area mV·ms

svg_y Y component of SVG = YQ_area + YT_area mV·ms

svg_z Z component of SVG = ZQ_area + ZT_area mV·ms

sai_x Area under the absolute value of the median X QRST complex mV·ms

sai_y Area under the absolute value of the median Y QRST complex mV·ms

sai_z Area under the absolute value of the median Z QRST complex mV·ms

sai_qrst SAI QRST = sai_x + sai_y + sai_z mV·ms

sai_vm Area under the absolute value of the median VM QRST complex mV·ms

q_peak_mag Magnitude of peak QRS vector mV

q_peak_az Azimuth of peak QRS vector deg

q_peak_el Elevation of peak QRS vector deg

t_peak_mag Magnitude of peak T wave vector mV

t_peak_az Azimuth of peak T wave vector deg

t_peak_el Elevation of peak T wave vector deg

svg_peak_mag Magnitude of the sum of peak QRS and peak T vectors (peak SVG) mV

svg_peak_az Azimuth of the peak SVG vector deg

svg_peak_el Elevation of the peak SVG vector deg

q_area_mag Magnitude of QRS area vector ([XQ_area, YQ_area, ZQ_area]) mV·ms

q_area_az Azimuth of QRS area vector deg

q_area_el Elevation of QRS area vector deg

t_area_mag Magnitude of T-wave area vector [XT_area, YT_area, ZT_area] mV·ms

t_area_az Azimuth of T-wave area vector deg

t_area_el Elevation of T-wave area vector deg

svg_area_mag Magnitude of the SVG vector [svg_x, svg_z, svg_z] mV·ms

svg_area_az Azimuth of the SVG vector deg

svg_area_el Elevation of the SVG vector deg

qrst_angle_area Area (mean) QRST angle: 3D angle between area QRS and area T wave vectors deg

qrst_angle_peak Peak QRST angle: 3D angle between peak QRS and peak T wave vectors deg

qrst_angle_peak_frontal Projection of area QRST angle into frontal plane deg

qrst_angle_area_frontal Projection of peak QRST angle into frontal plane deg

XQ_area Area under median X QRS complex mV·ms

YQ_area Area under median Y QRS complex mV·ms

ZQ_area Area under median Z QRS complex mV·ms

XT_area Area under median X T wave mV·ms

YT_area Area under median Y T wave mV·ms

ZT_area Area under median Z T wave mV·ms

165
Variable Description Units
XQ_peak Value of median X QRS complex at time of maximum distance from origin mV

YQ_peak Value of median Y QRS complex at time of maximum distance from origin mV

ZQ_peak Value of median Z QRS complex at time of maximum distance from origin mV

XT_peak Value of median X T wave at time of maximum distance from origin mV

YT_peak Value of median Y T wave at time of maximum distance from origin mV

ZT_peak Value of median Z T wave at time of maximum distance from origin mV

speed_max Maximum speed across the entire VCG loop mV/ms

speed_min Minimum speed across the entire VCG loop mV/ms

speed_med Median speed across the entire VCG loop mV/ms

time_speed_max Time after QRS onset of maximum VCG speed ms

time_speed_min Time after QRS onset of minimum VCG speed ms

speed_qrs_max Maximum speed across the QRS VCG loop mV/ms

speed_qrs_min Minimum speed across the QRS VCG loop mV/ms

speed_qrs_med Median speed across the QRS VCG loop mV/ms

time_speed_qrs_max Time after QRS onset of maximum QRS speed ms

time_speed_qrs_min Time after QRS onset of minimum QRS speed ms

speed_t_max Maximum speed across the T wave loop mV/ms

speed_t_min Minimum speed across the T wave loop mV/ms

speed_t_med Median speed across the T wave loop mV/ms

time_speed_t_max Time after QRS onset of maximum T-wave speed ms

time_speed_t_min Time after QRS onset of minimum T-wave speed ms

qrst_distance_area Distance between the area QRS and area T vectors mV

qrst_distance_peak Distance between the area QRS and area T vectors mV

vcg_length_qrs Length of QRS VCG loop mV

vcg_length_t Length of T wave VCG loop mV

vcg_length_qrst Length of QRST VCG loop = vcg_length_qrs + vcg_length_t mV

vm_tpeak_time Time after QRS onset of peak of median VM Twave ms

vm_tpeak_tend_abs_diff Time dierence between T wave peak and T wave end in median VM lead ms

vm_tpeak_tend_ratio Ratio between time of T wave peak and time of T wave end in median VM lead 

166
24.3 Lead Morphology Class ( Lead_Morphology.m )
[lead] refers to any of the 16 leads (L1, L2, L3, avR, avL, avF, V1-V6, X, Y, Z, VM)
Variable Description Units
[lead]_r_wave Magnitude of R wave on median beat of [lead] mV

[lead]_s_wave Magnitude of S wave on median beat of [lead] mV

[lead]_rs_wave Magnitude of entire QRS complex = [lead]_r_wave + abs([lead]_s_wave mV

[lead]_rs_ratio Ratio of R wave to magnitude of entire QRS complex = [lead]_r_wave / [lead]_rs_wave 

[lead]_sr_ratio Ratio of S wave to magnitude of entire QRS complex = [lead]_s_wave / [lead]_rs_wave 

[lead]_t_max Maximum magnitude of T wave in [lead] mV

[lead]_t_max_loc Timing of T wave maximum (after QRS onset) in [lead] ms

[lead]_qrs_area Area of [lead] median beat QRS complex mV·ms

[lead]_t_area Area of [lead] median beat T wave mV·ms

[lead]_qrst_area Area of [lead] median beat full QRST complex mV·ms

cornell_lvh_mv Cornell LVH = V3_s_wave + avL_r_wave mV

sokolow_lvh_mv Sokolow-Lyon LVH = V1_s_wave + max(V5_r_wave, V6_r_wave) mV

qrs_frontal_axis Fontal plane QRS axis deg

167
25 Equations

Area Vectors:
Area vectors are obtained by taking the area under the relevant segment of the median VCG

(V(t) = [X(t), Y (t), Z(t)]) QRST complex using the trapezoidal rule:

Z Qoff Z Qoff Z Qoff Z Qoff 


QRSarea = V(t) dt = X(t) dt, Y (t) dt, Z(t) dt (1)
Qon Qon Qon Qon

Z Toff Z Toff Z Toff Z Toff 


Tarea = V(t) dt = X(t) dt, Y (t) dt, Z(t) dt (2)
Qoff Qoff Qoff Qoff

Peak Vectors:
Peak vectors are obtained by taking the value of relevant segment of V at the time point which

is of maximum distance from the origin:

QRSpeak = [X(tQmax ), Y (tQmax ), Z(tQmax )] (3)

Tpeak = [X(tT max ), Y (tT max ), Z(tT max )] (4)

where tQmax is the time of max distance of the QRS loop from the origin, and tT max is the time

of max distance of the T loop from the origin. These times correspond to the maximum values of

the QRS complex and T wave in the VM lead, respectively.

Spatial Ventricular Gradient:


The Spatial Ventricular Gradient (SVG) is the vector created by the QRST integrals in X, Y,
and Z:
Z Toff Z Toff Z Toff Z Toff 
SVG = QRSarea + Tarea = V(t)dt = X(t) dt, Y (t) dt, Z(t) dt (5)
Qon Qon Qon Qon

Vector Magnitude:
Vector magnitude (VM) is dened as the Euclidean norm of the VCG:


VM = X2 + Y 2 + Z2 (6)

168
Azimuth Angle:
Azimuth is dened as the angle in the transverse (XZ) plane with negative angles pointing

anterior, and positive angles pointing posterior (see Figure 50). Azimuth can take values from 0

to ±180 degrees, with 0 degrees pointing to towards the left, and ±180 degrees pointing towards

the right.  
Z
azimuth = arctan (7)
X

Elevation Angle:
Elevation is dened as the angle up from pointing straight down towards the ground (see Figure
50). Values range from 0 to 180 degrees, with 0 degrees pointing towards the feet and 180

degrees pointing towards the head.

 
Y
elevation = arccos √ (8)
X2 + Z2

Absolute Integrals:
The sum absolute integral (SAI) is dened as the area under the absolute value of the QRST

complex:
Z T off
SAIi = |Vi (t)| dt for i = X, Y, Z, or VM (9)
Qon

SAI QRST is dened as:

Z T off Z T off Z T off


SAI QRST = SAIx + SAIy + SAIz = |X(t)| dt + |Y (t)| dt + |Z(t)| dt (10)
Qon Qon Qon

QRST Angles:
The spatial QRST angle is the 3-dimensional angle between QRS and T vectors:

 
QRS · T
QRST Angle = arccos (11)
|QRS| |T|

where the peak QRST angle uses QRSpeak and Tpeak , and the area QRST angle (also known as

mean QRST angle) uses QRSarea and Tarea .

169
Total Cosine R to T (TCRT):
TCRT was calculated as previously described using singular value decomposition [15].

VCG Loop Length:


Loop length is calculated as the sum of distances covered as the VCG loop increments by each

sample For example, QRS loop length is calculated as:

Qo−1
X p
(Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 (12)
i=Qon

and T loop length is calculated as:

To−1
X p
(Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 (13)
i=Qo

VCG Loop Speed:


The instantaneous speed of the QRS or T loops (vi ) in mV/s for a VCG with frequency f is

calculated as the distance traveled in a sample of time:

p
vi = (Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 / ∆t where ∆t = 1000/f (14)

Left Ventricular Hypertrophy (LVH):


LVH metrics are calculated as previously described: The Cornell Voltage is calculated as the sum

of the S wave in lead V3 + the R wave in lead aVL [16]. The Sokolow-Lyon LVH criteria is

calculated as the sum of the S wave in lead V1 and the maximum of the R wave in either lead

V5 or V6 [17].

QRS Electrical Axis:


The ECG electrical axis (EA ) in the frontal plane is calculated as:

 
2F
EA = arctan √ (15)
3I

170
where F is the R wave - S wave in the lead aVF median beat, I is the R wave - S wave in the

lead I median beat, and arctan is the 2-argument arctangent (results are −180 deg to +180 deg)
to assign the positive and negative values correctly based on established conventions. Notably,

the factor of 2/ 3 is included to account for variations in signal amplitude when calculating the

electrical axis using a combination of a bipolar ECG lead (Lead I) and an augmented unipolar

lead (aVF). See [18] for further information.

VCG Loop Morphology and Singular Value Decomposition:


The singular value decomposition (SVD) is used to nd the best t planes for the QRS and T

loops separately. Let X ′ = X − cx , Y ′ = Y − cy , and Z ′ = Z − cz where the centroid

c = (cx , cy , cz ) is the mean QRS or T vector. Then let the matrix M′ have the

centroid-subtracted leads as columns. The SVD of M′ is:

M′ = USVT (16)

After SVD, unit vectors that span the best t plane for the VCG loop are given by the columns

of V.

The 3 singular values along the diagonal of matrix S, when squared, give the proportion of
2
mean-squared error or variance (σ ) in the direction of the 3 corresponding basis vectors in

matrix V:

   
S1 0 0 S12 0 0
   
S=
 0 S2 0 
 σ2 = 
 0 S 2
2 0 
 (17)

0 0 S3 0 0 S32

The columns are arranged such that S1 > S2 > S3 . Assuming that the VCG loop is

approximately planar, the third column of matrix V is normal to the best t plane; let this

vector be denoted by n. Note that if the the VCG loop is perfectly coplanar, then S3 = 0. The

major and minor axes of the VCG loop are then given by the rst and second columns of V,
respectively.

171
VCG Loop Coplanarity:
The degree of VCG loop coplanarity is assessed in 2 ways. First, the mean standard error (MSE)
2
in the direction normal to the best t plane (S3 ) is obtained from squaring the 3rd singular value
2
as noted above. If S3 = 0 then all points in the loop are coplanar. Coplanarity is also assessed

by calculating RMSE for points in the VCG loop compared to the points projected onto the best

t plane:

For a given point in the QRS or T loops s = [sx , sy , sz ] let s′ = s − c. Then the projection s′proj
relative to the centroid c onto the best-t plane is found by subtracting out the component of

the vector in the direction of the normal vector n dened above:

s′ proj = s′ − (s′ · n)n (18)

The contribution to the RMSE is then the square root of the mean distance between

corresponding points s and sproj . Using this metric, if all points are coplanar, RMSE = 0.

VCG Loop Dihedral Angle:


VCG loop dihedral angle is dened as the 3-dimensional angle between the unit normal vectors

that dene the QRS loop best t plane (NQRS ) and the T loop best t plane (NT ). By

convention, the dihedral angle is an acute angle:

Dihedral Angle = arccos(|NQRS · NT |) (19)

VCG Loop Roundness:


Assuming that the MSE in the direction normal to the best t plane should be relatively small

compared to the MSE in the plane itself, the roundness" (R) of the VCG loop is dened as the

ratio of the largest to second largest singular values:

R = S1 /S2 (20)

If R=1 the VCG loop is a perfect circle, and as the value of R increases above 1 the loop is

more oval or oblong.

172
VCG Loop Perimeter:
QRS and T loop perimeter are calculated as the length of the QRS or T loop projected into the

best t plane with the set of points dened as Mproj , and is analogous to the QRS and T loop

length which is the length of the loop without projection (set of points dened as M ). The

perimeter of Mproj is calculated using Matlab polyshapes.

VCG Loop Area:


QRS and T loop area are calculated as the area of the QRS or T loop projected into the best t

plane with the set of points dened as Mproj . The area of Mproj is calculated using Matlab

polyshapes.

173
26 Annotation Parameter Links with GUI

This section contains the links between parameters in Annoparams.m and where the parameter
value is editable in the BRAVHEART GUI.

ˆ maxBPM ←→ GUI item 1.6 textbox


ˆ pkthresh ←→ GUI item 1.7 textbox
ˆ lowpass ←→ GUI item 1.3 checkbox
ˆ highpass ←→ GUI item 1.4 checkbox
ˆ wavelet_level_lowpass ←→ GUI item 1.3 dropdown
ˆ wavelet_level_highpass ←→ GUI item 1.4 dropdown
ˆ wavelet_name_lowpass ←→ GUI item 1.3 dropdown
ˆ wavelet_name_highpass ←→ GUI item 1.4 dropdown
ˆ baseline_correct_flag ←→ GUI item 1.5 checkbox
ˆ transform_matrix_str ←→ GUI item 1.2 dropdown
ˆ baseline_flag ←→ GUI item 3.12 dropdown
ˆ origin_flag ←→ GUI item 3.13 dropdown
ˆ autoMF ←→ GUI item 3.1 checkbox
ˆ autoMF_thresh ←→ GUI item 3.1 textbox
ˆ MF_width ←→ NA
ˆ QRwidth ←→ GUI item 3.2 textbox
ˆ RSwidth ←→ GUI item 3.2 textbox
ˆ STstart ←→ GUI item 3.2 textbox
ˆ STend ←→ GUI item 3.2 textbox
ˆ spike_removal ←→ GUI item 1.8 checkbox
ˆ pacer_spike_width ←→ GUI item 1.8 textbox
ˆ pacer_mf ←→ NA
ˆ pacer_thresh ←→ GUI item 1.8 textbox
ˆ align_flag ←→ GUI item 3.4 dropdown
ˆ cov_mf ←→ NA
ˆ cov_thresh ←→ NA
ˆ shiftq ←→ NA
ˆ shiftt ←→ NA
ˆ Tendstr ←→ GUI item 3.3 dropdown
ˆ median_reanno_method ←→ GUI item 3.15 dropdown
ˆ outlier_removal ←→ GUI item 9.4 checkbox
ˆ modz_cutoff ←→ GUI item 9.3 textbox
ˆ pvc_removal ←→ GUI item 9.10 checkbox
ˆ pvcthresh ←→ GUI item 9.5 textbod
ˆ rmse_pvcthresh ←→ GUI item 9.6 textbox
ˆ keep_pvc ←→ GUI item 9.7 radio button
ˆ blanking_samples ←→ GUI item 6.5.1 textbox
ˆ debug ←→ GUI item 3.10 checkbox

NA = Parameter cannot be adjustsed via GUI

174
27 Testing Framework

It is important to be certain that any changes to the BRAVEHEART source code have not

broken or otherwise adversely aected the main functions of the software, including ECG

processing/ltering, annotation, PVC/outlier removal, manual beat removal/editing, and

calculations. In order to ensure that any changes have not inadvertently aected critical parts of

the BRAVEHEART source code, we have provided a testing framework that can be used to

validate any changes that are made. The testing framework is located in test_braveheart.m .
This is a very long le that contains a multitude of tests designed to determine if there are any

errors in any parts of the BRAVEHEART ECG/VCG processing pipeline.

The testing framework can be run by opening the test_braveheart.m le and clicking the Run

Tests icon in the Editor toolbar, or by typing runtests( "test_braveheart" ) in the MATLAB

command line. The testing functions will run and at the end you will get a report about how

many functions passed or failed. If the software is functioning properly, all tests should pass. If a

test fails, MATLAB provides information on the error that can be used to troubleshoot.

If you make changes to some of the BRAVEHEART core functions such as signal ltering or

annotation, it is possible that the tests may fail even though BRAVEHEART is functioning

properly within the parameters of this new code. This is because functions like ltering and

annotation aect all downstream processing and measurements. The testing framework assumes

that the current ltering and annotation functions are being used, and the measurements that
are checked as part of testing will therefore generate errors if alternate ltering/annotation

functions are used. If such changes are made, the testing framework expected outputs can be

updated.

The testing framework will not automatically update if new parameters are added to the

BRAVEHEART results classes (see Chapter 10), but adding new parameters will not break the
testing framework.

The BRAVEHEART GitHub automatically runs the testing framework for all commits to ensure

that the most up-to-date version of code in the Github repository will function accurately and

without errors.

175
28 Troubleshooting/Help/FAQs

28.1 The GUI is Cut O/Missing Some Features


If the GUI is missing some features when compared to Figure 1 when you rst open the
BRAVEHEART GUI, the most likely cause is that your monitor resolution is too low. Adjust

your monitor resolution so that it is atleast 1920 x 1080, and then reload the GUI. Note that

there are minor dierences in the appearance of GUI elements depending on your operating

system.

If your screen resolution is 1920 x 1080 or greater and the GUI is still not fully displayed, it is

likely that your computer display settings have some form of scaling turned on that increases the

size of text etc but also eectively reduces the screen resolution.

Ease of Access settings by pressing the


To disable screen scaling: Windows 10: Go to the

Windows key + U. Under Make everything bigger on the Display tab, change to 100%.

Windows 11: Open Settings and then Display. Under Scale & layout, expand the Scale
menu and change to 100%.

Mac OS: Open System Preferences and then Display. Choose Scaled Resolution and then
More Space.

28.2 My ECG Won't Load


If an ECG won't load, rst check that the correct le format is selected, and try to load another

ECG of the same format to ensure that the format is set correctly.

The most common reason for an ECG not loading is signicant noise or artifact that interferes

with QRS peak localization (because QRS peak localization depends on thresholding the full VM

signal, large, focal artifacts can result in almost all of the ECG being below the percentile value

set by pkthresh ). By enabling V Safe Mode (see Chapter 28.3 below) in the GUI
Utilities section (GUI item 6.6.7), after the ECG signals are loaded you can view the
12-lead ECG by clicking on the 12L ECG (GUI item 7.1). This may reveal a large area of
noise/artifact, or signicant baseline wander.

The rst thing to try is to decrease the value of pkthresh by lowering the value in the `Peak

Threshold' textbox in GUI section 1.6 to a very low value around 10. In fact, if the ECG throws
an error but loads in Safe Mode (GUI item 6.6.7), without changing any other settings, the

176
value of pkthresh is likely the cause of the error, as Safe Mode also automatically lowers

pkthresh to 10 in addition to disabling processing that occurs after ltering. If this resolves the

error, you may need to increase pkthresh somewhat to avoid overcalling QRS peaks. Use of the

Threshold button (GUI item 1.15  see Chapter 15.1 and Figure 22) can help visualize what
the QRS peak detector is doing.

If adjusting pkthresh does not resolve the issue, next try to lower the the high-pass ltering

level (GUI item 1.4) by 1-2 levels. This often helps remove any low-frequency wander by

increasing the high-pass lter cuto frequency. However, lowering the high-pass ltering level

(and therefore increasing the high-pass lter cuto frequency) too much can adversely aect

measurements by distorting the QRST complex. If ltering is removing frequencies between

0.5-40 Hz there will be some concern that the QRST complex may be distorted by ltering [3].

If there is a focal section of the ECG that is causing errors, another option is to load the ECG in

Safe Mode and then use the ECG Splitter button/function in the Utilities section (GUI

item 6.6.5). The abnormal area of the ECG can be cut out and the remainder of the ECG

without the severe artifact can be analyzed. It should be noted that using a shortened ECG will

likely aect the measured values slightly because baseline correction depends on the calculated

HR.

28.3 Safe Mode


Safe mode can help in cases where an ECG will not load. As noted above, this is often due to

signicant noise and artifact that cause problems with initial R peak detection. Clicking `Safe

Mode' in GUI item 6.6.7 disables all processing after ltering and decreases the value of
pkthresh to 10 to increase the chances that the ECG can load without an error. This can allow

you to visualize the ECG/VCG using GUI section 7.

28.4 The ECG Loads but I get an Error When Press Calculate
This is usually due to an issue with rst pass or median beat annotation. Attempt to

troubleshoot this issue in the same was as shown above when dealing with ECGs that won't

load. Checking the `Debug' gures (see Chapter 28.7) can also help.

28.5 A Measured Parameter Returns as NaN


This error is usually due to noise/artifact which can be dealt with as noted above. The other

reason that this may occur is if a median beat ducial point was not found. This most

177
commonly occurs if the median beat annotater did not nd a Toff . This can occur if the ECG is

very noisy, or in good quality ECGs if the QT interval is long or if the QRS morphology is

atypical to the point where the QRS width and/or QT search windows are too short. If this

occurs, using the V Debug option (see Chapter 28.7) can help troubleshoot, and often
adjusting the annotation parameters will allow the annotater to nd all ducial points. In rare

occasions when the neural network median beat annotater fails but the ECG quality is

reasonable, switching median_reanno_method from 'NNet' to 'Std' may be useful. The overall

accuracy of the 'Std' median beat annotater is signicantly lower than the 'NNet' median beat

annotater, especially for low amplitude T waves or atypical QRST morphologies.

28.6 Error Logs


When using the GUI, under Utilities there is an option for V Error Logging (GUI item

6.6.3). If this is checked, loading an ECG will generate a text le called

braveheart_error_log_<date_time>.txt which includes information on the le, annotations

parameters, and any errors that are generated. Note that logging is started during ECG loading,

so to start logging errors you will need to load/reload the ECG after checking V Error Logging .
Starting in v1.1.0, when running via executable, the MATLAB console is logged to a le

logfile.txt . We are happy to assist with interpretation of error logs if needed - contact us at

braveheart.ecg@gmail.com.

28.7 Debugging Annotation Figures


The V Debug checkbox (GUI item 4.9) enables graphical display of both rst pass and median
beat annotation, and can be helpful when troubleshooting ECGs that cause errors or do not

annotate properly. Debug gures can help determine how to adjust annotation parameters to

allow the ECG to successfully process. When V Debug is checked and Calculate is pressed,

gures showing annotation windows for rst pass annotation and neural network predicted

ducial point probabilities are displayed. See Chapter 18, Chapter 18.3, Figure 30, and
Figure 49 for further details. These gures can often help you determine if adjustment of

annotation parameters will resolve any errors.

28.8 How should I cite use of the BRAVEHEART software?


Please cite our Open Access methods manuscript [1] which is currently available in Computer
Methods and Programs in Biomedicine :

Hans F. Stabenau and Jonathan W. Waks, BRAVEHEART: Open-source software for automated

178
electrocardiographic and vectorcardiographic analysis. Computer Methods and Programs in
Biomedicine 2023 Dec:242:107798; DOI: https://doi.org/10.1016/j.cmpb.2023.107798.

179
28.9 Frequently Asked Questions
1. Can BRAVEHEART use scanned ECGs in .jpg or .pdf format?
No  BRAVEHEART requires ECG data to be in some raw, digitized format. The formats

that are included with BRAVEHEART are described in Chapter 23, and new formats can
be added as needed as described in Chapter 8. Construction of VCGs also requires

simultaneous recording of the 8 independent ECGs leads (I, II, V1V6), but if you have

printed ECGs of decent quality that have simultaneous rhythm strips of at least the 8

independent leads, consider using a program to digitize your ECG [19] and then import the

digitized version into BRAVEHEART.

2. Why are the high-pass and low-pass wavelet levels not automatically adjusting
when I run BRAVEHEART via the command line like they do when I use the GUI?
The wavelet levels only adjust based on the ECG sampling frequency when using the GUI.

When using the command line version of BRAVEHEART ( braveheart_batch.m ) you must

set the high- and low-pass wavelet levels manually in Annoparams.m . Details about how to

adjust the wavelet levels to adjust the ltering cuto frequencies are available in Chapter
7 and Table 1.

3. Can BRAVEHEART annotate or measure parameters from P waves?


Not currently, although we are in the process of adding P wave annotation which will allow

assessment of P wave parameters. P wave annotation/processing is more complex than

QRST annotation due to the fact that a cardiac cycle always has a single QRST complex

in a predictable order, but atrial activity can be completely dissociated from ventricular

activity (or absent completely) and, in general, P waves are lower amplitude signals with a

lower signal to noise ratio.

4. I don't have MATLAB, but I need to add a new ECG format, transformation
matrix, or parameter. What can I do?
Contact us at braveheart.ecg@gmail.com and we will try to assist you.

5. I found a bug/error. How can I tell you whats wrong?


Contact us at braveheart.ecg@gmail.com with as many details as possible (and possibly

an error log  see Chapter 28.6) and we will try to resolve the issue.

6. How can I change the default parameters so I don't have to adjust them each
time I use the program?
The default parameters for use in both the command line and GUI versions of

180
BRAVEHEART are controlled by setting values within Annoparams.m when running via

MATLAB, or Annoparams.csv when running via executable. Edit and save the values in

these les to control the default values that appear when the GUI is opened or the

command line version is run (see Chapter 6). NOTE: there are some parts of the GUI

that operate based on the specic ECG format chosen (see Chapter 8). This includes

choosing specic wavelet decomposition levels for specic ECG formats based on ECG

sampling frequency. Once the GUI is loaded, choosing a new ECG format may adjust the

denoising/ltering settings. If these changes based on specic ECG formats are causing

issues, you can edit them in the le ecg_source_gui.m . These settings are ONLY used

with the GUI.

7. I have an ECG in a format that BRAVEHEART should be able to read, but it's
not working. Whats wrong?
It is possible that your le is a variant/dierent version of the formats that can be read by

BRAVEHEART, as unfortunately we were not able to test every possible version of each

included format. You can look through the code in the appropriate load module .m le (see

Chapter 23) to see if you can nd the issue and modify the code. If you can't edit the

code or are having issues, please email us at braveheart.ecg@gmail.com and we can help

troubleshoot. Please send us a de-identied copy of the le that is not working if possible.

181
29 External Code/Files

BRAVEHEART uses some existing open-source code which includes:

ˆ draggable  Francois Bouard (2023)


https://www.mathworks.com/matlabcentral/fileexchange/4179-draggable,
MATLAB Central File Exchange. Retrieved February 5, 2020.

ˆ LZW Compression Algorithm  Giuseppe Ridinò (2023)


https://www.mathworks.com/matlabcentral/fileexchange/4899-lzw-compression-algorithm,
MATLAB Central File Exchange. Retrieved June 1, 2022.

ˆ Sierra ECG Tools  David D. Salcido and Christopher A. Watford (2014).


https://github.com/sixlettervariables/sierra-ecg-tools,
Retrieved June 1, 2022.

182
30 References

[1] H. F. Stabenau and J. W. Waks. Braveheart: Open-source software for automated electrocardiographic and
vectorcardiographic analysis. Comput Methods Programs Biomed, 2023, In Press.

[2] H. F. Stabenau, A. Sau, D. B. Kramer, N. S. Peters, F. S. Ng, and J. W. Waks. Limits of the spatial
ventricular gradient and qrst angles in patients with normal electrocardiograms and no known cardiovascular
disease stratied by age, sex, and race. J Cardiovasc Electrophysiol, 2023, In Press.

[3] N. V. Thakor, J. G. Webster, and W. J. Tompkins. Estimation of QRS complex power spectra for design of
a QRS lter. IEEE Trans Biomed Eng, 31(11):702706, Nov 1984.

[4] J. A. Kors, G. van Herpen, A. C. Sittig, and J. H. van Bemmel. Reconstruction of the Frank
vectorcardiogram from standard electrocardiographic leads: diagnostic comparison of dierent methods. Eur
Heart J, 11(12):10831092, Dec 1990.

[5] G. E. Dower, H. B. Machado, and J. A. Osborne. On deriving the electrocardiogram from vectoradiographic
leads. Clin Cardiol, 3(2):8795, Apr 1980.

[6] L. Johannesen, J. Vicente, M. Hosseini, and D. G. Strauss. Automated Algorithm for J-Tpeak and
Tpeak-Tend Assessment of Drug-Induced Proarrhythmia Risk. PLoS One, 11(12):e0166925, 2016.

[7] B. Iglewicz and D. Hoaglin. The ASQC Basic References in Quality Control: Statistical Techniques, chapter
Volume 16: How to Detect and Handle Outliers. 1993.

[8] P. S. Addison. Wavelet transforms and the ECG: a review. Physiol Meas, 26(5):R155199, Oct 2005.

[9] P. Kligeld, L. S. Gettes, J. J. Bailey, R. Childers, B. J. Deal, E. W. Hancock, G. van Herpen, J. A. Kors,
P. Macfarlane, D. M. Mirvis, O. Pahlm, P. Rautaharju, and G. S. Wagner. Recommendations for the
standardization and interpretation of the electrocardiogram. Circulation, 115(10):13061324, 2007.

[10] H. F. Stabenau, C. Shen, L. G. Tereshchenko, and J. W. Waks. Changes in global electrical heterogeneity
associated with dofetilide, quinidine, ranolazine, and verapamil. Heart Rhythm, 17(3):460467, 03 2020.

[11] Recommendations for measurement standards in quantitative electrocardiography. The CSE Working Party.
Eur Heart J, 6(10):815825, Oct 1985.

[12] S. H. Zhou, E. D. Helfenbein, J. M. Lindauer, R. E. Gregg, and D. Q. Feild. Philips QT interval


measurement algorithms for diagnostic, ambulatory, and patient monitoring ECG applications. Ann
Noninvasive Electrocardiol, 14 Suppl 1:38, Jan 2009.

[13] J. L. Willems, P. Arnaud, J. H. van Bemmel, P. J. Bourdillon, C. Brohet, S. Dalla Volta, J. D. Andersen,
R. Degani, B. Denis, and M. Demeester. Assessment of the performance of electrocardiographic computer
programs with the use of a reference data base. Circulation, 71(3):523534, Mar 1985.

[14] C. Zywietz and D. Celikag. Testing results and derivation of minimum performance criteria for computerized
ecg-analysis. In [1991] Proceedings Computers in Cardiology, pages 97100, 1991.

[15] B. Acar, G. Yi, K. Hnatkova, and M. Malik. Spatial, temporal and wavefront direction characteristics of
12-lead T-wave morphology. Med Biol Eng Comput, 37(5):574584, Sep 1999.

[16] P. M. Okin, M. J. Roman, R. B. Devereux, and P. Kligeld. Electrocardiographic identication of increased


left ventricular mass by simple voltage-duration products. Journal of the American College of Cardiology,
25(2):417423, 1995.

183
[17] M. Sokolow and T. P. Lyon. The ventricular complex in left ventricular hypertrophy as obtained by unipolar
precordial and limb leads. American Heart Journal, 37(2):161186, 1949.

[18] D. Novosel, G. Noll, and T. F. scher. Corrected formula for the calculation of the electrical heart axis. Croat
Med J, 40(1):7779, Mar 1999.

[19] H. Wu, K. H. K. Patel, X. Li, B. Zhang, C. Galazis, N. Bajaj, A. Sau, X. Shi, L. Sun, Y. Tao, H. Al-Qaysi,
L. Tarusan, N. Yasmin, N. Grewal, G. Kapoor, J. W. Waks, D. B. Kramer, N. S. Peters, and F. S. Ng. A
fully-automated paper ECG digitisation algorithm using deep learning. Sci Rep, 12(1):20963, Dec 2022.

184

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy