laszukdawid / PyEMD

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

duplicate Issues #87

Closed codingMMax closed 2 years ago

codingMMax commented 3 years ago

Hello, I have been using PyEMD for my graduation project for Speech Noise Separation. At present, I want to decompose the input sample into several IMFs. However, when I call the function the error reports "ValueError: Expect x to not have duplicates" The code is shown below.

full_signal_EMD = EMD() 
full_signal = np.array(wave.signal)
full_signal_IMF = full_signal_EMD.emd(full_signal)

counter = full_signal_IMF.shape[0]+1
plt.figure(1)
for n, imf in enumerate(full_signal_IMF):
    plt.subplot(counter,1,n+1)
    plt.plot(imf,'g',label=" IMF"+str(n+1))
    plt.xlabel("Time[s]")
    plt.legend()
plt.tight_layout()
plt.show()

In the above code, the wave.signal is a (425241, ) array. When I slice the whole signal with signal [0:600] / signal [0:6000] the end() function works well. Is that because my input is too long and exceed the length limitation of PyEMD ?

laszukdawid commented 3 years ago

Hey @Max-H-JJ,

Sincere apologies for late reply. I understand that almost 3 months later might be too late. Hopefully it is, as it will mean that you were able to solve it, however, I'm replying in case others have a similar question/issue.

Regarding your problem: As you probably understood, the exception you mentioned is about having duplicate values in some array. You didn't paste the full stack trace so I can only guess that this is related to the timeline vector within the EMD. Recently it was brought to my attention, and was recently fixed, that when using a signal with integers (np.int16) there will be a wrap around in values, thus it will have duplicates. This might be what has happened in your case. Please see #90. This has been fixed. If you are still interested in decomposing your signals with PyEMD then please update it to the newest version.

Feel free to let us know on your progress with this.

laszukdawid commented 2 years ago

Closed since I haven't heard anything about this.