next up previous
Next: Effect of outliers on the MSE curves Up: Multiscale Entropy Analysis (MSE) Previous: MSE analysis of simulated white and 1/f noise


Software for MSE analysis

Download mse.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 mse -O mse.c -lm

Preparing data for MSE analysis

In this tutorial, we illustrate the use of mse to analyze time series of intervals between consecutive heart beats (RR intervals). RR interval lists as used by mse are in text format, consisting of one column (the RR intervals). Interval lists in this format can be prepared from beat annotation files using ann2rr. Use a command of the form:

    ann2rr -r RECORD -a ANNOTATOR -A -i s4 >RECORD.rr
where RECORD is the record name and ANNOTATOR is the annotator name of the beat annotation file you wish to study. (If you choose a PhysioBank record and have not previously downloaded the annotation file into a local directory, ann2rr obtains the annotations directly from PhysioNet. For details on the options used in this command, see ann2rr in the WFDB Applications Guide.) For example, the command line:
    ann2rr -r nsr2db/nsr040 -a ecg -A -i s4 >nsr040.rr
creates an interval list from the ecg beat annotations for record nsr040 of the Normal Sinus Rhythm RR Interval Database. The first few lines of output from this command are:


Of course, mse can accept text files containing any similarly formatted series; it is not restricted to use with RR interval time series.

Setting parameters for mse

In order to calculate entropy, the values of parameters m and r defining the pattern length and the similarity criterion [3] respectively, have to be fixed. The default values for these parameters are m = 2 and r = 0.15. The options -m and -r may be used to change the default values. It is possible to run MSE for a set of different m and r values using the options -M, -b, -R and -c, which specify, respectively, the maximum m value, the difference between consecutive m values, the maximum r value, and the difference between consecutive r values. For example, the command line:

    mse -m 2 -M 4 -b 1 -r 0.15 -R 0.2 -c 0.01 <nsr040.rr >nsr040.mse
calculates the MSE curves for the file nsr040.rr for all combinations of m (2, 3, and 4) and r (0.15, 0.16, 0.17, ..., 0.2) values.

The entire time series or a segment may be selected for the MSE analysis. By default the first 40,000 data points (or the entire time series if it contains fewer than 40,000 data points) are selected. The user may select a different segment using the options -i and -I that specify the first and the last points of the segment.

The MSE curve is calculated for a range of scales, typically from 1 to 20 data points. Each scale defines the length of the window used for building the coarse-grained time series. The user may change the maximum scale value and the difference between consecutive scale values using the options -n and -a respectively. For example, if we run the command line:

    mse -n 10 -a 2 <nsr040.rr >mse-nsr040
we obtain an output file (MSE-nsr040) containing:

    m = 2,  r = 0.150
    1       0.235
    3       0.192
    5       0.238
    7       0.257
    9       0.277
In this output, the first column contains the scale factors, and the second column provides the corresponding entropy values.

Several time series may be analyzed simultaneously with the option -F. For this purpose a list with the names of the data files (one per line) should be saved as a text file. For example, we can generate an RR interval series for record nsr047 following the same method as for nsr040, above, and then create a file named filelist, containing:

We can then process both of these files using mse by the command:
    mse -n 10 -a 2 -F filelist >filelist.mse
to obtain this output:
    m = 2,  r = 0.150
            nsr040  nsr047
    1       0.235   0.796
    3       0.192   1.053
    5       0.238   1.218
    7       0.257   1.228
    9       0.277   1.201
    Mean and SD over all files
            m=2, r=0.150
            mean    sd
    1       0.515   0.397
    3       0.623   0.609
    5       0.728   0.693
    7       0.742   0.686
    9       0.739   0.654
For each scale, the mean and the sample deviation of the entropy values over all data files are calculated.

Summary of options and default values for mse

Scale factor

-n: maximum scale factor (default: 20)

-a: difference between consecutive scale factors (default: 1)

Parameter m

-m: minimum m value (default: 2)

-M: maximum m value (default: 2)

-b: difference between consecutive m values (default: 1)

Parameter r

-r: minimum r value (default: 0.15)

-R: maximum r value (default: 0.15)

-c: difference between consecutive r values (default: 0.05)

Segment selection

-i: starting data point (default: 0)

-I: ending data point (default: 39999)

Multiple data files

-F: text file; each line lists the name of a data file

next up previous
Next: Effect of outliers on the MSE curves Up: Multiscale Entropy Analysis (MSE) Previous: MSE analysis of simulated white and 1/f noise
Madalena Costa (