Braveheart Userguide
Braveheart Userguide
Braveheart Userguide
User Guide
Software Version 1.1.2
http://www.github.com/BIVectors/BRAVEHEART
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
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
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
4
1 Introduction
(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
code, and executables for Windows and Mac are available under version 3 of the General Public
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,
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
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.
concerns.
5
2 Version History/Changelog
v1.0.0 5/1/2023: Initial public release
Added error handling for selecting wavelet decomposition levels > max level.
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).
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).
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 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.
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.
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
http://www.github.com/BIVectors/BRAVEHEART.
Signal Processing
Deep Learning
Wavelet
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
To run the GUI version of BRAVEHEART run braveheart_gui from within MATLAB as
To run the command line version of BRAVEHEART run braveheart_batch() from within
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
hashes for their respective .zip les (where x.x.x is the release version) if you would like to
You must unzip/install the executable in a folder that has write access so that various les that
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
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
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:
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.
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.
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
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.
directory that has write access. You will see the 15 following les/folders:
disable Mac OS runtime protection for relevant les (see next paragraphs in this section).
Example ECGs Directory containing 4 example ECG les (see Chapter 5).
Download MATLAB Runtime - Mac 64 bit Link to download MATLAB Runtime.
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
Entering your system password is necessary because the script also whitelists
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:
If you prefer to not run the script, you will have to manually whitelist the .app and .sh les by
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.
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
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
using the standard ltering and annotation settings, and save the results to an external le.
16
The ` Initialize/Load ECG' section of the GUI controls loading ECG les, ltering, baseline
correction, and transformation into a VCG.
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
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
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
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
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
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
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
Click on the VCG Calculations button in the middle of the GUI which displays calculations from
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.
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).
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
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 `
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
At this point, the data can be exported as noted above in Example 1 ( Chapter 5.1).
removal.
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
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
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,
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
Re-enable pacemaker artifact removal by checking the V On checkbox, and then reload the
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.
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
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
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
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.
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
respective ducial points in the ` Beat Selection' text box and then click Add Beat in the
The new beat is added, a new median beat is created and annotated, and measurements are
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.
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
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
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
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
By choosing `Remove Native' in the radio button, note how the Remove PVCs button changes
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
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
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
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
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
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
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.
and made any manual edits, click the VCG Calculations button in the middle of the GUI as
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.
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
45
6 Annotation Parameters ( Annoparams.m )
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
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
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.
median_reanno_method = 'NNet'; % 'NNet' for neural network and 'Std' for standard annotations
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.
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
removes frequencies above a cuto frequency and helps remove high-frequency noise.
highpass | Integer 0 or 1
ltering removes frequencies below a cuto frequency and helps remove low-frequency
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
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
changed; this corresponds to a nominal low-pass ltering cuto of 125 Hz. See Chapter 7
for further details.
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
avoid removing frequencies contained within the QRST complex (0.5-40 Hz)[3]. The
ECG signal in samples (L) and is given as nmax = floor(log2 L). The BRAVEHEART GUI
changed; this corresponds to a nominal high-pass cuto frequency of 0.24 Hz. See Chapter
7 for further details.
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
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
baseline_correct_flag | Integer 0 or 1
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.
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.
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
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
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
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
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.
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.
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.
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
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.
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
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.
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.
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.
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.
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:
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.
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
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
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.
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
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.
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
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
keep_pvc | Integer 0 or 1
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
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
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.
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
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
Table 1: Denoising/ltering frequency cutos based on wavelet decomposition level (n) and ECG sampling fre-
quency of 500, 1000, and 2000 Hz.
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
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
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
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
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/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
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.
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
59
The Filtering button displays the original signals and the ltered and baseline corrected signals so
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
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:
... 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
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
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
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
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.
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
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
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,
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,
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.
If you are using the GUI version of BRAVEHEART, simply choose the new format from the
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
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
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
ecg_transform.m . The new transformation matrix will have to be added to this le.
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 ];
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
switch transform_matrix
case 'Dower'
M = dowermatrix();
case 'Kors'
M = korsmatrix();
case 'NewMatrix'
M = newmatrix();
otherwise
error('Unknown transform_matrix: %s', transform_matrix);
end
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
Annoparams.csv if you are using the compiled version) and assign the newly created
transformation_matrix_str = 'NewMatrix' ).
If you are using the GUI version of BRAVEHEART, simply choose the new format from the
67
68
10 Adding New ECG/VCG Parameters
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.
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
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.
69
10.1.1 VCG_Calc.m
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
Tend location (in samples) of T wave oset (Toff ) for the median beat
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:
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 .
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
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
10.1.2 Lead_Morphology.m
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
[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
10.1.3 VCG_Morphology.m
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
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
classdef VCG_Calc
%
properties (SetAccess=private)
% SVG
svg_x
svg_y
svg_z
% SAI
sai_x
sai_y
sai_z
...
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
...
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
classdef VCG_Calc
%
properties (SetAccess=private)
% SVG
svg_x
svg_y
svg_z
% SAI
sai_x
sai_y
sai_z
% New Measurement
newvar
...
We then insert the function which is used to calculate newvar into the methods section of
...
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
Chapter 24 lists the dierent parameters that are included in each of the results classes.
74
11 Adding New Denoising/Filtering
Chapter 7 which have many benets over conventional linear lters [1, 8]. However, if you have
Lines 153180 of ECG12.m (see Chapter 8 for further details on the ECG12 class) are devoted to
function within the VCG class because the ECG is ltered prior to transformation into a VCG.
...
[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
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
The outputs of the function include the 12 ltered leads, and a numeric variable
Our suggestion would be to NOT alter the output variable structure of the ecgfilter function
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
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.
final_lf_wavelet_lvl_min in the output to avoid breaking the GUI). In the interest of space
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
[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
78
12 Using the BRAVEHEART GUI
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
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
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.
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
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.
the ECG into a VCG, QRS peak detection, signal ltering, and pacemaker spike removal.
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
the Kors [4] and inverse Dower [5] transformation matrices. Additional transformation
3. Select and choose options for low-pass ltering. The V Wavelet Low Pass checkbox
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
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
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
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.
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
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
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
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
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
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
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
15. The Filtering button displays a gure that shows the eect of the selected ltering on the
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
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
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
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
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.
1. Select and set options for using automatic QRS width estimation during rst pass heuristic
the QRS search window for each beat individually rather than using a xed window as
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.
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
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
9. Checkbox to enable/disable debug gures for both rst pass and median beat annotation.
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
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
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
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
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.
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
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
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
5. Measures of ECG processing/annotation quality (see Chapter 16). The `Prob (%)' value
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
The `Counts' value reports the number of quality parameters that are outside of the bounds
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
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
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
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
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.
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
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
V Axes at Origin : When checked, this option moves axes labeling inside the 3D 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
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
3. The Animate button opens an animated gure of the VCG loop. The animation steps are in
4. The Orbit Camera opens a second toolbar that can be used to manipulate the camera for the
5. This section is used to rotate the 3D VCG without using the rotation tool (GUI item
95
6. This section is used to rotate the 3D VCG to common viewing angles.
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
7. The Refresh button reloads the VCG with the active VCG visualization options set in GUI
Section 6.2:
The VCG Calculations button displays results from the VCG_Calc results class and sets options
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
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
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.
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
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
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
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.
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.
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
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
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.
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
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
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
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
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,
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 Angle Info button displays a gure explaining the conventions used for angles
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.
This section of the GUI is used to display and save various ECG/VCG gures and 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
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
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
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
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
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
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
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
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
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
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.
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
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
7. Radio buttons that sets the value of keep_pvc in Annoparams.m . If `Remove Native' is
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
various gures that are displayed in the GUI. Click on an icon in the toolbar and then use in the
: Pan gure
: Rotate gure
: Zoom in on gure
: Print gure
111
13 Batch Processing ECGs with braveheart_batch.m
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
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
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
112
The parameters that can be set to control batch ECG processing include:
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:
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
113
parallel_proc | 0 or 1
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
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,
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
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
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
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
output le. Further details of the data included in the VCG Morphology results class can be
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.
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
115
To construct an Annoparams class simply call the Annoparams constructor without any inputs.
aps1 = Annoparams();
aps1.lowpass = 0;
aps1.pkthresh = 90;
aps1.STend = 55;
...
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
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
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
processed from the directory (1 row per ECG). If specic results classes are disabled (e.g.
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>/
Folder annotations_<timestamp>/
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
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
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
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
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.
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).
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
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
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
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 .
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
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
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').
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.
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
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
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),
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
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).
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
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 >
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
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:
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
Adding new variables to the quality agging can be done without too much diculty, although
which lists the ECGs which were agged and the reason for agging. The le contains columns
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
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
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.
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
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
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
.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
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
When performing batch ECG processing, checking the V Annos box in the GUI, or setting
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
`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
138
18 First Pass Annotation
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
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
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
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
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
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:
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
The NN included with BRAVEHEART is highly accurate when compared to board certied
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:
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
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.
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
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)
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)
PVC
0 1000 2000 3000 4000 5000
VM (mV)
PVC
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).
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 .
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
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.
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
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.
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:
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
majority of results contained in the Lead_Morphology results class. The lead morphology gure
151
Figure 43: Measurements on 16 median beats. Values are in mV.
`Step' textbox sets the number of samples that are advanced per frame.
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
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.
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
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
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
beat annotation that can help troubleshoot ECGs that are not processing to see if specic
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°
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
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
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
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
The following parameters have normal ranges which can be displayed in the GUI:
The BRAVEHEART GUI can extract age and sex from ECG formats that contain this data,
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
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
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
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
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
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
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
qrsloop_residual SVD variance from tting QRS loop to a plane (0 = perfect t) = qrs_S32
qrsloop_roundness QRS loop roundness. 1 = perfect circle, larger values are increasingly elliptical = qrs_S1/qrs_S2
tloop_residual SVD variance from tting T loop to a plane (0 = perfect t) = t_S32
tloop_roundness T loop roundness. 1 = perfect circle, larger values are increasingly elliptical = t_S1/t_S2
qrst_dihedral_ang Dihedral angle between best t QRS loop and T loop planes deg
164
24.2 VCG Calculation Class ( VCG_Calc.m )
Variable Description Units
qrs_int QRS duration ms
qt_int QT interval 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_vm Area under the absolute value of the median VM QRST complex mV·ms
svg_peak_mag Magnitude of the sum of peak QRS and peak T vectors (peak SVG) mV
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
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
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
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:
Peak Vectors:
Peak vectors are obtained by taking the value of relevant segment of V at the time point which
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
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
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
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
169
Total Cosine R to T (TCRT):
TCRT was calculated as previously described using singular value decomposition [15].
Qo−1
X p
(Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 (12)
i=Qon
To−1
X p
(Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 (13)
i=Qo
p
vi = (Xi+1 − Xi )2 + (Yi+1 − Yi )2 + (Zi+1 − Zi )2 / ∆t where ∆t = 1000/f (14)
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].
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
c = (cx , cy , cz ) is the mean QRS or T vector. Then let the matrix M′ have the
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 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.
that dene the QRS loop best t plane (NQRS ) and the T loop best t plane (NT ). By
compared to the MSE in the plane itself, the roundness" (R) of the VCG loop is dened as the
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
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
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.
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
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
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
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.
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.
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
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.
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
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.
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
6.6.3). If this is checked, loading an ECG will generate a text le called
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.
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
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
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.
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
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.
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
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
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.
[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.
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