ECG Measurement and Analysis

Rob MacLeod and Brian Birchler


1 Purpose and Background


The goal of the lab is to develop some understanding of the biophysical basis and practice of electrocardiographic measurements. A secondary purpose is to examine the hypothesis that a current dipole is a suitable source model for the electrical activity of the heart.


The text book background for this lab is particularly weak so please consult the class notes and some of the web links from the class web site. Some particularly useful links are:

Note that the term ``lead'' here means the potential difference measured between two electrodes. Thus, each single lead requires two electrodes. We talked in class about bipolar versus unipolar leads and this lab will illustrate their meaning and differences.

2 Lab Procedure

2.1 Organization

Please perform the Limb Leads, Frank Lead ECG, and Standard ECG exercises (described below) in your usual groups of 2 and 3 students. Use the same subject for all parts.

Equipment for performing the Body Surface Mapping (BSPM) may not be available; if not, you will receive a point to data to be analyzed for your lab report. Groups of 6 students at a time should consult with Dr. MacLeod at some point during the lab for a tutorial of map3d, the program necessary for visualization and analysis of the BSPM data.

2.2 Limb Leads

Figure 1: Electrocardiographic lead field.

The limb leads are part of the legacy of Wilhems Einthoven, developer of the string galvanometer and winner of the 1926 Nobel Prize for his advances in electrocardiography. The idea was based on the current dipole as a source of cardiac electrical activity. The goal of the leads developed by Einthoven was to capture the projection of the cardiac dipole in the frontal plane based on an equilateral triangle coordinate system. The underlying formalism of the limb lead system (and the Frank lead system developed later) is the lead field, a function that projects a current dipole source to any point on the body surface as shown in Figure 1. The lead field vector $ \bf L$ mathend000# is specific to a set of electrode locations and when multiplied by the current dipole vector $ \bf H$ mathend000#, the result is a scalar value equal to the potential difference between the electrodes of the lead. See the class notes for more background on this concept. The limb leads represent the most simplified application of the lead field idea in that there is the lead vector for each of the three limb leads, I, II, and III, that correspond to the sides of the Einthoven triangle.

Figure 2: System of limb lead ECG.

In this lab, you will record the standard limb leads in sequence, according to the diagram in Figure 2. Note the polarity of the leads-this is important to check when performing the measurements. An inverted lead (i.e., with the connections reversed) will result in useless data during the analysis. Note also that the limb leads are based on an equilateral triangular coordinate system and that it will be necessary to transform them to a Cartesian system to compare with the other lead systems we will investigate. HINT: This requires more than just taking the sin/cos of the vectors.

Figure 3: Circuit diagram for the limb lead measurements

The circuit diagram for the associated measurements in the lab is shown in Figure 3. Note here again the importance of getting proper polarity of the leads. Don't trust the diagram but check yourself to make sure the connections make sense. Failure to check this during the measurements will result in data that cannot be corrected later! Lead placement

Note also that rather than the classic limb leads based on electrodes attached to the arms and legs, we will use an equivalent system based on electrode sites on the thorax. This modification makes the lead placement slightly easier but the main advantages are practical in that electrode wires are shorter (less noise) and easier to manage, both in the lab and in clinical practice.

2.2.1 Lab steps

The steps in setting up this basic ECG measurement are illustrated in Figure 3 and are as follows:

  1. Identify the following four sites on the torso of the subject and use an alcohol swab to clean the skin beforehand:

  2. At each site, apply one of the disposable, pre-gelled ECG electrodes. Find locations as free of subcutaneous fat and muscle as possible. Do not remove these electrodes until the end of the lab.

  3. Connect the lead wires to 3 of the inputs of the 4-channel bioamplifier so that you can record all three leads at once. Select any two of the leads and display them on the oscilloscope. Make sure the polarities are correct, for example, to record Lead I, this would require: You can check that you have proper polarity by comparing the measured signals to the sample in Figure 4 below.

  4. For the bioamplifier start with the following settings and adjust as necessary to achieve the best possible signal quality:

  5. Put a T-connector on any two of the outputs of the bioamplifier, with two BNC cables, one to channel 1 on the oscilloscope and the other to the first channel of the A/D input box connected to the computer.

  6. On the oscilloscope:

Figure 4: An example of a normal 12-lead ECG. Use for comparison to your measurements in the lab

