pywt
pywt copied to clipboard
Reconstructing details and approximations at all levels with ISWT
Hi,
I have been trying to reconstruct the details and approximations at all levels with inverse stationary wavelet transform using the code shown here:
https://stackoverflow.com/questions/69434307/inverse-stationary-wavelet-transform-with-pywavelets
However, it seems to be going wrong. To my understanding there is a way to reconstruct the levels and approximations at all levels for the discrete wavelet transform with pywt.upcoef(...)
Is there an analog for the stationary wavelet transform that I am not aware of?
@rgommers @arfon @nigma @matthew-brett
Hi, I am still struggling t=with this one. Could you provide some insight please? Is there an analog to pywt.upcoef when using ISWT? Thanks
PyWavelets 1.2 introduced a new set of multiresolution analysis functions. For the 1D case, see pywt.mra. I think that it might do what you want? (pywt.mra docs). If you are familiar with the Matlab Wavelet Toolbox, it is like the function modwtmra there.
The pywt.mra function uses the SWT in a way that provides an additive decomposition such that the original signal is a simple summation of the set of coefficients (you can see here that the inverse transform pywt.imra is just a single line of code that sums all of the coefficients). A beneficial property of this transform is that all of the coefficients will be temporally aligned, which is not the case for the standard SWT (that one is more similar to Matlab's modwt, although likely not identical in implementation).
There is a demo of use with an ECG signal available in this repository.
I should mention that this MRA function internally is using both SWT and ISWT where the ISWT is performed by setting one pair of coefficients to zeros as in the docs linked from your stackoverflow response.
@grlee77 Thank you for your reply! I was trying to get a power spectrum out of the details. However, the spectrum I am getting by applying the code you directed me to, does not seem to match the Fourier power spectrum of my time-series. Any idea why?
@grlee77 I guess this is because I am trying to estimate the power spectrum using the details in the real physical space. Is there any chance I could doobtain the coefficients of the details? Thanks!
If i understand clearly pywt.mra returns the Wavelet subspaces of a signal, preserving it length, and using the SWT.
The result is similar to modwtmra from matlab, but of course not similar to modwt, right?
Thanks in advance!