pywt.cwt(data, scales, wavelet)

149 views
Skip to first unread message

Mohammad Mk

unread,
Apr 13, 2024, 5:57:51 AM4/13/24
to PyWavelets
Hello,

I am facing a problem in pywt.cwt function which calculate the continuous wavelet transform of a signal and as mentioned in the description of the function the second axis of the output, which represents the translation (in time) is the same as the input data, but sometimes when applying CWT we need to apply some strides to obtain fewer samples on the second axis.

For example:
We have a signal data with 10000 sample, if we apply pywt.cwt with 40 scales we obtain (40, 10000) output, but I don't need all the 10000, I need to apply a stride of 16 for example, so the output becomes (40,10000/16) = (40,625).

If any one worked on this before and could help me, it would be appreciated.

Thank you in advance!

Gautam Sinha

unread,
May 20, 2024, 5:04:02 PM5/20/24
to PyWavelets
Hi, 

From what I've studied and implemented, I know that CWT (in this case discretized CWT because scale parameter is discretized) in pywavelets computes the convolution for every single point in the data sample with the wavelet function. So, the number of data points on the time axis remains the same (or larger if padding is provided) in the time frequency plane.
Perhaps some post-processing is needed after obtaining the CWT matrix. Hope this helps.

Thoai Phan

unread,
Jun 2, 2024, 4:31:59 AM6/2/24
to PyWavelets
I am also interested in this matter currently. As you see in the formula of CWT, there is no translation parameter to adjust. Then if it computes for every single point of data, the complexity would be N^2log2(N), but still don't understand how the complexity of CWT is calculated.

Vào lúc 23:04:02 UTC+2 ngày Thứ Hai, 20 tháng 5, 2024, Gautam Sinha đã viết:

Mohammad Mk

unread,
Jun 2, 2024, 4:49:22 AM6/2/24
to PyWavelets
That's correct, there is no translation parameter to adjust in pywt.cwt. To solve the problem, you can take strides after calculating the Continuous Wavelet Transform (CWT) for the entire signal.

For example:
If we have a signal with 10,000 samples, and we apply pywt.cwt with 40 scales, we obtain a coefficient matrix "coeff" with the shape (40, 10000). However, the time complexity remains the same because you need to calculate the CWT for the entire signal first. After that, you can apply strides to the resulting matrix. For instance, with a stride of 16, you can use coeff = coeff [:,::16] to obtain a smaller matrix.

I hope this helps.

Thoai Phan

unread,
Jun 3, 2024, 10:07:44 AM6/3/24
to PyWavelets
Thanks Mohammad for the reply as well as the shared document.
My idea is to reduce the computational complexity of CWT, for e.g applying stride in CWT computation itself, not post computation.
That is the reason I am searching for how the translation parameter is used in CWT.
I am reading you shared document, in the mean time, if you could give me some hint, it would be very appreciated!


Vào lúc 10:49:22 UTC+2 ngày Chủ Nhật, 2 tháng 6, 2024, Mohammad Mk đã viết:
Reply all
Reply to author
Forward
0 new messages