Now ensure that you have a good signal on the oscilloscope and make adjustments as necessary. Here, perhaps more than in other labs, it is worth the time to achieve the best quality signals possible. Try and move wires around, have the subject sit very quietly and make sure to prepare the skin fully as these all contribute to high quality recordings. Once you are satisfied with the signal quality, carry out the following steps:

  1. Note the sensitivity of the ECG to motion of the subject and experiment to create the best conditions.
  2. Save an image of the ECG on the oscilloscope using the memory function (or record with the acquisition program on the computer).
  3. From this, compute the period and heart rate for your subject.
  4. Using the acquisition program, record 10-20 seconds of a baseline ECG (be certain to record all 3 channels simultaneously so they are time aligned).

After the lab, follow the instructions in Section 3 below to compute the dipole direction from the limb lead signals.

2.3 Frank Lead ECG

Figure 5: Frank electrode system to record the three-dimensional projection of the heart dipole. The circuit is for reference only. The amplifier replaces it.

The goal for the Frank electrode system is to capture the three-dimensional extent of the heart dipole. For this, it is necessary to measure potential differences not just in the frontal plane, as in the limb leads, but along the antero-posterior (front-to-back) axis of the body. The diagram in Figure 5 illustrates the original Frank lead system [1] and we will use a simplified version of this.

Figure 6: Circuit diagram for the Frank lead measurements

The circuit diagram for the associated measurements in the lab is shown in Figure 6. Again, be very careful about lead polarity and lead placement in these measurements. Note that you can capture all three leads at once on the A/D converter but must select two leads to display on the oscilloscope. HINT: CB8ChanScope cannot record just 3 channels and crosstalk occurs on empty channels. This does not affect your recorded signals but may be confusing. I suggest connecting channel 4 to ground.

2.3.1 Lab steps

  1. Using the same subject, apply electrodes to the sites labeled in Figure 5 as I, A, E, M, and H. HINT: Use the back of the neck for H.
  2. Attach the reference to the lower right rib electrode (RL). Attach Kpy- to the lower left rib electrode (LL) and then attach the wires from the other electrodes to the appropriate lead inputs of the 4-channel bioamplifiers. Connect the x mathend000#, y mathend000#, and z mathend000# leads, labeled Kpx mathend000#, Kpy mathend000#, and Kpz mathend000# in the figure, to channels 1, 2, and 3 of the bioamplifier.
  3. Be careful to select the polarity of the leads to match the directions in the figure, i.e., y mathend000#-axis pointing along the body axis in the upwards direction. (Note that this is not the standard arrangement of clinical body axes but a more physically oriented version).
  4. Connect all three output channels of the 4-channel amplifier and to the A/D converter.
  5. Take two of the outputs from the amplifier and feed them to Channels 1 and 2 of the oscilloscope and use them to monitor the leads and ensure good quality (low noise) lead placements.
  6. Now on the oscilloscope, select the x-y mode so that instead of time, we have one of the leads driving the x-deflection of the 'scope. This way, it is possible to visualize in real time the vectors loops in each of the three orthogonal planes. Select different pairs of outputs to connect to the oscilloscope and see the vector loop diagrams in different spatial planes.
  7. Observe changes in the loops as the subject moves or changes position.
  8. Record 10-second runs of ECG for all three leads simultaneously and store these for later analysis. Record and save several runs and attempt each time to acquire the best quality signals.

2.4 Standard ECG

Figure 7: Precordial leads, part of the Standard ECG developed by Wilson.

The standard 12-lead ECG lead system seeks to increase sensitivity to local activity and so places the leads on the chest close to the heart, as Figure 7 indicates. The source assumptions for this lead system are not of a current dipole but rather each lead is thought to reflect the electrical activity of a nearby region of the heart.

Figure 8: Circuit diagram for the precordial lead measurements

The circuit diagram for the associated measurements in the lab is shown in Figure 8.

2.4.1 Lab steps

  1. On your group subject, apply six electrodes as indicated in Figure 7. Don't confuse the nipples (dark brown) as sites.
  2. We will use the Limb Leads to make a Wilson Central Terminal (WCT) that will be a reference for all other leads. There will be some circuitry available to connect these three leads, each through an approximately 5 k$ \Omega$ mathend000# resistor.
  3. The rib electrode on the right side (RL) should be the ground.
  4. As depicted in Figure 8, the first channel will be used to record each precordial lead one at a time. The second channel will be used to record the standard limb lead (LI) that will serve to time align the precordial data in your later analyses.
  5. For each precordial lead, record both that signal and the Lead I reference signal.
  6. As before, make sure the subject stays quiet throughout to ensure high quality data.

