8

I'm attempting to create a real-time scalogram (from a 1 dimensional signal) in the style of a spectrogram;

Looking through various papers+books; the Gabor wavelet, or complex Morlet seems to be favoured for keeping a close relation to frequency.

Though I was hoping to use a real valued wavelet though due to computational complexity concerns... What wavelet would be recommended?

daurnimator
  • 181
  • 5
  • I don't necessarily understand this, but maybe you can get your answer from the source code for this, which produces the output you want, though not in real-time: http://www.phy.uct.ac.za/courses/python/examples/Wavelets.py http://flic.kr/p/7oXfbT – endolith Mar 30 '12 at 19:28

3 Answers3

3

The mother wavelet of your scalogram should have a similar shape to the usual peak shapes you want to detect (I suppose you use it to detect peaks of your signal). However, I would like to ask you what would you like to use wavelets for? I could give you a more specific answer for your question.

  • 1
    I essentially want to create a spectrogram using wavelets instead of the STFT. So the 'shapes' I want to detect would just be sinusoids I guess... – daurnimator Mar 05 '12 at 09:20
  • I would use the same shape function g(t) in wavelet than in STFT. You could find differences between these two transforms in Doc. – Luis Andrés García Mar 05 '12 at 10:28
  • Do you mean that (eg) if I want something like an STFT using a Hamming window; my wavelet should be a modulated Hamming window? – daurnimator Mar 05 '12 at 12:43
  • 1
    that´s it. Mother wavelet (shape function) should be similar in both cases. – Luis Andrés García Mar 05 '12 at 13:00
  • Does that necessitate a complex window then? (where it's absolute value is = to the hamming window) Or can I just drop the imaginary component? – daurnimator Mar 06 '12 at 01:16
  • you can choose a simple window, but not drop in any case the imaginary component (it gives phase components, so the filtering would be distorted). – Luis Andrés García Mar 06 '12 at 07:48
  • sorry, I didn't understand that sentence. You mean I should not drop the imaginary component; as distortion will result? – daurnimator Mar 07 '12 at 04:32
  • If you use a complex window, use it, but in this case do not drop its imaginary component. – Luis Andrés García Mar 07 '12 at 07:27
  • If you compare to a complex sinusoid, like STFT does, then you will get a high peak no matter what the phase of your signal. If you use a real sinusoid, like the non-complex Morlet, you will get ripples in the scalogram as it shifts in and out of phase, which is not like a spectrogram: http://flic.kr/p/7oXfh6 – endolith Mar 30 '12 at 19:30
2

Unfortunately it's for 2D signals (image analysis), but I believe his conclusion would also apply to 1D signal. J.F. Kirby, "Which wavelet best reproduces the Fourier power spectrum?", Computers & Geosciences 31 (2005) 846–864

Basically, his conclusion is to go with the Fan wavelet, which is a 2D rotated version of the Morlet wavelet. In 1D, I'd suggest the complex Morlet. It's the mix of real and complex part that allows for a good similarity to a Fourier power spectrum.

In better precision, here what it should look like, converted to 1D from Kirby (2005): $$ \Psi = exp\Big(-\frac{ik_0x}{\lambda} - \frac{x^2}{2\lambda^2}\Big),$$ where $\lambda$ is the scale you're looking at, and $k_0=5.336$ is a constant selected to give the best "scale sampling" vs "frequency sampling". I didn't include the normalization constant because in every computational situation, it's better to just divide the final wavelet by its maximum value, and subtract its average. It gives pretty much the same result with less headache.

Basically, the complex Morlet wavelet is a Fourier transform "wave" ($exp(-i k_0 x/\lambda)$) bounded by a Gaussian kernel ($exp(-x^2/2)$). I suspect you might get a good power spectrum using only the real part (using $cos(x) \cdot exp(-x^2/2)$), but you would loose phase information.

Try comparing the spectrum obtained from a Fourier transform, from a complex Morlet and from a real Morlet. Watch out for bad/non-standard normalization found in many FFT algorithms.

PhilMacKay
  • 519
  • 2
  • 9
  • As noted in question; I need a real values wavelet. I ended up going with the discrete meyer FWIW. – daurnimator Sep 30 '12 at 04:13
  • Off course, if you cannot use complex values in your computations, the Morlet wavelet looses some of its charm...

    Still, the mathematics are not that much more complex, so when memory and computing power are not the limiting factor, I recommend to go with the Morlet.

    One of my friend/colleague made himself a program to compare, and if you take the average value of the wavelet transform at each scale, you end up with an exact copy of a Fourier power spectrum. Unfortunately, he has not published his results yet, so I do not have a source to cite (beside Kirby(2005)).

    – PhilMacKay Oct 01 '12 at 21:25
0

The discrete Meyer was my end choice; it provides a relatively clean sub-band separation.

daurnimator
  • 181
  • 5