Download gmse.c, the C language source for a program that performs multiscale entropy analysis. The program can be compiled using any ANSI/ISO C compiler, and should be linked to the C math library (it uses only the sqrt function from that library). For example, using the freely available GNU C compiler, mse.c can be compiled into an executable mse by the command:
gcc -o gmse -O gmse.c -lm
The program to compute GMSE processes text formatted input files with either one or two columns. Files with one column can be a list of RR intervals or any time series of interest. Files with two columns should be the time of occurrence of an R wave, t(i), and the corresponding RR intervals, t(i+1) - t(i). This type of RR interval file can be obtained from a beat annotation file using ann2rr:
ann2rr -r nsrdb/16265 -a atr -c -p N -P N -i s3 -V s3 > 16265.RR
Example of a two-column input file (16265.RR):
t(i) | RR(i) = t(i+1) - t(i) |
0.406 | 0.602 |
1.008 | 0.609 |
1.617 | 0.602 |
2.219 | 0.625 |
2.844 | 0.609 |
3.453 | 0.625 |
4.078 | 0.594 |
4.672 | 0.602 |
⋮ | ⋮ |
300.914 | 0.547 |
301.461 | 0.539 |
302.539 | 0.547 |
303.086 | 0.539 |
⋮ | ⋮ |
The two-column file, 16265.RR can be filtered using filt from the HRV Toolkit:
filt 0.3 20 -x 0.3 2.0
In this example, all points below 0.3 and above 2.0 are first removed. Next, to decide one whether the data point xi should be filtered out or kept, the mean value of the 20 data points to the left and the 20 data points to the right is calculated. The central point xi is deleted if it is below of above 30% (0.3) of the computed average value. The process is repeated for all data points.
When given two column input files (time and RR intervals), the GMSE program excludes RR intervals that are not consecutive. In the example above, there is an interruption in the time series between 301.461 and 302.539 s (values highlighted in yellow): 302.539 - 301.461 = 1.078 ≠ 0.539. Thus, the RR interval 0.539 will be excluded from the analysis. In addition, no vectors comprising the intervals immediately preceding (0.547) and following (0.547) the interruption will be considered.
gmse -i 0 -I 50000 -c 1 < 16265.RR-filt > output
Coarse-graining method: mean (traditional MSE). Sample entropy parameters values m = 2, r = 0.15 (15% of SD of the original time series). The first 50,000 data points are considered.
The output values are:
Scale | SampEn | m3/m2 | r * SD |
1 | 1.1897 | 7253987/23837718 | 0.013203 |
2 | 1.3032 | 1600494/5891466 | 0.013203 |
3 | 1.4956 | 473897/2114637 | 0.013203 |
4 | 1.6527 | 179051/934800 | 0.013203 |
5 | 1.6506 | 117176/610500 | 0.013203 |
6 | 1.6294 | 85533/436301 | 0.013203 |
7 | 1.6505 | 57324/298632 | 0.013203 |
8 | 1.6164 | 47163/237466 | 0.013203 |
9 | 1.5821 | 40749/198244 | 0.013203 |
10 | 1.5895 | 31764/155689 | 0.013203 |
11 | 1.5332 | 28626/132628 | 0.013203 |
12 | 1.5297 | 24666/113877 | 0.013203 |
13 | 1.5189 | 21291/97245 | 0.013203 |
14 | 1.4899 | 18804/83427 | 0.013203 |
15 | 1.4710 | 16822/73235 | 0.013203 |
16 | 1.4687 | 14703/63866 | 0.013203 |
17 | 1.4734 | 12977/56633 | 0.013203 |
18 | 1.4482 | 11873/50527 | 0.013203 |
19 | 1.4621 | 9992/43114 | 0.013203 |
20 | 1.4319 | 9591/40155 | 0.013203 |
gmse -i 0 -I 50000 -r 0.2 -c 2 < 16265.RR-filt > output
Coarse-graining method: SD. Sample entropy parameters m = 2, r = 0.20 (20% of the coarse-grained time series for scale 5). This is the command line used to derive the results shown on the left panel of Fig. 2 and on the right panel of Fig. 5.
The output values are:
Scale | SampEn | m3/m2 | r * SD |
5 | 1.4648 | 307814/1331797 | 0.003835 |
6 | 1.5233 | 168245/771816 | 0.003835 |
7 | 1.5829 | 99565/484806 | 0.003835 |
8 | 1.6365 | 62961/323456 | 0.003835 |
9 | 1.7058 | 40966/225554 | 0.003835 |
10 | 1.7258 | 30256/169946 | 0.003835 |
11 | 1.7605 | 21967/127745 | 0.003835 |
12 | 1.8010 | 16915/102437 | 0.003835 |
13 | 1.8103 | 13668/83541 | 0.003835 |
14 | 1.8485 | 10580/67189 | 0.003835 |
15 | 1.8309 | 9132/56979 | 0.003835 |
16 | 1.8727 | 7565/49216 | 0.003835 |
17 | 1.8786 | 6460/42275 | 0.003835 |
18 | 1.8836 | 5632/37041 | 0.003835 |
19 | 1.8833 | 4867/32000 | 0.003835 |
20 | 1.9080 | 4180/28171 | 0.003835 |
gmse -i 0 -I 50000 -x 0.008 -c 4 < 16265.RR-filt > output
Mean absolute deviation is the chosen metric for coarse-graining. Sample entropy parameters m = 2, r = 0.008 (fixed, not a % of SD). This is the command line used to derive the results plotted on the right side panel of Fig. 3.
The output values are:
Scale | SampEn | m3/m2 | r * SD |
5 | 0.7032 | 3594655/7261796 | 0.008000 |
6 | 0.7591 | 2008629/4291038 | 0.008000 |
7 | 0.8139 | 1186303/2677237 | 0.008000 |
8 | 0.8624 | 767179/1817262 | 0.008000 |
9 | 0.9165 | 506521/1266507 | 0.008000 |
10 | 0.9311 | 380264/964870 | 0.008000 |
11 | 0.9756 | 273555/725658 | 0.008000 |
12 | 0.9891 | 217627/585165 | 0.008000 |
13 | 0.9915 | 177947/479594 | 0.008000 |
14 | 1.0232 | 140291/390320 | 0.008000 |
15 | 1.0296 | 117161/328049 | 0.008000 |
16 | 1.0236 | 104222/290078 | 0.008000 |
17 | 1.0395 | 89258/252412 | 0.008000 |
18 | 1.0468 | 77024/219414 | 0.008000 |
19 | 1.0332 | 68169/191564 | 0.008000 |
20 | 1.0375 | 60541/170863 | 0.008000 |
Madalena Costa (mcosta3@bidmc.harvard.edu)