Software Open Access
Heart Vector Origin Point Detection and TimeCoherent Median Beat Construction
Erick Andres Perez Alday , Larisa Tereshchenko
Published: May 25, 2021. Version: 1.0.0
When using this resource, please cite:
(show more options)
Perez Alday, E. A., & Tereshchenko, L. (2021). Heart Vector Origin Point Detection and TimeCoherent Median Beat Construction (version 1.0.0). PhysioNet. https://doi.org/10.13026/jfeg4820.
Please include the standard citation for PhysioNet:
(show more options)
Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. e215–e220.
Abstract
An appropriate selection of the heart vector origin point defines the ECG’s baseline, which then affects all subsequent ECG measurements. We introduce software capable of automatically identifying the heart vector origin point and constructing a timecoherent median beat. We define the heart vector electrocardiographic (VCG) origin point based on its electrophysiological and biophysical meaning: the electrically quiet, or isoelectric state of the heart when the heart vector does not move in 3D space. The electrically silent period is defined as the segment between the end of repolarization and the onset of Pwave (if present), or the beginning of the QRS complex.
The definition of the VCG origin point determines the definition of the vector magnitude ECG baseline. VectorMagnitude that is zeroed at the origin of the heart vector provides the most physiologically accurate cardiac beat. This is a fundamental step for any further global ECG and VCG measurements. Timecoherent median beat preserves the physiological sequence of cardiac activation and recovery. The timecoherent approach takes an easily detectable fiducial point (maximum dV/dt) as detected only on one ECG lead (e.g., X). Corresponding timepoints on two other leads (e.g., Y and Z) are taken regardless of their morphological features. Such an approach significantly reduces the chance of error and preserves the physiological sequence of cardiac activation and recovery. The algorithm requires an input of a 10second raw digital orthogonal ECG signal (XYZ leads).
Background
The ECG measurements are based on the lead theory which assumes that the heart is a dipole vector (heart vector) that is moving during the cardiac cycle in threedimensional (3D) space, forming vectorcardiographic (VCG) loops [1]. Projection of the heart vector movement on any ECG lead axis produces the waveform measured in that lead. The electrical origin of the heart vector has important electrophysiological and biophysical meaning, as it is defined by the isoelectric state of the heart [2]. The electrocardiographic method, developed by Einthoven and colleagues, quantifies the magnitude and direction of the resultant electromotive force produced by the heart at a given time instance during the cardiac cycle.
In 1938, Wilson and Johnston highlighted the importance of the heart vector origin point (see Figure 3 from [2]), which corresponds to the electrocardiographic baseline. Due to technological limitations in the 1930s, they were not able to define the origin point, and noted that “details are lost in the uniformly black area which surrounds the isoelectric point”.[2] Modern ECG signal resolution allows the characterization of its fine features. However, contemporary ECG standards ignore the VCG origin definition [3,4].
This algorithm defines the heart vector origin point and constructs a timecoherent global median beat. In a large (nearly 16,000 participants) study, we defined the origin point of the heart vector as the electrically silent portion of the cardiac cycle (isoelectric period) [5]. We showed that the physiologically meaningful definition of the heart vector’s origin point and timecoherent global XYZ median beat construction affected ECG measurements and improved predictive accuracy of ECG and VCG biomarkers of sudden cardiac death.
Software Description
We introduce software capable of automatically identifying the VCG origin point from a timecoherent global XYZ median beat. The VCG origin point is defined based on its electrophysiological and biophysical meaning: the electrically quiet, or isoelectric state of the heart when the heart vector does not move in 3D space. The electrically silent period is defined as the segment between the end of repolarization and the onset of Pwave (if present), or the beginning of the QRS complex. The definition of the VCG origin point determines the definition of the VM ECG baseline.
Algorithm to detect the VCG electrically quiet origin point:
Figures 1 and 2 provide an overview of the algorithm. Two time interval windows are identified to select an isoelectric segment in the TP segment. The first window (w_{1}) is dynamically calculated from the RR’ interval using the following equation (eq. 1):
The center of the window, T_{C}, also depended on the RR interval and the type of beat under investigation. Two cases are identified: (1) T_{C }= 260ms, if RR interval (RR_{int}) < 600 ms and median beat ≠ Supraventricular (S). T_{C }= 320ms, for any other case: RR_{int} ≥ 600 ms for any type of beat or RR_{int} < 600 but median beat =S.
The second window (w_{2}) is a fixed window of 320ms with the same T_{c} center. If the edges of w_{1 }were larger than the edges of w_{2}, the edges of w_{1} were set to be the same as w_{2}.
Following the selection of the isoelectric baseline, the algorithm uses two approaches to select the flattest line on VM and XYZ leads signal within w_{1}: (1) clustering of the signal with the least variance in a given window and (2) minimum absolute change of magnitude closest to the end of the window.
Searching for a candidate segment with the least variance
We calculate the variance on the X, Y, and Z lead signals with a moving window of 20ms (movvar_{XYZ}). Using the MATLAB function movvar, we identify the segment with the least amount of variance i.e. the flattest portion of the signal. Candidate points are identified by looking for the segments containing the largest number of counts from the histogram of movvar_{XYZ} with a fixed bin width of 10 µV^{2}. Once candidate points are identified, they are separated into clusters. The clusters are then defined such that the minimum distance between the edges of neighboring clusters was larger or equal to 8ms in order to reduce the impact of noise within the signal. The algorithm selected two candidate clusters comprised of the largest number of elements with which to perform origin point calculation.
The absolute voltage gradient across X, Y, and Z is calculated with a time step of 10ms. Then, the average of the sum of the absolute voltage gradient across the X, Y, and Z leads of a given cluster is obtained. The cluster with the smallest average gradient is chosen to best approximate the isoelectric segment, and the origin point is chosen at the median time point of that candidate cluster. If the last criteria was not met and the algorithm could not identify an origin point candidate within w_{1}, the search for an origin point is carried on to w_{2} with the algorithm described above.
Searching for a candidate segment with the least change
As an alternative approach, we attempt to identify the isoelectric segment by computing the sum of the absolute voltage gradient on the X, Y, and Z leads:
Then, we compare the gradient at any time step ∆tn and their neighboring time points (∆tn1 and ∆tn+1 ) against the minimum of the sum of the voltage absolute gradient (eq. 4) in the window w_{1}
The candidate origin point is the middle point of the segment where the comparison is below a threshold of 0.1 mV, to look for a stable isoelectric line. The comparison is performed starting at the right edge of the window w_{1} (closest to the R peak), then working backward toward the preceding T wave with a time step of ∆tn=4ms .
Final selection of the origin point
At the final step of the algorithm, the two previously identified candidate origin points are compared using the following criteria: area under the curve of reconstructed VM and sum of the average absolute gradient in 10ms time steps. Individual VMs are reconstructed for each candidate by defining the candidate as the zerovalue baseline. The area under the curve for each VM is computed only in window w_{1}. The sum of the average absolute gradient of each VM, with a time step of 10ms, is calculated around each candidate. The final heart vector origin point with the smallest area under the windowed VM curve and the minimum average voltage gradient is selected.
Construction of a representative timecoherent global XYZ median beat
A threestep approach is used (Figure 3):
Beat labeling and dominant type beat selection
First, each beat on a 10second 12lead ECG recording must be appropriately labeled. Nonanalyzable beats due to noise and artifacts and nondominant ectopic beats must be excluded from the analysis. Kors transformation matrix is used to obtain the orthogonal X, Y, and Z leads from 12lead ECG (see the Kors transformation matrix in the associated GitHub repository [6]).
Singlelead median beat construction
At the next step, all included beats on a single lead, Vx , are then aligned to construct a representative singlelead median beat, VMX . The maximum absolute of the first derivative (maximum dV/dt) is used to construct the singlelead median beat. After alignment, the representative median beat, VMX , is constructed using the median function of MATLAB (MathWorks, Natick, MA, USA).
Global XYZ multilead beat construction
At the third step, we construct a timecoherent global XYZ median beat. Singlelead alignment is performed only on a single lead (X). Corresponding time points on leads Y and Z are used for the construction of timecoherent global XYZ median beat.
Installation and Requirements
For the latest version of this software, please refer to the associated GitHub repository [6]. This code has been developed in Matlab and tested on Matlab versions 20162020. It can be also run in Octave. An example data file has been provided, including a test file for timecoherent global median beat construction. A test file for the heart vector origin point detection (median beat) is generated as an output of median beat construction. Subsequently, a test file for the viewer is generated as an output of origin point detection.
Usage Notes
This software may assist researchers with identifying the heart vector origin point. An associated paper entitled "Importance of the heart vector origin point definition for an ECG analysis: The Atherosclerosis Risk in Communities (ARIC) study" provides more detail on the approach used in this software [1]. For the latest version of the software, and to submit bug reports, please refer to the associated GitHub repository [6].
Limitations
This is semiautomated software that requires a review of the results using a viewer. The software provides an opportunity for users to correct the origin point manually, and to observe the effect of the change of origin point on median beat morphology. The software has been tested, but nevertheless may contain bugs.
Acknowledgements
This work was supported by 1R01HL118277 and 2R56HL118277 (PI Tereshchenko).
Conflicts of Interest
The authors have no conflicts of interest to declare.
References
 E. Frank, An accurate, clinically practical system for spatial vectorcardiography, Circulation. 13 (1956) 737749.
 F.N. Wilson, F.D. Johnston, The vectorcardiogram, American Heart Journal. 16 (1938) 1428.
 P. Kligfield, L.S. Gettes, J.J. Bailey, R. Childers, B.J. Deal, E.W. Hancock, H.G. van, J.A. Kors, P. Macfarlane, D.M. Mirvis, O. Pahlm, P. Rautaharju, G.S. Wagner, M. Josephson, J.W. Mason, P. Okin, B. Surawicz, H. Wellens, Recommendations for the standardization and interpretation of the electrocardiogram: part I: the electrocardiogram and its technology a scientific statement from the American Heart Association Electrocardiography and Arrhythmias Committee, Council on Clinical Cardiology; the American College of Cardiology Foundation; and the Heart Rhythm Society endorsed by the International Society for Computerized Electrocardiology, J Am Coll.Cardiol. 49 (2007) 11091127
 J.J. Bailey, A.S. Berson, A. Garson, Jr., L.G. Horan, P.W. MacFarlane, D.W. Mortara, C. Zywietz, Recommendations for standardization and specifications in automated electrocardiography: bandwidth and digital signal processing. A report for health professionals by an ad hoc writing group of the Committee on Electrocardiography and Cardiac Electrophysiology of the Council on Clinical Cardiology, American Heart Association, Circulation. 81 (1990) 730739.
 PerezAlday EA, LiPershing Y, Bender A, Hamilton C, Thomas JA, Johnson K, Lee TL, Gonzales R, Li A, Newton K, Tereshchenko LG. Importance of the heart vector origin point definition for an ECG analysis: The Atherosclerosis Risk in Communities (ARIC) study. Comput Biol Med. 2019 Jan;104:127138.
 Heart Vector Origin Point Detection and Representative Median Beat construction software on GitHub. https://github.com/Tereshchenkolab/Origin [Accessed: 20 May 2021]
Access
Access Policy:
Anyone can access the files, as long as they conform to the terms of the specified license.
License (for files):
MIT License
Discovery
DOI:
https://doi.org/10.13026/jfeg4820
Programming Languages:
Topics:
baseline
vectorcardiogram
origin point
heart vector
signal processing
electrocardiogram
Project Website:
https://github.com/Tereshchenkolab/Origin
Corresponding Author
Files
Total uncompressed size: 4.2 MB.
Access the files
 Download the ZIP file (3.0 MB)

Download the files using your terminal:
wget r N c np https://physionet.org/files/heartvectororiginmatlab/1.0.0/
Name  Size  Modified 

Parent Directory  
Example_Median_XYZ.csv (download)  18.9 KB  20210329 
Example_file_Rpeaks_XYZ.csv (download)  181 B  20210329 
Example_file_XYZ.csv (download)  157.1 KB  20210329 
Time_alignment_code_github.m (download)  4.6 KB  20210329 
origin_point_github.m (download)  10.2 KB  20210329 