2.5 Body Surface Potential Mapping (BSPM)

Figure 9: Body surface mapping system showing the 120 electrodes distributed over the front and back of the torso.

The goal of body surface mapping is to record the entire distribution of electric potential over the surface of the torso and thus to create an image of this field rather than a small number of time samples. To this end, such systems measure at from 32-200 sites on the front (and sometimes back) of the torso. Figure 9 shows an example of a BSPM system with 120 electrodes attached to both the front and back of the torso.

The BSPM system used in the lab is based on 32 leads attached to the anterior surface of the torso. To select these 32 sites, investigators recorded a database of maps at much higher resolution and then extracted from them the most meaningful leads [2,3] according to a statistical estimation strategy. To create maps of potential distribution from the 32 leads requires a post processing step that applies this estimation, in the form of a matrix. The resulting maps contain 192 leads. We will use a program called map3d to display these data. See Appendix A below for details of the estimation scheme. The data posted to the web site is already appropriately transformed and is ready for use.

3 Post Processing

There are a set of steps to perform on the recorded signals before they are available for analysis. With the processed data it will then be possible to determine the direction of the heart dipole using each of the lead systems.

3.1 Limb leads

  1. As you look at your raw data, you will notice a low frequency oscillation or a wandering baseline that is different for each recording; where do you think this oscillation comes from? Such behavior is customary in data recorded from biological systems, but it is undesirable. Removing it is called ``baseline correction'' and there some simple methods for removing baseline from cardiac data. You can use filters, Fourier transforms, or line fitting (filtfilt, fft, ifft, polyfit); simplest is probably line fitting, which approximates the baseline drift as a straight line (using Polyfit in MATLAB) and then subtracts it from the original signal. The disadvantage of this approach is that it can only be applied locally, i.e., for a short period in time, at a minimum for each beat. The corrected beats are then put back together to create a baseline corrected signal (concatenate).

    For this lab, identify for each beat in your recording two points, one before the PQRST and one after it, and use those to fit a straight line. Then subtract this line from the entire beat. The MATLAB function POLYFIT provides a simple means of fitting a segment of the signal to a straight line (or any other higher order polynomial as well).

  2. Derive the formula for determining the heart vector direction and amplitude from the limb leads. For this, use the trigonometric relationships provided by the Einthoven triangle and take advantage of the fact that the the triangle is equilateral. Lead I is easiest of all because it aligns with the x mathend000#-axis of a Cartesian coordinate system; the others are a little more complicated but use the geometry of the triangle to convert between the triangular coordinate system described by the Einthoven system and the Cartesian system we will need to display the vector. It is probably easiest to first derive expressions of the three leads as a function of the heart vector amplitude (H mathend000#) and angle with respect to the x mathend000#-axis, ($ \alpha$ mathend000#). Then use two of these expressions to solve for H mathend000# and $ \alpha$ mathend000# in terms of two of the limb leads.

    Note that because of the redundancy in the system, you will only need two of the limb leads to determine the heart vector; pick any two (but be smart, i.e., use lead I). Include a diagram and the steps of your derivation with the report

    HINT: LII is NOT H and Hy mathend000# is NOT LII*cos(30).

  3. Once you know H and ($ \alpha$ mathend000#) you can easily compute the x and y components (Hx mathend000# and Hy mathend000#) of the heart vector and plot the dipole during any instant of a heartbeat. Physicians look at the heart vector in the form of loops that mark the trajectory of the heart dipole. To create a plot of the trajectory plot points corresponding to Hx mathend000# and Hy mathend000# and connect them with a line in the proper order. Divide a representative heartbeat into the QRS complex and the ST segment (the rest of the signal) and plot each trajectory separately. Include separate plots of both QRS and ST loops for the case in your report

3.2 Frank leads

The Frank lead system provides directly the three orthogonal leads of the dipole vector so that no calculations are necessary. To compare with the results of the limb leads, plot the same values as described for the limb lead case in the frontal plane (x - y mathend000#). In order to make comparisons with the precordial lead system, also plot dipole trajectories in the horizontal plane (x - z mathend000#).

Make sure to apply the same type of baseline correction as for the limbs leads and divide the signals into QRS and ST complexes, then create separate loops for each of these two parts of the ECG.

3.3 Precordial leads

The notion of the dipole vector is not so well integrated into the electrocardiography of the precordial leads (standard ECG). As Figure 7 shows, each lead represents a vector direction based on a line from the body central axis through the electrode location on the body surface.

  1. Because you had to record these leads in sequence, use Lead I, which is common to each recording, to time align across sequential recordings. Write a MATLAB program that performs the time alignment. Create a plot of all 6 leads and Lead I stacked vertically and, as always, with constant vertical scaling for each plot.
  2. Identify two leads that have vector projection directions that align approximately with the x mathend000# and z mathend000# axes.
  3. Use these leads as the components of the heart dipole and compare the resulting vector loops to those from the horizontal plane of the Frank lead system.

3.4 BSPM

BSPM captures all the potentials on the body surface and the analysis of such maps occurs not in terms of dipoles but by the distribution. We will take a similar course in analyzing some pre-recorded BSPM data from a previous lab. We will include in the next lab a demo of the BSPM method but in the meantime, please proceed as follows:

  1. To download the data from the lab, go to
    and then (right-click or control-click on the files you want to download and then select ``download link to disk'' or equivalent

    There is a single set of four mapping data files, one for each of positions we had Andrew (a student in a previous class) take. Download all these files. Each file is in MATLAB format as a data structure with three items, the time signals, called ``potvals'', the units, called ``unit'', and a text label, called ``label''.

    For example, to read in the file andrew-sitting.mat and see its contents in MATLAB:

          >> load 'andrew-sitting'
          >> whos
            Name       Size                    Bytes  Class
            run2       1x1                   2032584  struct array
          Grand total is 254061 elements using 2032584 bytes
          >> run2
          run2 =
              potvals: [192x1323 double]
                 unit: 'uV'
                label: 'SITTINGUPANDREW/    24-FEB-05/G=6/      '
    In this case, ``run2'' is the name I gave to the data when I created andrew-sitting.mat so you will see a different name for each of the files. This file contains 192 channels of data with 1323 time instants in each of those channels. To access the time series data, use the notation run2.potvals and treat this as the matrix name. Each row in run2.potvals is a time signal for a particular channel. So to plot channel 47 of the data, use the MATLAB command
          >> plot(run2.potvals(47,:))

  2. Select some pairs of electrodes that you could use to construct a set of orthogonal leads, i.e., like the Frank leads you used in the previous part of the lab. My personal favorites are: Generate these leads and then find the direction of the vector loop at its maximum and compare the direction and magnitude for each of the positions of the subject, i.e., laying flat, on the left side, on the right side, and sitting. The question to answer here is whether a change in body position is enough to cause a discernible shift in the vector direction.

4 Lab report

Use the standard lab format for this one:

  1. Introduction: provide overview and some (.5-1 page) background on the measurements and then a summary of what you did.
  2. Methods: brief description of each measurement set.
  3. Results: Please include the following:
    1. Limb leads: Plot the three leads in a vertical stack (three separate subplots) using consistent horizontal and vertical scaling. Take a window of three to four beats and scale the plots sufficiently to see the ECG features. Plot the heart dipole loops for the QRS and ST complexes. These loops will be compared with the frontal plane dipole loops of the Frank lead system.
    2. Frank leads: Plots of each of the three leads as function of time, again with constant scaling as all plots in the report. Plot the vector loops for the frontal (x - y mathend000#), transverse (x - z mathend000#), and sagittal (y - z mathend000#) planes. The frontal will be compared with the limb lead loops, the horizontal with the precordial lead loops, and the sagittal with the BSPM loops. Verify that all loops are similar to the displays you had on the oscilloscope during the lab.
    3. Precordial leads: plot all of the (time aligned) leads in a vertical stack and include these as well as the dipole loop plot for the two leads most closely aligned with the x and z components of the horizontal plane. This will be compared to the horizontal plane loops of the frank lead system.
    4. BSPM: compute dipole loops from the BSPM data and compare them to those from other sources.
  4. Discussion: discuss your results and attempt to address the main question for the lab about the suitability of the dipole as a source that represents the electrical activity of the heart. Be specific about similarities and differences between heart vector loop plots between the various lead systems.

A. Estimation process

Here are the details of the estimation, provided only for the curious.

Figure 10: Steps required to perform estimation of high resolution maps from a subset of measured ECGs

The first component of the estimation technique is the training phase, which begins by defining the training database and selecting the particular leadset. The training database is composed of N mathend000# maps each containing M mathend000# values, from which we constructed a matrix $ \bf A$ mathend000# of N mathend000# M x 1 mathend000# column vectors. We assume that MK mathend000# of the total M mathend000# values are known and wish to create an estimator for the remaining MU mathend000#. We then reorder the values in each column of $ \bf A$ mathend000# such that the known values filled the upper MK mathend000# rows. Each selection of a new lead subset thus requires a different ordering of $ \bf A$ mathend000# and resulted in a different estimation matrix. In the schematic example shown in Figure 10, the high resolution map contains 49 ( 7 x 7 mathend000#) electrodes with a subset of leads containing only 8 leads. Therefore, MK = 8 mathend000# and MU mathend000# (the number of unknown values) = 41 mathend000#. We the partition the matrix $ \bf A$ mathend000# into an 8 x N mathend000# upper partition $ \bf A_{{K}}^{}$ mathend000# and $ \bf A_{{U}}^{}$ mathend000#, the 41 x N mathend000# lower partition.

The next step in the training phase is to calculate the covariance matrix $ \bf K$ mathend000# according to

$\displaystyle \bf K$ = $\displaystyle {\frac{{({\bf A} - \overline{{\bf A}})
({\bf A}-\overline{{\bf A}})^{T}}}{{M}}}$, (1)
where $ \overline{{{\bf A}}}$ mathend000# is a matrix with identical columns, each of which is the mean activation vector across all maps. We then partition $ \bf K$ mathend000# into blocks according to MK mathend000# and MU mathend000#

$\displaystyle \left[\vphantom{
{\bf K}_{KK} & {\bf K}_{KU} \\
{\bf K}_{UK} & {\bf K}_{UU}
\end{array} }\right.$$\displaystyle \begin{array}{cc}
{\bf K}_{KK} & {\bf K}_{KU} \\
{\bf K}_{UK} & {\bf K}_{UU}
\end{array}$$\displaystyle \left.\vphantom{
{\bf K}_{KK} & {\bf K}_{KU} \\
{\bf K}_{UK} & {\bf K}_{UU}
\end{array} }\right]$, (2)
where $ \bf K_{{KK}}^{}$ mathend000# and $ \bf K_{{UU}}^{}$ mathend000# are both square submatrices of size MK mathend000# and MU mathend000#, respectively, $ \bf K_{{KU}}^{}$ mathend000# is of size MK x MU mathend000# and $ \bf K_{{UK}}^{}$ mathend000# is its transpose. Finally, the transformation, $ \bf T$ mathend000#, is formed by solving the simple matrix equation,

$\displaystyle \bf T$ = ($\displaystyle \bf K_{{KU}}^{}$)T  ($\displaystyle \bf K_{{KK}}^{}$)-1. (3)

The result from the training phase is an MU x MK mathend000# matrix of basis functions, T, that is unique to the selected lead subset and the training database. Left multiplication by $ \bf T$ mathend000# of any subsequent measurement vector of the same MK mathend000# electrodes yields an estimate of the values at all MU mathend000# remaining sites and thus a complete, high resolution map according to the equation

AUi = $\displaystyle \bf T$ x AKi, (4)
where AKi mathend000# and AUi mathend000# are the measured and estimated portions, respectively, of a single map.


E. Frank.
An accurate, clinically practical system for spatial vectorcardiography.
Circ., 1:737-749, 1956.

R.L. Lux, C.R. Smith, R.F. Wyatt, and J.A. Abildskov.
Limited lead selection for estimation of body surface potential maps in electrocardiography.
IEEE Trans Biomed. Eng., 25:270-276, 1978.

R.L. Lux, M.J. Burgess, R.F. Wyatt, A.K. Evans, G.M. Vincent, and J.A. Abildskov.
Clinically practical lead systems for improved electrocardiography: Comparison with precordial grids and conventional lead systems.
Circ., 59:356-363, February 1979.

About this document ...

ECG Measurement and Analysis

This document was generated using the LaTeX2HTML translator Version 2008 (1.71)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 3 -no_white -link 3 -no_navigation -no_math -html_version 3.2,math -show_section_numbers -local_icons descrip

The translation was initiated by Rob Macleod on 2011-03-02

Rob Macleod 2011-03-02