# What is Empirical Mode Decomposition

Empirical Mode Decomposition (EMD) is a signal processing technique that decomposes a signal into its underlying oscillatory components, called Intrinsic Mode Functions (IMFs). It is a data-driven method that does not require prior knowledge of the signal’s frequency content or the characteristics of the underlying oscillations.

The EMD algorithm involves decomposing the signal into a series of IMFs, which are obtained through a process called sifting. Sifting involves identifying the local extrema of the signal and fitting an envelope to this extrema. The difference between the signal and its envelope is then computed, and the process is repeated on the difference until a locally smooth IMF is obtained.

The resulting IMFs represent different oscillations scales in the signal, with the first IMF capturing the highest-frequency oscillations and the last IMF capturing the lowest-frequency oscillations. The final residual signal, obtained after all the IMFs have been extracted, represents the trend of the original signal.

EMD has been used in a variety of applications, including signal denoising, feature extraction, and trend analysis. It is particularly effective in analyzing non-stationary signals, where the frequency content of the signal varies over time.

# Hilbert-Huang Transform (HHT)

The Hilbert-Huang Transform (HHT) is a signal processing technique that is used for analyzing non-stationary and nonlinear time-series data. It was developed by Norden E. Huang in the late 1990s as an alternative to traditional Fourier-based signal processing techniques.

The HHT is composed of two main components: the Empirical Mode Decomposition (EMD) and the Hilbert Spectral Analysis (HSA). The EMD is a method for decomposing a signal into a finite set of intrinsic mode functions (IMFs), which are the components of the signal that have a well-defined frequency range and are obtained through a process of sifting and averaging. The HSA involves applying the Hilbert transform to each of the IMFs to obtain the instantaneous frequency and amplitude of the signal.

The HHT has been used in a wide range of applications, including in the analysis of biological signals, financial time series, and climate data. It is particularly useful for analyzing data that has non-linear and non-stationary characteristics, such as in the case of signals with rapidly varying frequency components or those with abrupt changes in amplitude.

# Empirical Mode Decomposition (EMD)

The different steps involved in the Empirical Mode Decomposition (EMD) algorithm, in the order in which they are typically applied:

1. Sifting Process: The sifting process is the core of the EMD algorithm, where we extract each Intrinsic Mode Function (IMF) from the signal. In this process, we identify all the local maxima and minima of the signal and connect them to form the upper and lower envelopes, respectively. Then, we obtain the mean of the two envelopes as the local mean. We subtract this local mean from the original signal to obtain an oscillatory component called an IMF.
2. Stoppage Criterion: After each sifting process, we check whether the resulting IMF satisfies the “stoppage criterion.” This criterion is met when the IMF has no more than two extrema of the same sign, which indicates that the IMF contains a single oscillatory mode. If the criterion is not met, we repeat the sifting process until the criterion is satisfied.
3. Residual Component: After we have extracted all the IMFs, the residual component is obtained by subtracting the sum of all the IMFs from the original signal. The residual component represents the trend of the signal.
4. Repeat Steps 1–3: Steps 1–3 are repeated iteratively on the residual component until we obtain a final set of IMFs and a residual component that satisfies the stoppage criterion.
5. Post-Processing: Once we have obtained the IMFs and residual components, we can perform post-processing to improve the quality of the results. This can include smoothing the IMFs or the residual component, as well as removing any artifacts or noise.

Note that the exact implementation of the EMD algorithm can vary depending on the specific application and the algorithm used. However, these steps provide a general overview of the EMD process.

# Examples

Consider the following signals for a selected feature from the datasets the goal would be to find the extreme minima and maxima of the original signals.

Let’s zoom in on the first 100 indices and do the IMFs and picks on this range. Zoomed in on the original signals in the range of 1–100

Hence in the following, we plot the IMF (Zoomed in a range of 1 to 100 indices) with the top and lower picks of the signals and the average as well.

And various IMFs for the selected year and scaled [1, 100] as follows

Therefore, we will have the envelopes for the mentioned snippet of the signals

# sampling frequency

The sampling frequency (fs) is the number of samples of a signal that are taken per unit of time. It is typically measured in Hertz (Hz), which represents the number of samples per second. In digital signal processing, the sampling frequency is determined by the rate at which the signal is sampled or digitized.

For example, if you have a continuous analog signal that you want to sample and digitize, you would need to choose a sampling frequency that is high enough to capture the frequency content of the signal accurately. The Nyquist theorem states that the sampling frequency should be at least twice the maximum frequency of the signal to avoid aliasing.

