Skip to contents

Decomposes a signal by successive extraction of product functions, each obtained by repeated subtraction of a smoothed local mean and division by a smoothed local magnitude.

Usage

decomposeLMD(signal, maxIterations, envelopeTolerance, changeTolerance,
             maxSmoothPasses, maxModes = Inf)

Arguments

signal

Numeric vector of finite values without dim, in the units of the quantity. Positions are sample indices.

maxIterations

Whole number \(\ge 1\) of normalizations allowed in one product function. No default; the package tests use 200.

envelopeTolerance

Number \(\ge 0\); an extraction ends when the mean of \(|1 - a_q|\) over the samples is at most this value. No default; the package tests use 0.01.

changeTolerance

Number \(\ge 0\); an extraction ends when the mean of \(|s_{q-1} - s_q|\) is at most this value. No default; the package tests use 0.01.

maxSmoothPasses

Whole number \(\ge 1\) of passes of the moving average that smooths the local levels. No default; 12 is the number of passes that LMD 1.2.1 reaches by default.

maxModes

Whole number \(\ge 1\) or Inf, the limit of product functions; default Inf.

Details

The local levels of a function use as nodes its interior extrema and its first and last samples: consecutive nodes \(n_i, n_{i+1}\) give the mean \(m_i = (n_i + n_{i+1}) / 2\) and the magnitude \(a_i = |n_i - n_{i+1}| / 2\), held between the two nodes. Both levels are smoothed by a repeated uniform moving average whose half width follows from the largest gap between nodes and shrinks at the borders; passes repeat while two consecutive samples are equal, up to maxSmoothPasses.

From \(s_0 = r_{p-1}\), iteration \(q\) forms $$s_q = \frac{s_{q-1} - m_q}{a_q}$$ with the smoothed levels of \(s_{q-1}\). The extraction ends without that normalization, with converged TRUE, when one of the two tolerances is met; it ends with converged FALSE when \(s_{q-1}\) has at most one extremum or after maxIterations normalizations. With \(Q\) normalizations, the product function is \(a_1 \cdots a_Q s_Q\) and \(r_p = r_{p-1} - PF_p\). Before extraction \(p\) the decomposition ends with "terminalResidue" when \(r_{p-1}\) has at most one extremum and with "modeLimit" when \(p - 1\) equals maxModes. A product function combines an accumulated amplitude envelope with a normalized oscillation; this construction does not impose the IMF envelope conditions of EMD.

In the first iteration \(a_1\) and \(s_0 = r_{p-1}\) carry the units of the signal, so both tolerances compare magnitudes in those units with dimensionless quantities; the result depends on the unit only when the initial magnitude approaches 1 in that unit.

Value

A list with

modes

Double matrix, samples by product functions.

residue

Numeric vector, the final residue.

iterations

Integer vector, the number \(Q\) of normalizations of each product function.

converged

Logical vector by product function.

stopReason

"terminalResidue" or "modeLimit".

Conditions

A local magnitude that is not positive leaves the normalization undefined and stops the function with an error of class xemdZeroEnvelope.

References

Smith, J. S. (2005). The local mean decomposition and its application to EEG perception data. Journal of the Royal Society Interface, 2(5), 443–454. doi:10.1098/rsif.2005.0058

The local levels and the extraction of a product function are adapted from LMD 1.2.1 (Shubhra Prakash), revision ec11b721ec7b05f0137eeb67a619b28f62ef85a2, Apache License (>= 2); see the NOTICE file of the installed package.

Examples

Time <- seq(0, 9, length.out = 3000)
Signal <- sin(pi * Time) + sin(2 * pi * Time) + sin(6 * pi * Time) +
    0.5 * Time
OUT <- decomposeLMD(Signal, maxIterations = 200, envelopeTolerance = 0.01,
                    changeTolerance = 0.01, maxSmoothPasses = 12,
                    maxModes = 8)
dim(OUT$modes)
#> [1] 3000    3
OUT$iterations
#> [1] 1 2 2
OUT$stopReason
#> [1] "terminalResidue"