Software Open Access
Apnea Detection from the ECG
Published: Feb. 4, 2002. Version: 1.0.0
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.
Background
The apdet software package uses a new automated method to diagnose and quantify obstructive sleep apnea from single-lead electrocardiograms based on detection of the periodic oscillations in cardiac interbeat intervals that are often associated with prolonged cycles of sleep apnea. This technique employs the Hilbert transformation of the sinus interbeat (NN) interval time series to derive the instantaneous amplitudes and frequencies of the series, and calculates their averages and standard deviations over a moving 5-minute window. We then apply a thresholding technique and detect continuous sequences of those windows that lie within threshold limits.
When applied to the training set of the Apnea-ECG Database created for the CinC Challenge 2000, this algorithm correctly classified 26 of 30 subjects (86.6%), and correctly identified the presence or absence of sleep apnea in 13895 of 17045 minutes (82.1%). When applied to the test set of the Apnea-ECG Database, this algorithm performed even better, correctly classifying 28 out of 30 cases (93.3%) of subjects, and 14591 of 17268 minutes (84.5%).
Obtaining the apdet package
The apdet software package is available in source form and as prebuilt binaries for Linux and MS-Windows.
Before building or using the apdet software, you must install the free WFDB software package. Under MS-Windows, you will also need to install the free Cygwin environment before building or using the apdet software.
Unpacking the apdet package requires tar and gzip, and running the software requires sh (or a compatible shell such as bash), and awk, all of which can be found on all Unix, Linux, and Mac OS/X systems, and in the Cygwin environment for MS-Windows. Cygwin also includes the gcc C compiler and all other utilities needed to compile the apdet package from sources if desired.
Downloading and installing the apdet package
Once you have installed the WFDB software package (and, under MS-Windows, the Cygwin environment), download and install the apdet package of your choice:
Sources:
- Download apdet.src.tar.gz. (You may also view or download the sources as individual files.)
- Unpack it:
tar xfvz apdet.src.tar.gz
tar is included in all versions of Unix, Linux, and MacOSX, and in Cygwin for MS-Windows. If your version of tar doesn't support the z option, unpack the package in two steps:
gzip -d apdet.src.tar.gz
tar xfv apdet.src.tar - Enter the source directory (apdet-1.0) and compile the software:
make all
(under MS-Windows, make -f Makefile.w32 all). - Install the software:
make install
(under MS-Windows, make -f Makefile.w32 install). You will probably need root (administrator) permissions to install in the default location; change the value of BINDIR in Makefile (Makefile.w32) if you need to use a different location.
Linux (x86) binaries:
- Download apdet.i386-linux.tar.gz.
- As root, unpack it:
tar xCfvz / apdet.i386-linux.tar.gz
MS-Windows binaries:
- Download apdet.cygwin.tar.gz.
- In a Cygwin/bash window, unpack it:
tar xCfvz / apdet.cygwin.tar.gz
Using the apdet package
Open a terminal window (under MS-Windows, a Cygwin/bash window) and type a command such as
get_apdet apnea-ecg/a03 qrs
The first argument is the record name, and the second is the annotator name for a beat annotation file. In the example above, get_apdet will analyze record a03, annotator qrs from the Apnea-ECG Database. (If you have not previously downloaded the input data into a local apnea-ecg directory, get_apdet obtains the data directly from PhysioNet.)
The get_apdet command prints the times of detection of sleep apnea heart rate oscillations and the total fraction of time with such detections. For the example above, the output is:
00:05:59 - 00:59:59 01:39:59 - 02:28:59 03:04:59 - 03:52:59 03:57:59 - 04:22:59 04:38:59 - 05:03:59 05:56:59 - 06:48:59 06:58:59 - 07:24:59 07:45:59 - 08:39:59tot = 05:33:00 / 08:42:25 = 0.637
See an illustration of these detections.
get_apdet relies entirely on normal-to-normal beat interval data, which it normally derives from a beat annotation file. Beat annotation files are available for most of the PhysioBank records that include ECGs. If you wish to study a recording for which no beat annotation file is available, you may be able to create one using sqrs. If you have interbeat interval data but not a beat annotation file, you can modify get_apdet as needed, or you can use rr2ann to put your data into the standard format before processing them.
How does get_apdet work?
The sequence of steps involved in the detection of the RR interval oscillations, as implemented by get_apdet, is as follows:
- The normal-to-normal (NN) intervals are derived:
rrlist $ANN $REC -a N
If the input files ($REC.$ANN and $REC.hea) are not in the current directory, rrlist looks for them in the PhysioBank archives on PhysioNet. - The NN interval series is then filtered to remove outliers:
filt 0.2 20 -x 0.4 2.0 - The series is then linearly resampled at 1 Hz ...
linsamp 1.0 - ... then locally detrended using a moving 40 second window ...
ldetrend 40 - ... and smoothed using a moving 5 second window:
smooth 5 - Next, the Hilbert transform is applied to derive instantaneous amplitudes and frequencies:
ht - The Hilbert amplitudes and frequencies are then median filtered using a 60 second window:
htmedfilt 60 - The amplitudes are normalized such that the average amplitude equals 1.0 (using awk).
- The midpoint of the Hilbert amplitudes is found (using awk and mm), and the minimum Hilbert amplitude threshold is set to
THRES = a + b*(mid+1)/2
where a = -0.555 and b = 1.3 (note: the values of a and b were given incorrectly in the original publication; please refer to the posted version instead.) - The mean Hilbert amplitudes and frequencies, their standard deviations and fraction of time within their specified threshold limits are calculated over 5-minute windows incremented each minute:
htavsd 1:00 5:00 THRES - Those windows where the means, standard deviations and threshold times of the Hilbert amplitudes and frequencies are all within their specified limits are selected (using awk).
- Apnea is detected whenever at least 15 consecutive windows are selected in the previous step, and the times of the detected apneic periods are printed:
detruns 1:00 5:00 15:00
This program correctly identifies the presence or absence of apnea in in 82.1% of the data in the CinC test set and 84.5% of the data in the CinC training set.
It is recommended that the accuracy of the oscillation detections be verified by visual inspection of the original RR interval series.
Contributors
This software was contributed by JE Mietus, C-K Peng, PCh Ivanov, AL Goldberger from Beth Israel Deaconess Medical Center and Harvard Medical School, Boston, USA
Access
Access Policy:
Anyone can access the files, as long as they conform to the terms of the specified license.
License (for files):
Open Data Commons Attribution License v1.0
Corresponding Author
Files
Total uncompressed size: 0 B.
Access the files
-
Download the files using your terminal:
wget -r -N -c -np https://physionet.org/files/apdet/1.0.0/
-
Download the files using AWS command line tools:
aws s3 sync --no-sign-request s3://physionet-open/apdet/1.0.0/ DESTINATION
Name | Size | Modified |
---|---|---|
Parent Directory | ||
LIST.USAGE (download) | 1.9 KB | 2019-04-12 |
Makefile (download) | 985 B | 2019-04-12 |
Makefile.w32 (download) | 1.2 KB | 2019-04-12 |
av.c (download) | 1.8 KB | 2019-04-12 |
detruns.c (download) | 4.6 KB | 2019-04-12 |
filt.c (download) | 4.5 KB | 2019-04-12 |
get_apdet (download) | 3.7 KB | 2019-04-12 |
ht.c (download) | 3.3 KB | 2019-04-12 |
htavsd.c (download) | 6.6 KB | 2019-04-12 |
htmedfilt.c (download) | 2.9 KB | 2019-04-12 |
ldetrend.c (download) | 3.4 KB | 2019-04-12 |
linsamp.c (download) | 2.4 KB | 2019-04-12 |
mm.c (download) | 1.6 KB | 2019-04-12 |
rrlist.c (download) | 4.3 KB | 2019-04-12 |
smooth.c (download) | 2.4 KB | 2019-04-12 |