Engee documentation

emd

Decomposition of the signal into empirical modes.

Library

EngeeDSP

Syntax

Function call

  • imf,residual = emd(x) — returns functions imf decomposition into Intrinsic Mode Function (IMF) and residual signal residual corresponding to the decomposition of the signal x in an empirical fashion. Use the function emd to decompose and simplify complex signals into a finite number of internal mode decomposition functions necessary to perform Hilbert spectral analysis.

  • imf,residual,info = emd(x) — returns additional information info about IMF and residual signal for diagnostic purposes.

  • ___ = emd(___,Name,Value) — decomposes the signal into empirical modes with additional parameters specified by one or more arguments of the type Name,Value.

  • emd(___;out=:plot) — Plots the original signal, IMF, and residual signal as separate graphs in one figure.

Arguments

Input arguments

# x is a time domain signal

+ vector

Details

A time domain signal defined as a vector of real values.

Name-value input arguments

Specify optional argument pairs as Name,Value, where Name — the name of the argument, and Value — the appropriate value. Name-value arguments should be placed after other arguments, but the order of the pairs does not matter.

Use commas to separate the name and value, and Name put it in quotation marks.

# SiftRelativeTolerance — Cauchy convergence criterion

+ 0.2 (by default) | positive scalar

Details

The Cauchy convergence criterion, defined as a comma-separated pair consisting of "SiftRelativeTolerance" and a positive scalar. Argument SiftRelativeTolerance It is one of the criteria for stopping screening, that is, screening stops when the current relative tolerance is less than the value SiftRelativeTolerance. For more information, see Relative screening tolerance.

# SiftMaxIterations — maximum number of screening iterations

+ 100 (by default) | a positive integer scalar

Details

The maximum number of screening iterations, set as a comma-separated pair consisting of "SiftMaxIterations" and a positive integer scalar. Argument SiftMaxIterations it is one of the criteria for stopping screening, that is, screening stops when the current number of iterations is greater than the value SiftMaxIterations.

Argument SiftMaxIterations It can only be specified with positive integers.

# MaxNumIMF — maximum number of IMFs extracted

+ 10 (by default) | a positive integer scalar

Details

The maximum number of extracted IMFs, specified as a comma-separated pair consisting of "MaxNumIMF" and a positive integer scalar. Argument MaxNumIMF It is one of the criteria for stopping decomposition, that is, decomposition stops when the number of generated IMFs is equal to MaxNumIMF.

Argument MaxNumIMF It can only be specified with positive integers.

# MaxNumExtrema — maximum number of extremes in the residual signal

+ 1 (by default) | a positive integer scalar

Details

The maximum number of extremes in the residual signal, defined as a comma-separated pair consisting of "MaxNumExtrema" and a positive integer scalar. Argument MaxNumExtrema It is one of the criteria for stopping decomposition, that is, decomposition stops when the number of extremes is less than the value MaxNumExtrema.

Argument MaxNumExtrema It can only be specified with positive integers.

# MaxEnergyRatio is the ratio of signal energy to residual energy

+ 20 (by default) | scalar

Details

The ratio of signal energy to residual energy, defined as a comma-separated pair consisting of "MaxEnergyRatio" and a scalar. Argument MaxEnergyRatio is the ratio of the energy of the signal at the beginning of screening to the average energy of the envelope. Argument MaxEnergyRatio It is one of the criteria for stopping decomposition, that is, decomposition stops when the current energy ratio is greater than the value MaxEnergyRatio. For more information, see The ratio of energies.

# Interpolation is an interpolation method for building an envelope

+ "spline" (by default) | "pchip"

Details

An interpolation method for constructing an envelope, specified as a pair separated by a comma, consisting of "Interpolation" and either "spline", or "pchip".

Set for the argument Interpolation one of the values is:

  • "spline" if x — smooth signal;

  • "pchip" if x — a non-smooth signal.

The interpolation method "spline" uses cubic splines, and "pchip" — piecewise cubic Hermite interpolation polynomials.

# Display — switching the information display in the command window

+ 0 (by default) | 1

Details

Switching the information display in the command window, set as a comma-separated pair consisting of "Display" and either 0, or 1. The data table generated in the command window indicates the number of screening iterations, the relative tolerance, and the screening stop criterion for each generated IMF. Set for the argument Display meaning 1 to display the table, or 0 to hide it.

# out — type of output data

+ :none (by default) | :plot

Details

Type of output data:

  • :none — the function returns data;

  • :plot — the function returns a graph.

Output arguments

# imf — decomposition function into internal modes

+ the matrix

Details

