Forums

Cepstrum Help

Started by Raeldor November 23, 2010
Hi Guys,

I'm trying to calculate the cepstrum of a signal to see if I can find
some similarities between it and another signal.  I am doing the
following, but I'm not sure the data coming out looks quite right.  I
have an 8000hz signal and 512 sample window.  I am passing this to
FFTW and then on each result, doing...


                    float sample = (float)Math.Sqrt(Math.Pow(complex1,
2) + Math.Pow(complex2, 2));

to get the magnitude, and then

                    sample = (float)Math.Log(Math.Pow(sample, 2));

to get the log (as per what I've been reading on cepstrums in
wikipedia).  I then run the resulting array again through FFTW this
time with of course a 256 sample window, and then on each of the
results I again do...

                    float sample = (float)Math.Sqrt(Math.Pow(complex1,
2) + Math.Pow(complex2, 2));

to get the magnitude.

Am I missing something here, or do I have all the steps?

Thanks
Ray

On Nov 23, 11:01&#2013266080;pm, Raeldor <rael...@gmail.com> wrote:
> Hi Guys, > > I'm trying to calculate the cepstrum of a signal to see if I can find > some similarities between it and another signal. &#2013266080;
> Am I missing something here, or do I have all the steps?
As I recall, computing the cepstrum is a 3-stage procedure: 1) Compute the DFT of the data 2) Compute some logs of the DFT 3) Compute the IDFT of the LogDFT. You will of course need to verify this with a textbook. Apart from that, be aware that the cepstrum is a mess. A simplified log, like you seem to be doing, where the phase of the DFT is ignored, will cause you to mis-represent the signal and so the cepstra you compare might not correspond quite the way you think or suppose they do. Computing the 'exact' log of the complex DFT coefficients is an even greater mess, as you will be dealing with all kinds of uniqueness issues caused by the complex log not being well-behaved. There are very good reasons why the cepstrum is not used more than it actually is. You need to be aware of these reasons, and deal with every single one of them, to have any chance of succeeding. Rune
On Nov 23, 9:55&#2013266080;pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> On Nov 23, 11:01&#2013266080;pm, Raeldor <rael...@gmail.com> wrote: > > > Hi Guys, > > > I'm trying to calculate the cepstrum of a signal to see if I can find > > some similarities between it and another signal. &#2013266080; > > Am I missing something here, or do I have all the steps? > > As I recall, computing the cepstrum is a 3-stage procedure: > > 1) Compute the DFT of the data > 2) Compute some logs of the DFT > 3) Compute the IDFT of the LogDFT. > > You will of course need to verify this with a textbook. > > Apart from that, be aware that the cepstrum is a mess. > A simplified log, like you seem to be doing, where the > phase of the DFT is ignored, will cause you to mis-represent > the signal and so the cepstra you compare might not > correspond quite the way you think or suppose they do. > > Computing the 'exact' log of the complex DFT coefficients > is an even greater mess, as you will be dealing with all > kinds of uniqueness issues caused by the complex log not > being well-behaved. > > There are very good reasons why the cepstrum is not used > more than it actually is. You need to be aware of these > reasons, and deal with every single one of them, to have > any chance of succeeding. > > Rune
Thank you for your informative (and honest) reply. I'll try and look for other ways to find features first, but I may come back to this later if I can't see any other avenues. Thank you!
On Nov 24, 4:33&#2013266080;pm, Raeldor <rael...@gmail.com> wrote:
> On Nov 23, 9:55&#2013266080;pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> > There are very good reasons why the cepstrum is not used > > more than it actually is. You need to be aware of these > > reasons, and deal with every single one of them, to have > > any chance of succeeding. > > > Rune > > Thank you for your informative (and honest) reply. &#2013266080;
It's not about honesty, but reality. An idea is not good just because it is new or cool. Or arcane. Once you read up on a subject, you will find that most textbooks cover more or less the same subjects in more or less the same order - that's certainly the case with DSP. As you keep reading, you find all kinds of seemingly nifty tricks and ideas. Like the cepstrum. If you track the publishing history, you very often find that the ideas are old. I know the xcepstrum was extensively studied in the late '60s / early '70s, with some papers and textbooks published. But the material is nowhere to be seen in the textbooks, except as asides. Once you discover these kinds of things, start asking 'why': - Why isn't this idea covered in more depth in more places? - Why isn't this idea used in more applications? and so on. That way you very soon find reasons like I outlined about the cepstrum, and you know why to be cautious about the technique, and when it might be used. Rune
On Nov 24, 5:55&#2013266080;am, Rune Allnor <all...@tele.ntnu.no> wrote:
> On Nov 23, 11:01&#2013266080;pm, Raeldor <rael...@gmail.com> wrote: > > > Hi Guys, > > > I'm trying to calculate the cepstrum of a signal to see if I can find > > some similarities between it and another signal. &#2013266080; > > Am I missing something here, or do I have all the steps? > > As I recall, computing the cepstrum is a 3-stage procedure: > > 1) Compute the DFT of the data > 2) Compute some logs of the DFT > 3) Compute the IDFT of the LogDFT.
No, stage (3) is just a DFT. Cepstrum is the DFT of the log of the DFT. For implementation (real, complex, power etc) then yes you must look for the many variants. In case anyone is interested, I invented a similarly weird use of the DFT in ultrasound prostate (rectal) scanning that is called the 'sprectum'). :-) Chris ====================================== Chris Bore BORES Signal Processing www.bores.com
> > You will of course need to verify this with a textbook. > > Apart from that, be aware that the cepstrum is a mess. > A simplified log, like you seem to be doing, where the > phase of the DFT is ignored, will cause you to mis-represent > the signal and so the cepstra you compare might not > correspond quite the way you think or suppose they do. > > Computing the 'exact' log of the complex DFT coefficients > is an even greater mess, as you will be dealing with all > kinds of uniqueness issues caused by the complex log not > being well-behaved. > > There are very good reasons why the cepstrum is not used > more than it actually is. You need to be aware of these > reasons, and deal with every single one of them, to have > any chance of succeeding. > > Rune