Next: PARSESCP(1) Up: WFDB Applications Guide Previous: NGUESS(1)On This Page

Name

nst - noise stress test for ECG analysis programs

Synopsis

nst [ options ... ]

Description

nst adds calibrated amounts of noise from a noise record to ECGs (or other signals) from a clean record, generating an output record in WFDB format. Such output records make it possible to assess the noise tolerance of analysis programs.

Options include:

-a annotator
Use annotator as the reference annotator for the clean record. If the -a option is omitted, atr is used as the reference annotator. Reference annotations are used to determine the signal size as part of the noise level calibration, unless the -p option (see below) is used. Reference annotations are also copied to the output record.
-F format
Write output signals in the specified format (default: 16; for a list of valid formats, see signal(5) ).
-h
Print a usage summary.
-i clean-record noise-record
Read ECG (or other) signals from clean-record, and noise from noise-record. nst obtains these record names interactively if the -i option is omitted.
-o output-record
Create a record named output-record containing the input signals and added noise. nst obtains the name of the output record interactively if the -o option is omitted. If a header, signal, or reference annotation file for output-record already exists in the current directory, it will be overwritten.
-p protocol
Use protocol (the annotator name of an annotation file associated with the noise record) to define how noise is to be added to the signals (see below). If the -p option is omitted, nst generates a protocol annotation file.
-s SNR
Set scale factors for noise such that the signal-to-noise ratio during noisy segments of the output record is SNR (in dB, see below). This option is ignored if a protocol is specified using -p.

Output signal generation

If the sampling frequencies of the clean and noise records differ by 10% or more, nst resamples the noise record (using xform(1) ), producing a new noise record in the current directory. The name of the new record is that of the original (less any suffix beginning with an underscore), with a suffix consisting of an underscore followed by the sampling frequency of the new record. For example, if nst is asked to use AHA DB record 1001, sampled at 250 Hz, and noise record em, sampled at 360 Hz, it first generates a new noise record named em_250, sampled at 250 Hz. If the noise record that nst would generate exists already, nst uses it without regenerating it. nst prints a warning if it is necessary to resample the noise record, or to substitute a previously resampled noise record.

Each ECG (or other) signal is paired and combined with a noise signal. A gain (a, a multiplicative scale factor) to be applied to the noise samples is set independently for each clean signal. If there are fewer noise signals than ECG signals, noise signals are paired with more than one clean signal as necessary. For example, if there are three clean signals and two noise signals, they are paired and combined as follows:
   output signal 0 = clean signal 0 + a[0] * noise signal 0 + b[0]

   output signal 1 = clean signal 1 + a[1] * noise signal 1 + b[1]

   output signal 2 = clean signal 2 + a[2] * noise signal 0 + b[2]

The initial values of the gains, a, and offsets, b, are zero for all signals (i.e., no noise is added). In the protocol annotation file, the time field of each NOTE annotation specifies when gains are to be changed, and the aux field specifies new values for the gains (in scanf(3) %lf format, beginning with a[0]; values are separated by white space within the aux field). The offsets, b, are recalculated at these times to cancel out step changes in signal levels when gains are changed. During the intervals between NOTE annotations in the protocol annotation file, gains and offsets are fixed.

If no protocol annotation file is specified, nst generates one using a standard protocol (a five-minute noise-free ‘‘learning period’’, followed by two-minute periods of noisy and noise-free signals alternately until the end of the clean record). The gains to be applied during the noisy periods are determined in this case by measuring the signal and noise amplitudes (see Signal-to-noise ratios, below).

Generation of the output signals ends at the time of the last NOTE annotation in the protocol annotation file, or at the end of the clean record, whichever comes first. If the noise record ends before that time, nst ‘rewinds’ the noise record to the beginning as necessary to obtain additional noise samples.

If a non-standard protocol is needed, it is probably easiest to run nst without the -p option to obtain a standard protocol annotation file. The standard file can be converted to text by rdann(1) , edited as needed using any text editor, and converted back into annotation file format by wrann(1) .

Signal-to-noise ratios

It is useful to characterize the noise level in a noise stress test in terms of the signal-to-noise ratio (SNR) during the noisy segments. SNR is commonly expressed in decibels (dB):
   SNR = 10 log (S/N)

where S is the power of the signal, and N is the power of the noise. If the -p option is omitted, nst measures S and N, and determines gains for the noise signals such that SNR matches the level specified using the -s option (or interactively).

The major difficulty in applying such a definition to the noise stress test is that most measurements of signal power are not particularly meaningful when applied to the ECG. A measurement based on mean squared amplitude, for example, will be proportional to the square of the heart rate. Such a measurement bears little relationship to a detector’s ability to locate QRS complexes, which is typically related to the size of the QRS complex. A less significant problem is that unweighted measurements of noise power are likely to overestimate the importance of very low frequency noise, which is both common and (usually) not troublesome for detectors. In view of these issues, nst defines S as a function of the QRS amplitude, and N as a frequency-weighted noise power measurement. The definitions of S and N have been chosen such that SNRs given for noise stress tests will correspond roughly in terms of an intuitively defined ‘signal quality’ with SNRs such as those that may be encountered in other contexts.