The Intrinsic Mode Function (IMF) returned as a matrix. Each IMF is an amplitude and frequency modulated signal with positive and slowly varying envelopes. For spectral analysis of a signal, you can apply the Hilbert—Huang transform to its IMF. For more information, see Decomposition functions into internal modes.

Argument imf it is returned as a matrix, each column of which is imf if x — vector.

# residual — residual signal

+ column vector

Details

The residual signal returned as a column vector. Argument residual represents a part of the original signal x, not decomposed by the function emd.

Argument residual it is returned as a column vector if x — vector.

# info — additional diagnostic information

+ structure

Details

Additional diagnostic information returned as a structure with the following fields:

  • NumIMF — the number of IMFs extracted;

    NumIMF — vector from before , where — the number of IMF. If IMFs are not extracted, NumIMF empty;

  • NumExtrema — the number of extremes in each IMF;

    NumExtrema is a vector whose length is equal to the number of IMF. -th element of the argument NumExtrema is the number of extremes found in -th IMF. If IMFs are not extracted, NumExtrema empty;

  • NumZerocrossing — the number of zero crossings in each IMF;

    The number of zero crossings in each IMF. NumZerocrossing is a vector whose length is equal to the number of IMF. -th element of the argument NumZerocrossing is the number of zero crossings in -th IMF. If IMFs are not extracted, NumZerocrossing empty;

  • NumSifting — the number of screening iterations used to extract each IMF;

    NumSifting is a vector whose length is equal to the number of IMF. -th element of the argument NumSifting is the number of screening iterations used in the extraction -th IMF. If IMFs are not extracted, NumSifting empty;

  • MeanEnvelopeEnergy — the energy of the average value of the upper and lower envelopes obtained for each IMF;

    If UE — the upper envelope, and LE — lower, then the value of the argument MeanEnvelopeEnergy equally mean(((LE+UE)/2).^2). MeanEnvelopeEnergy is a vector whose length is equal to the number of IMF. -th element of the argument MeanEnvelopeEnergy is the average energy of the envelope for -th IMF. If IMFs are not extracted, MeanEnvelopeEnergy empty;

  • RelativeTolerance — the final relative tolerance of the remainder for each IMF;

    The relative tolerance is defined as the ratio of the square of the second norm of the difference between the remainder from the previous screening stage and the remainder from the current screening stage to the square of the second norm of the remainder from -the th screening step. The screening process stops when the value RelativeTolerance less value SiftRelativeTolerance. For more information, see Relative screening tolerance. RelativeTolerance is a vector whose length is equal to the number of IMF. -th element of the argument RelativeTolerance — this is the final relative tolerance obtained for -th IMF. If IMFs are not extracted, RelativeTolerance empty.

Examples

Zero crossings and extremes in the decomposition function into internal sinusoid modes

Details

This trigonometric identity represents two different views of the same scalar signal.:

Generate two sinusoids, s and z, so that s it was the sum of three sine waves, and z — one sine wave with a modulated amplitude. Let’s make sure that the two signals are equal by calculating the norm of their difference, which is equal to infinity.

import EngeeDSP.Functions: norm

t = 0:1e-3:10
omega1 = 2π*100
omega2 = 2π*20
s = 0.25*cos.((omega1-omega2)*t) + 2.5*cos.(omega1*t) + 0.25*cos.((omega1+omega2)*t)
z = (2 .+ cos.(omega2/2*t).^2) .* cos.(omega1*t)

norm(s-z,Inf)
3.2740476996195866e-13

Let’s plot the sinusoids and select the interval in 1 one second, starting from 2 seconds.

plot(t, [s z],
     xlim = (2, 3),
     xlabel = "Time (s)",
     ylabel = "Signal")

emd 1

Using the function emd to calculate the functions of decomposition into internal modes (Intrinsic Mode Function, IMF) of the signal and additional diagnostic information. By default, the function outputs data indicating the number of screening iterations, the relative error, and the screening stop criterion for each IMF. Decomposition into empirical modes considers the signal as z.

import EngeeDSP.Functions: emd

imf, _, info = emd(s)

The number of zero crossings and local extremes differs by no more than one. This satisfies the necessary condition for the signal to be IMF.

info["NumZerocrossing"] - info["NumExtrema"]
1-element Vector{Float64}:
 1.0

Let’s plot the IMF graph and select the interval in 0.5 seconds, starting from 2 seconds. The IMF is an AM signal because the function emd considers this signal to be amplitude-modulated.

plot(t, imf,
     xlim = (2, 2.5),
     xlabel = "Time (s)",
     ylabel = "IMF")

emd 2

Additional Info

The method of signal decomposition into empirical modes

Details

