Detecting and Quantifying T-Wave Alternans: The PhysioNet/Computing in Cardiology Challenge 2008 1.0.0

File: <base>/sources/Khaustov/TWAnalyser/index.shtml (9,847 bytes)
<!--#set var="TITLE" value="TWAnalyser: A T-wave alternans detector"-->
<!--#set var="USELOCALCSS" value="1"-->
<!--#include virtual="/head.shtml"-->

<div class="notice">
<table><tr><td><img src="/icons/Baustelle.png"></td>
<td>
<p><b>This package needs work, and you can help!</b></p>
<p> Minor revisions are needed to allow TWAnalyser to read its input using
the <a href="/physiotools/matlab/wfdb-swig-matlab/">WFDB Toolbox for MATLAB</a>.
If you are successful in making and testing these revisions, please share your
solution with us.  Thank you!</p>
</td></tr></table>
</div>

<p>
This software suite consists of Matlab implementations of the widely
used Spectral Method (SM) and Modified Moving Average (MMA) for T-wave
alternans (TWA) detection. It was initially developed for the
<a href=/challenge/2008/>PhysioNet/CinC Challenge 2008</a>, in which
these and a wide variety of other methods were evaluated and compared
in blinded tests, using a data set that included ECGs with and without
TWA as well as synthetic ECGs with calibrated amounts of artificial
TWA. The implementation of SM presented here scored second in the
<a href="/challenge/2008/sources/">open-source category</a> and third
overall with a score of 0.881. TWAanalyser's implementation of MMA
received a score of 0.400. (A third method, which combined both
algorithms, scored 0.834, not quite as well as SM alone.  In this
case, ECGs in which SM did not detect TWA were assigned a TWA estimate
of 0, and all others were assigned the MMA algorithm's TWA estimate.)
Most of the work to improve the score resulted from adjustments to
filtering and alignment.</p>

<p>
TWAnalyser has been tested on both Windows XP (SP2) and Linux
(Fedora Core 4-9) using Matlab R13 (6.5) and R2006b (7.3).</p>

<h2>Prerequisites</h2>

<h3>Data</h3>
<p>TWAnalyser accepts digitized ECGs in
<a href="/faq.shtml#physiobank-formats">PhysioBank-compatible
formats</a>. If you have ECGs in some other format and have Matlab
software for reading them, it's not too difficult to modify TWAnalyser
to work with your format. Otherwise,
<a href="/faq.shtml#creating-records">create PhysioBank-compatible
records</a> from your ECGs.  If you wish to analyze a lengthy
recording, you may wish to divide it into short segments (a few
minutes each) first; this will save a <em>lot</em> of time.</p>

<p>
TWAnalyser requires a set of Q-onset, S-end, and T-end annotations for the ECGs
to be analysed.  If these are not available, TWAnalyser
uses <a href="/physiotools/ecgpuwave/">ecgpuwave</a> to produce them.
You also have the option of providing your own annotation files.  In
that case the names of the annotation files should end with <tt>.vf</tt> or
<tt>.pu</tt> and their contents should mimic the format used by
ecgpuwave.  Specifically, annotation files should be stored in
PhysioBank-compatible format, and they should include:</p>
<ul>
<li> Q-onset annotations 
(<tt>anntyp&nbsp;=&nbsp;WFON, num&nbsp;=&nbsp;1, chan&nbsp;=&nbsp;0</tt>)
<li> S-end annotations
(<tt>anntyp&nbsp;=&nbsp;WFOFF, num&nbsp;=&nbsp;1, chan&nbsp;=&nbsp;0</tt>)
<li> T-end annotations
(<tt>anntyp&nbsp;=&nbsp;WFOFF, num&nbsp;=&nbsp;2, chan&nbsp;=&nbsp;0</tt>)
</ul>
<p>Read about annotations <a href="/faq.shtml#annotation">here</a>.</p>

<h3>Software</h3>

<p>
TWAnalyser requires
<a href="http://www.matlab.com" target="other">Matlab</a>,
<a href="/physiotools/wfdb.shtml">WFDB</a>,
and <a href="/physiotools/matlab/wfdb_tools/">WFDB_tools</a>.  If the
required annotations (see above) are not already available for the
ECGs to be analyzed, <a href="/physiotools/ecgpuwave/">ecgpuwave</a>
is also required.  TWAnalyser and all of its prerequisite software are
freely available under the terms of
the <a href="http://www.fsf.org/licensing/licenses/gpl.html"
target="other">GPL</a>, with the exception of Matlab.  It may be
possible to run TWAnalyser using
<a href="http://www.che.wisc.edu/octave/" target="other">GNU Octave</a>
or another freely available replacement for Matlab, but this has not
been tested.</p>

<h2>Installation</h2>

<p>
Under <b>Linux</b>:</p>
<ol>
<li> Install Matlab, WFDB, WFDB_tools, and ecgpuwave if you have not
already done so.
<li> Download and unpack <a href=twa-mfiles.tar.gz>twa-mfiles.tar.gz</a> (or
<a href=twa-mfiles.zip>twa-mfiles.zip</a>;  or download
individual source files for TWAnalyser <a href="twa-mfiles/">here</a>).
<li> Add the <tt>twa-mfiles</tt> directory to the Matlab path.
</ol>

<p>
Under <b>Windows</b>, you may follow the same procedure as for Linux.
Alternatively:</p>
<ol>
<li> Install Matlab if you have not already done so.
<li> Download and unpack <a href=twa-windows.zip>twa-windows.zip</a>.
<li> Enter the <tt>twa-windows</tt> directory and run <tt>setup.bat</tt>
from the Windows command prompt.
</ol>
Note that <tt>twa-windows.zip</tt> includes Windows executables that were
built using version 10.4.4 of the WFDB library (from May 2006), which lacks
features of recent versions such as support for reading EDF files.

<h2>Using TWAnalyser</h2>

<p>
There are three commands that will start the analysis for you. From
the Matlab command prompt type one of the following:</p>


<p><tt><b>DoTWASpectral</b></tt> [performs the SM and provides a
graphical interface to explore the results]</p>

<div class="reference">
<p><a href=images/SM.jpg><img src=images/SM-small.jpg title="Part of the
 DoTWASpectral GUI [click for full-size image]" style="float: right; padding: 0 0 1em 1em;"></a>
You are prompted to locate the ECG file you want to analyze.  The SM
interface consists of an ECG window, windows displaying successive
superimposed beats, alternans series, periodogram and averaged
periodogram.  Navigation is possible in the ECG, superimposed beat and
alternans series windows.  One ECG lead at a time is displayed. You
can switch leads using the button at the upper right corner of the
interface window.  A summary of the analysis results is at the top.
All three available options (see
the <a href="docs/KhaustovNematiClifford.pdf">paper</a>) for SM are
displayed simultaneously (i.e., respective alternans series,
periodograms and averaged periodograms are superimposed). You can
remove the options you don't need by
altering <tt>Param.MethodForEctopy</tt> in <tt>DoTWASpectral.m</tt> .</p>
</div> <!-- end reference -->

<p><tt><b>DoTWAbyMMA</b></tt> [performs the MMA and provides a graphical
interface to explore the results]</p>

<div class="reference">
<p><a href=images/MMA.jpg><img src=images/MMA-small.jpg title="Part of the
 DoTWAbyMMA GUI [click for full-size image]" style="float: right; padding: 0 0 1em 1em;"></a>
You are prompted to locate the ECG file you want to analyze.  The MMA
interface consists of ECG window, windows displaying superimposed even
and odd averages for the current interval, alternans value trend and
two windows containing (even and odd) averages for previous and
current interval plotted against the current beat.  Navigation is
possible in the ECG and trend windows.  One lead at a time is
displayed. You can switch leads using the button at the upper right
corner of the interface window.  A text string summarizing the
analysis results is displayed at the top of the window.</p>
</div> <!-- end reference -->

<p> <tt><b>BatchTWA</b></tt> [performs a batch analysis for a set of records
and outputs results into a text file]</p>

<div class="reference">
<p>For batch processing, set the current Matlab directory to
the directory with all the data files.  You are prompted to locate a
file that contains a list of records to analyse (one record per
string, no extensions). All available analysis options are
performed. If you don't need something - alter the <tt>Metric</tt>
and <tt>Method</tt> lists in <tt>BatchTWA.m</tt> .  The results are
stored in the current directory, in files <tt>twa_SM_replace.txt</tt>,
<tt>twa_SM_differences.txt</tt>, <tt>twa_SM_lomb.txt</tt>,
and <tt>twa_MMA.txt</tt>.</p>
</div> <!-- end reference -->

</ul>

<h2>Future work</h2>

<p>
We have a long to-do list planned for this software, including:
pre-filtering with PCA (as was used by the winning closed-source entry
in the competition, although this entry did not provide TWA
magnitudes, only rankings); reporting of heart rate (TWA that
manifests above 110 BPM is unlikely to be clinically significant);
tests to determine the effects of the unevenly sampled nature of TWA;
dealing with TWA phase changes (after ectopy for example) and
indicators to quantify this effect.</p>

<h2>References</h2>
<ul>
<li>
Khaustov A, Nemati S, Clifford GD
<a href="docs/KhaustovNematiClifford.pdf">An open-source standard
T-wave alternans detector for benchmarking signals.</a>
<i>Computers in Cardiology</i> 2008. The conference presentation of
this work is also available here
(<a href="docs/KhaustovNematiClifford.html">[HTML]</a> or 
<a href="docs/KhaustovNematiClifford.ppt">[PPT]</a>). 
<li>
Martinez JP, Olmos S
<a href="http://ieeexplore.ieee.org/iel5/10/30537/01408117.pdf"
target="other">Methodological principles of T wave alternans analysis:
a unified framework.</a>
<i>IEEE Transactions on Biomedical Engineering</i> <b>52</b>(4):
599-613; April 2005. [External link; requires subscription.  The
descriptions of the SM and MMA methods in this paper were the basis
for the implementations of these methods presented here.]
</ul>

<h2>Credits</h2>

<p>
This project was a joint effort
by <a href="mailto:avk@incart.ru?subject=TWAnalyser">Alexander
Khaustov</a> of the <a href="http://www.incart.ru" target="other">
St.-Petersburg Institute of Cardiological Technics (INCART)</a>, and
by Shamim Nemati and Gari Clifford of MIT. The software was
contributed to PhysioNet by INCART. Please refer your questions
to <a href="mailto:avk@incart.ru?subject=TWAnalyser">avk@incart.ru</a>.</p>

<!--#include virtual="/dir-footer.shtml" -->