I am learning signal processing and would like to know what's the python equivalent of matlab's cwtfilterbank.

I looked through pywt but did not find anything.

Some background information: I would like to process audio files with a CWT filter bank, where the wavelet filters are logarithmically spaced bandpass filters.

Many thanks in advance!


1 Answer 1


Avoid PyWavelets and scipy. ssqueezepy's (disclaimer, am author) scales='auto' is motivated similar to MATLAB's cwtfilterbank, and wavelets can be cached, inspected, and reused.

enter image description here

import numpy as np
from ssqueezepy import Wavelet, cwt
from ssqueezepy.utils import make_scales, cwt_scalebounds
from ssqueezepy.visuals import plot, imshow

# configure
signal_length = 4096
wavelet = Wavelet('morlet')

# make scales
min_scale, max_scale = cwt_scalebounds(wavelet, signal_length)
scales = make_scales(signal_length, scaletype='log', nv=8,
                     min_scale=min_scale, max_scale=max_scale)
# make filterbank
fbank = wavelet(scale=scales)

# take CWT
x = np.random.randn(signal_length)
Wx, _ = cwt(x, wavelet, scales=scales)

# visualize
plot(fbank.T, show=1, title="CWT filterbank")
imshow(Wx, title="|CWT(x)|", abs=1)
  • $\begingroup$ You did a great work on Wavelets. How come you fell into them so much? What was your motivation? $\endgroup$
    – Royi
    May 9, 2023 at 9:44
  • $\begingroup$ Cause I'm insane. And there's much more where that came from, soon, but I'm too busy beating people over the head on stonk exchange. May tell the rest another day. $\endgroup$ May 9, 2023 at 16:45
  • $\begingroup$ Moderately insane people are my kind of people. Please do share more. Enjoy the ride. $\endgroup$
    – Royi
    May 9, 2023 at 19:26

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.