Here’s an example of how to determine the sampling frequency for a specific signal. Let’s say you have an analog signal that has a maximum frequency component of 1000 Hz. To accurately capture this signal, you would need to choose a sampling frequency that is at least twice the maximum frequency, which in this case is 2000 Hz. A common choice for the sampling frequency would be 44100 Hz, which is the sampling frequency used for CD-quality audio.

In Python, you can use the `scipy.signal` library to resample a signal to a specific sampling frequency.

# Frequency

The Empirical Mode Decomposition (EMD) algorithm decomposes a signal into intrinsic mode functions (IMFs) that are supposed to capture different frequency components of the signal. In EMD, there is no a priori frequency selection, and the frequency content of each IMF is determined by the data itself.

After decomposing a signal into its IMFs using the EMD algorithm, we can calculate the frequency content of each IMF by performing a Hilbert transform on each IMF. The Hilbert transform provides the instantaneous frequency and phase of the signal at each point in time. This information can be used to identify and analyze the frequency components of the signal.

To use the EMD library in Python to calculate the frequency content of a signal:

`from scipy.signal import hilbertfrom scipy import signalfreqs = []phases = []for i in imf:    analytic_signal = hilbert(i)    freq = np.diff(np.unwrap(np.angle(analytic_signal)))/(2*np.pi)*fs    freqs.append(freq)    phase = np.angle(analytic_signal)    phases.append(phase)print(len(freqs))`

And here you can see an example of the extracted frequencies;

# measure the number of signals

In EMD, the number of intrinsic mode functions (IMFs) that are extracted during the decomposition of a signal is not fixed and can vary depending on the signal. However, some methods can be used to estimate the number of IMFs for a given signal.

One common method is to use the “sifting stopping criterion”, which is based on the fact that each IMF should have a well-defined characteristic scale or frequency range. The sifting process continues until the amplitude of the residue becomes smaller than a certain threshold relative to the amplitude of the input signal, or until the number of extrema and zero crossings in the residue no longer meets the requirements for an IMF.

Another method is to use a convergence criterion, which is based on the convergence of the Hilbert transform. The convergence criterion measures the difference between the instantaneous frequency of consecutive IMFs and stops the decomposition when the difference falls below a certain threshold.

There are also some empirical rules of thumb for estimating the number of IMFs, such as the “two-point criterion”, which states that the number of IMFs is equal to the number of zero crossings of the signal’s first derivative minus one.

However, it’s important to keep in mind that the number of IMFs is not always well-defined or unique, and may depend on the specific EMD algorithm used, the choice of stopping criterion, and the characteristics of the signal being decomposed. It’s often necessary to experiment with different decomposition parameters and visually inspect the resulting IMFs to determine the appropriate number for a given signal.

# changes in a signal

To determine if changes in a signal are daily or not, you can perform a time-frequency analysis using a method such as the continuous wavelet transform (CWT) or the short-time Fourier transform (STFT). These methods can help you identify any recurring patterns or oscillations in the signal that occur over a daily time scale.

For example, you can use the CWT to decompose the signal into time-frequency components and visualize the power spectrum using a spectrogram. The spectrogram can show you how the power of different frequency components changes over time. If you see prominent peaks or bands in the spectrogram at frequencies that correspond to daily rhythms, such as 24-hour cycles, then it’s likely that the changes in the signal are daily.

Conclusion

We have discussed various concepts related to signal processing and analysis, including the Hilbert-Huang Transform (HHT), Empirical Mode Decomposition (EMD), and frequency analysis using methods such as the continuous wavelet transform (CWT).

HHT is a signal processing technique that can be used to extract intrinsic mode functions (IMFs) from a signal, which can then be further analyzed to extract relevant information or features. EMD is a specific method for performing HHT that involves iteratively decomposing a signal into IMFs based on the local extrema and zero crossings of the signal.

Frequency analysis is a powerful tool for understanding the characteristics of a signal and identifying any recurring patterns or oscillations. CWT is a common method for performing time-frequency analysis of signals, which can help to identify any daily or periodic changes in the signal.

Overall, these techniques are widely used in various fields such as biomedical signal processing, finance, and image processing, among others, and can be applied to a wide range of signal-processing problems. However, it’s important to carefully choose the appropriate techniques and parameters for a given application and to carefully interpret the results in the context of the specific problem being solved.