AI-generated summary of Continuous Wavelet Transform (CWT) of 1-D Signals using Python and MATLAB, Exploring Technologies. Not written or verified by the author.
Takeaways: Continuous Wavelet Transform (CWT) of 1-D Signals using Python and MATLAB
2022-03-04 · 35:59 · Source: https://www.youtube.com/watch?v=qoMDpSatG7M · Exploring Technologies
Gist
A recap of CWT theory, then a code walkthrough in Python (PyWavelets) and MATLAB. The CWT slides a wavelet along a signal at many scales and arranges the coefficients by time and scale into a scalogram. Small scales squeeze the wavelet and catch fast detail. Large scales stretch it and catch slow detail. Unlike a Fourier spectrum, the scalogram shows when a change happens, so the demos plant discontinuities in a cosine and find them in the plot. The lecturer also saves the scalogram as a 512×512 RGB image to feed a deep neural network, and explains the cone of influence: the edge region where coefficients can't be trusted.
All claims are the lecturer's. Summarized from YouTube auto-captions, which garble terms: "model at" / "marlette" for Morlet, "scalar gram" / "kilogram" / "skelogram" for scalogram, "fair blades" for wavelets, "hatch effect" for edge effect, "simlet5" for (likely) sym5. Slides and code not seen, so code details come from narration only. The lecturer points to their own earlier intro video on wavelet theory, not read here. Notes marked (mine) are mine. (checked) marks claims checked against the PyWavelets or MathWorks docs.
Takeaways
Theory recap
- A wavelet is a waveform of limited duration with zero mean: $\psi_{a,b}(t) = \frac{1}{\sqrt{a}}\psi!\left(\frac{t-b}{a}\right)$.
ais dilation (scale),bis translation (position). - CWT coefficients: $C(a,b) = \frac{1}{\sqrt{a}}\int_{-\infty}^{\infty} f(t),\psi!\left(\frac{t-b}{a}\right)dt$. The lecturer calls this an $L^2$ inner product.
- Lower scales: wavelet compressed, high frequency, captures fast-changing detail.
- Higher scales: wavelet stretched, low frequency, captures slow-varying detail.
- Scalogram: coefficient magnitude plotted over time × scale.
- Fourier of a signal whose frequency jumps shows two peaks but not when the jump happened. The scalogram's time axis shows when.
Applications
- DWT (contrast): compression and denoising mainly, plus machine-learning features and image work: edges, enhancement, fusion.
- CWT ("limited applications"):
- Spectral analysis via the scalogram: frequency breaks, time discontinuities, bursts, damping, vibration patterns.
- Scalogram as image input to a deep neural network, for classifying 1-D signals with networks built for images.
Python: PyWavelets
pywt.cwt(signal, scales, wavelet)returns coefficients and the wavelet frequency for each scale.scalesis an array, e.g. 1 to 31. Optionalmethodpicks convolution or FFT. The lecturer says the defaults are fine.- Ships with Anaconda, as do its dependencies NumPy, SciPy, and Matplotlib.
- Continuous wavelets: Mexican hat
mexh, Morletmorl, complex MorletcmorB-C, Gaussian derivativegausP(P = 1 to 8), complex Gaussian derivativecgauP, ShannonshanB-C, frequency B-splinefbspM-B-C. (checked against the pywt.cwt docs)pywt.wavelist(kind='continuous')lists them all. - Plot:
imshowofabs(coeffs), since coefficients can be complex. Interpolation smooths it, and the colormap matters (bone,copper,jet,gray).
Demo 1: a cosine distorted by two exponentials, Gaussian wavelet, scales 1 to 31.
Demo 2: a 10 ms cosine at 44.1 kHz with samples 87 to 89 forced to zero, scales 1 to 21, copper colormap. The output shows discontinuities at 2 ms and 7 ms, and both line up in the scalogram. The captions only describe the first (sample 87 ÷ 44,100 Hz ≈ 2 ms). (mine) How the 7 ms break is made isn't narrated.
MATLAB: two cwt functions
MATLAB picks between an older and a newer cwt based on the arguments you pass.
| Older | Newer | |
|---|---|---|
| Inputs | signal, scales, wavelet name, 'plot' | signal, wavelet name, sampling frequency or sampling period |
| Scales | You give them | MATLAB picks them automatically |
| Output | coefficients, frequencies; auto-plots scalogram | coefficients, plus frequencies or periods depending on input |
| Wavelets | Many (demo uses sym5, scales 1 to 200, default colormap pink) | Only Morse (default), Morlet (amor), bump |
- (checked, from a summary of the MathWorks
cwtpage, R2026b) Newer wavelets aremorse,amor,bump. The page says the old syntax "continues to work but is no longer recommended". The syntax changed in R2016b. - Second plot method in both demos:
pcolorofabs(cfs)withshading interp, y-axis on a log scale for the newer function. - The newer demo uses the 2 ms and 7 ms discontinuity signal and a "complex modulated" wavelet. (mine) Probably
amor, the only Morlet option.
Saving the scalogram as an image: rescale the coefficients to 0 to 1, convert with im2uint8, map to RGB with a colormap, then write scalogram.jpg at 512×512. This lets you turn a set of 1-D signals into scalogram images for DNN training.
Cone of influence (COI)
- The newer
cwtplot shades a gray region bounded by a dashed line: the COI. - It marks coefficients that edge effects might distort. There, the stretched wavelet extends past the ends of the signal, so only part of the wavelet overlaps it.
- Coefficients in the unshaded region are treated as an accurate time-frequency picture. Coefficients in the gray region are suspect.
- The COI widens at higher scales: a stretched wavelet is longer, so more positions overhang an edge.
Patterns
- a probe's size sets which detail it catches: small for fast, large for slow ← "capable of capturing a very fast changing"
- a summary that drops time tells what changed, not when ← "cannot tell that at what instant"
- recast 1-D data as an image to reuse tools built for images ← "scallogram can be utilized as an image"
- results are suspect where the probe overhangs the data's edge ← "areas where the stretched wavelet extend beyond"
- the bigger the probe, the wider its zone of untrustworthy edge results ← "this area is continuously increasing"
- plant a known defect to test whether a method finds it ← "so this becomes a discontinuity"
- one name, two behaviors, chosen silently by argument shape ← "it identifies by the input arguments"
- a newer tool picks parameters for you that the old one demanded ← "matlab computes the number of scales automatically"