Wavelet Packet Transform in Mathematica 7 and 8

5

0

For finding location of spikes in a time series I used to transform the data into wavelet space using

DiscreteWaveletPacketTransform [ data, filter, 0] 

and then shrink the basis using the universal threshold in Mathematica version 7 and now every single command, corresponding to wavelets, is changed in version 8.

Is there anybody who can tell me how can I do in version 8 again? I guess I need to use WaveletBestBasis command, but how?

K-1

Posted 2012-03-09T03:01:03.110

Reputation: 571

From the docs it seems this function was not available in version 7. If you were using the Wavelet Explorer add-on in version 7, this guide should help in finding the equivalent commands.

– Szabolcs – 2012-03-09T14:24:01.063

Answers

9

After consulting a friend of mine P.M. I can tell you this. First of all as @Szabolcs @ruebenko already mentions - in order to get a comparison with Wavelet explorer (v7) to v8, you can go to the following link in the documentation center which shows how the syntax has changed:

http://reference.wolfram.com/mathematica/Compatibility/tutorial/WaveletExplorer.html

For the problem at hand, if you want location of the spike, perhaps using continuous wavelet transform might give the result easily. Here is an example:

data = N@Table[Sin[4 \[Pi] t] + 2 Exp[-10^5 (1/3 - t)^2], {t, 0, 1, 0.001}];
cwd = ContinuousWaveletTransform[data, PaulWavelet[5], {8, 8}];
ws = WaveletScalogram[cwd, ColorFunction -> "AvocadoColors"];
posData = Abs[{3, 1} /. cwd[{3, 1}]];
positionOfSpike = Position[posData, Max[posData]];
Print["Spike is at  " <> ToString[positionOfSpike[[1, 1]]]]
Row[{ws, ListLinePlot[posData, PlotRange -> All]}]

enter image description here

However, for multiple spikes, he may have to make careful use of a local FindMaximum. Another useful thing is this:

data = N@Table[
    Sin[4 \[Pi] t] + 2 Exp[-10^5 (1/3 - t)^2], {t, 0, 1, 0.001}];
dwd = DiscreteWaveletPacketTransform[data, Automatic, 5];
Manipulate[
 tmp = WaveletThreshold[
   WaveletBestBasis[dwd, {"Threshold", bestBasisThreshold}], {"Hard", 
    waveletThreshold}];
 recon = InverseWaveletTransform[tmp];
 GraphicsRow[{ListLinePlot[recon, PlotLabel -> "Reconstruction"], 
   ListLinePlot[data - recon, PlotLabel -> "Error"]}, 
  ImageSize -> 500], {bestBasisThreshold, 0.001, 0.99, 
  Appearance -> "Labeled"}, {waveletThreshold, 0.001, 0.99, 
  Appearance -> "Labeled"}]

enter image description here

The manipulate above shows the interplay between wavelet best basis and wavelet threshold. For more information, we would recommend going to the documentation page:

WaveletBestBasis > Applications > Compressions.

and go through the examples.

Vitaliy Kaurov

Posted 2012-03-09T03:01:03.110

Reputation: 66 672

Thank you Vitaliy but actually the stress in my question was on zero decomposition level, as seen DiscreteWaveletPacketTransform [data, filter, 0] – K-1 – 2012-04-24T04:35:55.747

5

Perhaps this helps:

(* data *)
data = Table[Sin[4 \[Pi] t] + RandomReal[0.1], {t, 0., 1, 1/2^9}];
data[[200]] = 1.5;
ListLinePlot[data]

(* fourier based *)
dft = Fourier[data];
fdft = Chop[dft, 0.2];
ftdata = InverseFourier[fdft];
ListLinePlot[ftdata]

(* wavelet based *)
dwt = DiscreteWaveletTransform[data, DaubechiesWavelet[4]];
fdwt = WaveletThreshold[dwt];
wtdata = InverseWaveletTransform[fdwt];
ListLinePlot[wtdata]

Also, have a look at the upgrading tutorial: Compatibility/tutorial/WaveletExplorer

user21

Posted 2012-03-09T03:01:03.110

Reputation: