I have an input signal of 30000 samples. I perform the Stationary wavelet transform in python to get the 4th level od decomposition. Then I perform an array mathematical operation over the decomposed level and convert it back into time. When I perform that conversion back in time, I get the exact double length (60000) of the original signal. Why is that and how can I correct it?

To help you reproduce the issue, I paste here an example code:

x_n_preprocessed = np.zeros(30000)
g_m = np.ones(30000)
y_m_2 = pywt.swt(x_n_preprocessed, 'sym4', level=4)[3]
y_m_corrected = np.multiply(y_m_2[0], g_m)
# combine the noise-free signal coefficients into a single array
s_n_hat = pywt.idwt(y_m_2, None, 'sym4', 'smooth')

import matplotlib.pylab as plt

plt.plot(s_n_hat, 'red')
  • $\begingroup$ What’s the point of y_m_corrected? It’s not being used in your code. $\endgroup$
    – Jdip
    Mar 1, 2023 at 17:29
  • $\begingroup$ I'm sorry, I just adapted the code for testing it for debugging here. That is the correct coefficients from the wavelet decomposition that I want to get back in time. I changed it to the origin y_m_2 for simplicity. $\endgroup$
    – GGChe
    Mar 1, 2023 at 21:58
  • $\begingroup$ You need to read the documentation carefully, and probably spend some time understanding what the stationary wavelet transform is (and discrete wavelet transform, and how they differ). Your code does not make much sense. You're using y_m_2 as approximation coefficients in your call to idwt even though they're not... $\endgroup$
    – Jdip
    Mar 1, 2023 at 23:56
  • $\begingroup$ I do understand what the SWT but not the inverse reconstruction. This transformation comes from a scientific paper where, in their algorithm, they propose to perform linear algebra to the wavelet decomposed coefficients and finally, get them back in time to obtain the noise free signal. I am curious how they reconstruct the signal since it seems that in scipy, the three functions for inverse wavelet transform gives me the doblue size of my original signal. I provided approximation and detail coefficients $\endgroup$
    – GGChe
    Mar 2, 2023 at 7:51
  • $\begingroup$ Not in the code you’ve pasted… $\endgroup$
    – Jdip
    Mar 2, 2023 at 8:05

1 Answer 1


You're using the inverse discrete wavelet transform on a stationary wavelet transform output.

Try iswt instead.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.