laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

how many IMFs to expect? #88

Closed msamf closed 3 years ago

msamf commented 3 years ago

Hello,

I just had a quick question about how many IMFs I should be expecting. Coming off of a Matlab implementation, the number of extracted IMFs was dependent on the size of the input array, so I'm wondering if that's the same here. In running some tests with the EEG dataset I'm using, I extract only 2 IMFs, whereas I'd be expecting 10-15 with the same size of data in Matlab, and I'd like more IMFs such that I can separate as many rhythms as possible.

Thanks for any help!

laszukdawid commented 3 years ago

Hey,

In short: No, the number of IMFs isn't and shouldn't be dependent on the length of the signal. Easy example is a sinusoid.

EEG data isn't as simple as a sinusoid. It's closer to some (white) noise which has been shown to have number of IMFs close to log(N), where N is the number of data. In such a case, yes, you probably expect the number of imfs to be somehow related to the length of your data.

However, bare in mind that EMD is an empirical process. It doesn't specify what are the outcomes but rather how you create them. There are plenty of implementation details that affect the decomposition. In fact, the whole nature of iterative subtraction, huge number of time, is not very computer-friendly. See Loss of significance. In short, the more you subtract similar values, the higher error is resulting in a noise. I've taken care of some of these effects.

As for "I'd like more IMFs"... The assumption for EMD is that there is as many IMFs, Intrinsic Mode Functions, as they are. No more, no less. So you shouldn't be able to change the number. However(!), since EMD is an empirical process all of that is a bit wishy-washy. The number and the quality of IMFs depends on the process of extraction. In a sense, change some parameters of EMD and see what you get. You might be lucky. I'd suggest starting with changing the type of spline function (spline_kind) and changing conditions for accepting an IMF (either IMF of IMF_H).

Hope that helps :)