The algorithm of signal decomposition into empirical modes (EMD) decomposes the signal decomposition functions into Intrinsic Mode Function (IMF) and remainder in an iterative process. The main component of the algorithm is to eliminate the function to get a new feature :

  • First, find the local minima and maxima of the function ;

  • Then use the local extremes to build the lower and upper envelopes. and accordingly, for the function . Generate the average value of the envelopes ;

  • Subtract the average from to get the remainder: .

In short, the decomposition looks like this.

  1. To begin with, let , where — the initial signal, and let .

  2. Before screening, check :

    1. Find the total number local extremes of the function .

    2. Find the energy ratio for the function (see the The ratio of energies section).

  3. If MaxEnergyRatio, or MaxNumExtrema, or the number of IMF MaxNumIMF, then stop the decomposition.

  4. Let .

  5. Filter out to get .

  6. Check :

    1. Find the relative tolerance functions (see Relative screening tolerance).

    2. Get the current number of the screening iteration .

  7. If SiftRelativeTolerance or SiftMaxIterations), then stop screening. IMF found: . Иначе, пусть and go to step 5.

  8. Let .

  9. Let . Return to step 2.

For more information, see [1] and [3].

Decomposition functions into internal modes

Details

The EMD algorithm decomposes the signal for internal mods and the residual function through an iterative screening process:

When Huang et al. [1] first introduced IMF, it was defined as a function with two characteristics:

  • the number of local extremes — the total number of local minima and local maxima — and the number of zero crossings differ by no more than one;

  • The average value of the upper and lower envelopes constructed on the basis of local extremes is zero.

However, as noted in [4], screening before obtaining a strict IMF can lead to IMF having no physical meaning. In particular, filtering out until the number of zero crossings and local extremes differs by less than one can lead to IMFs similar to pure tones, in other words, to functions very similar to those that would be obtained by projection onto the Fourier basis. This is exactly the situation that the EMD algorithm seeks to avoid by preferring AM-FM modulated components because of their physical meaning.

The link [4] offers options for obtaining physically significant results. Function emd weakens the original definition of IMF by using Relative screening tolerance, the Cauchy convergence criterion. Function emd iteratively extracts natural AM-FM modes. The generated IMFs may not meet the criteria of local extremum and zero crossing. See the example Zero crossings and extremes in the decomposition function into internal sinusoid modes.

Relative screening tolerance

Details

The relative elimination tolerance is the Cauchy convergence criterion proposed in [4]. Screening stops when the current relative tolerance is less than the value of the argument. SiftRelativeTolerance. The current relative tolerance is defined as

Since the Cauchy criterion does not directly take into account the number of zero crossings and local extrema, it is possible that the IMF obtained as a result of decomposition does not satisfy the strict definition of the decomposition function into internal modes. In such cases, you can try to reduce the value of the argument. SiftRelativeTolerance compared to its default value. For a detailed discussion of the stopping criteria, see [4]. This link also discusses the advantages and disadvantages of insisting on strictly defined IMFs when decomposed into empirical modes.

The ratio of energies

Details

The energy ratio is the ratio of the energy of the signal at the beginning of screening to the average energy of the envelope [2]. Decomposition stops when the current energy ratio is greater than the value of the argument. MaxEnergyRatio. For The -th IMF energy ratio is defined as

Literature

  1. Huang, Norden E., Zheng Shen, Steven R. Long, Manli C. Wu, Hsing H. Shih, Quanan Zheng, Nai-Chyuan Yen, Chi Chao Tung, and Henry H. Liu. «The Empirical Mode Decomposition and the Hilbert Spectrum for Nonlinear and Non-Stationary Time Series Analysis.» Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences 454, no. 1971 (March 8, 1998): 903–995. https://doi.org/10.1098/rspa.1998.0193.

  2. Rato, R.T., M.D. Ortigueira, and A.G. Batista. «On the HHT, Its Problems, and Some Solutions.» Mechanical Systems and Signal Processing 22, no. 6 (August 2008): 1374–1394. https://doi.org/10.1016/j.ymssp.2007.11.028.

  3. Rilling, Gabriel, Patrick Flandrin, and Paulo Gonçalves. «On Empirical Mode Decomposition and Its Algorithms.» IEEE-EURASIP Workshop on Nonlinear Signal and Image Processing 2003. NSIP-03. Grado, Italy. 8–11.

  4. Wang, Gang, Xian-Yao Chen, Fang-Li Qiao, Zhaohua Wu, and Norden E. Huang. «On Intrinsic Mode Function.» Advances in Adaptive Data Analysis 02, no. 03 (July 2010): 277–293. https://doi.org/10.1142/S1793536910000549.