1

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!

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
JXuan
  • 55
  • 6

1 Answers1

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

np.random.seed(0) 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)

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
  • You did a great work on Wavelets. How come you fell into them so much? What was your motivation? – Royi May 09 '23 at 09:44
  • 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. – OverLordGoldDragon May 09 '23 at 16:45
  • Moderately insane people are my kind of people. Please do share more. Enjoy the ride. – Royi May 09 '23 at 19:26