laszukdawid / PyEMD

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

Obtain Residual value of last IMF #24

Closed nazmibojan closed 6 years ago

nazmibojan commented 6 years ago

Hallo @laszukdawid ,

I just open new issue because this is a different topic. I use EMD to implement denoising to an input signal. To reconstruct a new signal, we have to sum qualified IMFs and residual of EMD process. How can I get the residual value using this library? Thank you.

Regards, Nazmi

laszukdawid commented 6 years ago

Hey, If you take a look at the result of EMD you'll see that it returns a NumPy array. Simply select whichever IMFs you like. Quick example:

from PyEMD import EMD
s = np.random.random(100)  # generate random signal
emd = EMD()
imfs = emd(s, max_imf=3)  # Force max 3 IMFs
noise = imfs[0]  # First IMF
denoised_signal = np.sum(imfs[1:], axis=0)  # Sum of all but first IMF
nazmibojan commented 6 years ago

Okay, thank you for the answer, I think that code is very useful. But, the denoised signal are sum of qualified IMF + Signal Residual. As we know, the signal residual was the remainder/residual of last sifting process that produce last IMF. Or the last IMF is the residual of sifting process in this library? Thank you.

Regards, Nazmi

*PS: This paper describes denoising process using EMD.

laszukdawid commented 6 years ago

The last row in the array is the residue.

The noise is whatever you decide shouldn't be in the signal. Depends on the signal and model that generated it but typically it's the first IMF which is considered the noise. (Not necessarily the only one.) If you want to detrend then also remove residue (or other slow components).

nazmibojan commented 6 years ago

Great! Thank you very much @laszukdawid for this awesome library. Good luck for you.

Regards, Nazmi