To determine S, nst invokes sigamp(1) to read the reference annotation file for the ECG record and to measure the peak-to-peak amplitude of each of the first 300 normal QRS complexes (in each case, by measuring the range of amplitudes during a window from 50 ms before to 50 ms after the QRS annotation). The largest 5% and the smallest 5% of the measurements are discarded, and sigamp estimates the peak-to-peak QRS amplitude as the mean of the remaining 90% of the measurements. nst squares this peak-to-peak amplitude estimate and divides the result by 8 (correct for sinusoids, close enough for these purposes) to obtain the QRS ‘‘power’’ estimate, S.

To determine N for the unscaled noise signals, sigamp divides the first 300 seconds of the noise record into one-second chunks. For each chunk, sigamp determines the mean amplitude and the root mean squared difference, n, between the signal and this mean amplitude. As in the calculation of S, the largest 5% and the smallest 5% of the 300 measurements of n are discarded, and sigamp estimates the RMS noise amplitude as the mean of the remaining 90% of the measurements. N is the square of this estimate; if a noise signal is scaled by a gain, a, then N is scaled by the square of a. To obtain the desired SNR given S and N, nst solves for a in the equation:
   SNR = 10 log (S/(N * a**2))

The calculations of S, N, and a are performed separately for each pair of clean and noise signals.

Noise records

Three noise records suitable for use with nst are available from http://www.physionet.org/physiobank/database/nstdb/ and are also provided in the nstdb directory of the MIT-BIH Arrhythmia Database CD-ROM. These contain noise of the types typically observed in ECG recordings. They were obtained using a Holter recorder and standard electrodes for ambulatory ECG monitoring, on an active subject. The electrodes were placed on the limbs in locations chosen such that the subject’s ECG is not visible in the recorded signals. Two signals were recorded simultaneously. Record bw contains primarily baseline wander, a low-frequency signal usually caused by motion of the subject or the leads. Record em contains electrode motion artifact (usually the result of intermittent mechanical forces acting on the electrodes), with significant amounts of baseline wander and muscle noise as well. Record ma contains primarily muscle noise (EMG), with a spectrum that overlaps that of the ECG, but which extends to higher frequencies. Electrode motion artifact is usually the most troublesome type of noise for ECG analyzers, since it can closely mimic characteristics of the ECG. For this reason, the remaining records in the nstdb directory consist of noise from record em mixed with clean ECGs by nst.

Although an early version of nst generated the records in the nstdb/old directory, the signal-to-noise ratios of these records were not determined using the definitions above. (Unfortunately, they were not calculated as stated in the readme.doc file on the first edition CD-ROM, either.) Using the definitions above, the signal-to-noise ratios (in dB) for the noisy portions of these records are as follows:

RecordSignal 0Signal 1RecordSignal 0Signal 1
118_0219.7914.38119_0220.3113.79
118_0413.778.36119_0414.297.77
118_0610.254.84119_0610.764.25
118_087.752.34119_088.271.75
118_105.810.41119_106.33-0.19
118_124.23-1.18119_124.74-1.77

Choosing ‘clean’ records

If the goal is to assess noise robustness, ‘clean’ records are best chosen from among those that can be analyzed without error (or with very low error rates). Given such a choice, any errors observed in analysis of nst output records can be attributed to the effects of the added noise, and not to any intrinsic properties of the signals.

Using nst output

The output records generated by nst may be analyzed in the same way as the clean records from which they were obtained. For ECG analyzers, programs such as bxb(1) , epicmp(1) , mxm(1) , and rxr(1) may be useful for assessing the accuracy of analysis results. A series of nst output records with a range of signal-to-noise ratios may be used to determine how analyzer performance varies as a function of SNR. The parameter of greatest interest is usually the minimum value of SNR for which performance remains acceptable.

The standard protocol is designed to provide a fair yet difficult challenge to most analyzers. Segments of noise-free signals during the test period illustrate how rapidly the analyzer recovers its ability to analyze clean signals after having been presented with noisy signals.

Tests of multichannel analyzers should include records in which not all signals are equally noisy. Such records can be generated by nst with appropriately constructed protocol annotation files.

Environment

It may be necessary to set and export the shell variable WFDB (see setwfdb(1) ).

See Also

bxb(1) , epicmp(1) , mxm(1) , rdann(1) , rxr(1) , setwfdb(1) , sigamp(1) , xform(1) , wrann(1) , signal(5)
Moody, G.B., Muldrow, W.K., and Mark, R.G.
A noise stress test for arrhythmia detectors. Computers in Cardiology 11:381-384 (1984).

Author

George B. Moody (george@mit.edu)

Source

http://www.physionet.org/physiotools/wfdb/app/nst.c


Table of Contents

Up: WFDB Applications Guide


Please e-mail your comments and suggestions to webmaster@physionet.org, or post them to:

PhysioNet
MIT Room E25-505A
77 Massachusetts Avenue
Cambridge, MA 02139 USA

Updated 28 May 2015