From: Aino on 2 Mar 2010 06:22 Hello all, Matlab seems to calculate the nodes of the wavelet packet tree in the following order (A=approximation or lowpass+downsampling, D= detail or highpass+downsampling): level nodes 0 original signal 1 A1 D1 2 AA2 DA2 AD2 DD2 3 AAA3 DAA3 ADA3 DDA3 AAD3 DAD3 ADD3 DDD3 So, always A first, then D. I read this article that said that an intuitively pleasing way to view the wavelet packet tree would be to display the nodes at a given level so that they occur in increasing frequency order from left to right. Their tree was composed as follows: level nodes 0 original signal 1 A1 D1 2 AA2 DA2 DD2 AD2 3 AAA3 DAA3 DDA3 ADA3 DDD3 ADD3 AAD3 DAD3 I don't quite get how this is an increasing frequency order, but the decomposition figure that they had was quite intuitive. Is there an easy way of changing the bin order as it is in the latter tree? Thank You. -Aino
From: Wayne King on 2 Mar 2010 07:59 "Aino" <aino.tietavainen(a)removeThis.helsinki.fi> wrote in message <hmiscs$jcu$1(a)fred.mathworks.com>... > Hello all, > > Matlab seems to calculate the nodes of the wavelet packet tree in the following order (A=approximation or lowpass+downsampling, D= detail or highpass+downsampling): > > level nodes > 0 original signal > 1 A1 D1 > 2 AA2 DA2 AD2 DD2 > 3 AAA3 DAA3 ADA3 DDA3 AAD3 DAD3 ADD3 DDD3 > > So, always A first, then D. I read this article that said that an intuitively pleasing way to view the wavelet packet tree would be to display the nodes at a given level so that they occur in increasing frequency order from left to right. Their tree was composed as follows: > > level nodes > 0 original signal > 1 A1 D1 > 2 AA2 DA2 DD2 AD2 > 3 AAA3 DAA3 DDA3 ADA3 DDD3 ADD3 AAD3 DAD3 > > I don't quite get how this is an increasing frequency order, but the decomposition figure that they had was quite intuitive. Is there an easy way of changing the bin order as it is in the latter tree? > > Thank You. > > -Aino Hi Aino, because the natural ordering of the wavelet packets as defined by the inductive process does not lead to wavelet packets with increasing zero crossings (analogous to frequency). For example, plot the first 7 (in natural ordering) Haar wavelet packets: [wfun,xgrid] = wpfun('haar',7,5); for k=1:8 subplot(2,4,k); plot(xgrid,wfun(k,:)); grid on; title(['W ',num2str(k-1)]) end Count the number of zero crossings in the Haar wavelet packets. See how the natural ordering does not correspond to an increasing number of zero crossings? If you are using the wavemenu GUI, you can view a frequency ordering. You can also do this via the command line with wpviewcf x = sin(8*pi*[0:0.005:1]); T = wpdec(x,4,'db1'); wpviewcf(T,1) Hope that helps, Wayne
From: Aino on 3 Mar 2010 06:03 > Hi Aino, because the natural ordering of the wavelet packets as defined by the inductive process does not lead to wavelet packets with increasing zero crossings (analogous to frequency). For example, plot the first 7 (in natural ordering) Haar wavelet packets: > > [wfun,xgrid] = wpfun('haar',7,5); > for k=1:8 subplot(2,4,k); > plot(xgrid,wfun(k,:)); grid on; > title(['W ',num2str(k-1)]) > end > > Count the number of zero crossings in the Haar wavelet packets. See how the natural ordering does not correspond to an increasing number of zero crossings? > > If you are using the wavemenu GUI, you can view a frequency ordering. You can also do this via the command line with wpviewcf > > x = sin(8*pi*[0:0.005:1]); > T = wpdec(x,4,'db1'); > wpviewcf(T,1) > > Hope that helps, > Wayne Hi, thank you for your quick reply. I can see from your reply that I still have a lot to understand about wavelet packets.. The reason why I asked about the order of the nodes had to do with the way that I am used to plot them. Matlab has those plots that have only one column in the plot, like in your last example. I made a little code that plots the tree as it is structured: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Original signal with two main frequencies t=1:128; y=sin(2*pi*1/4*t)+sin(2*pi*1/8*t); figure;plot(t,y) %WPT level=5; wpt = wpdec(y,level,'haar'); TheMatrix=nan(2^level, level+1); for i=0:level stop=2^i-1; parts=2^level/2^i; for j=0:stop first=i*2^level+1; start =parts*j+first; stop=parts*(j+1)+first-1; y=wpcoef(wpt, [i j]); %Average energy E=1/(length(y))*dot(y,y); TheMatrix(start:stop)=E; end end TheMatrix=TheMatrix'; figure;imagesc(TheMatrix) colormap(gray) colorbar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% If the nodes would be organized as I suggested in my first post, the last row in the imagesc figure should have only two highlighted parts corresponding to the two frequencies of the original signal. Now the picture is a bit more scrambled. Is there any way of getting the two frequencies shown in the last row? -Aino
From: Wayne King on 3 Mar 2010 07:35 "Aino" <aino.tietavainen(a)removeThis.helsinki.fi> wrote in message <hmlfl9$n1g$1(a)fred.mathworks.com>... > > Hi Aino, because the natural ordering of the wavelet packets as defined by the inductive process does not lead to wavelet packets with increasing zero crossings (analogous to frequency). For example, plot the first 7 (in natural ordering) Haar wavelet packets: > > > > [wfun,xgrid] = wpfun('haar',7,5); > > for k=1:8 subplot(2,4,k); > > plot(xgrid,wfun(k,:)); grid on; > > title(['W ',num2str(k-1)]) > > end > > > > Count the number of zero crossings in the Haar wavelet packets. See how the natural ordering does not correspond to an increasing number of zero crossings? > > > > If you are using the wavemenu GUI, you can view a frequency ordering. You can also do this via the command line with wpviewcf > > > > x = sin(8*pi*[0:0.005:1]); > > T = wpdec(x,4,'db1'); > > wpviewcf(T,1) > > > > Hope that helps, > > Wayne > > Hi, > > thank you for your quick reply. I can see from your reply that I still have a lot to understand about wavelet packets.. The reason why I asked about the order of the nodes had to do with the way that I am used to plot them. Matlab has those plots that have only one column in the plot, like in your last example. I made a little code that plots the tree as it is structured: > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %Original signal with two main frequencies > t=1:128; > y=sin(2*pi*1/4*t)+sin(2*pi*1/8*t); > figure;plot(t,y) > > %WPT > level=5; > wpt = wpdec(y,level,'haar'); > > TheMatrix=nan(2^level, level+1); > for i=0:level > stop=2^i-1; > parts=2^level/2^i; > > for j=0:stop > > first=i*2^level+1; > start =parts*j+first; > stop=parts*(j+1)+first-1; > > y=wpcoef(wpt, [i j]); > > %Average energy > E=1/(length(y))*dot(y,y); > TheMatrix(start:stop)=E; > > end > end > > TheMatrix=TheMatrix'; > figure;imagesc(TheMatrix) > colormap(gray) > colorbar > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > If the nodes would be organized as I suggested in my first post, the last row in the imagesc figure should have only two highlighted parts corresponding to the two frequencies of the original signal. Now the picture is a bit more scrambled. Is there any way of getting the two frequencies shown in the last row? > > -Aino Hi Aino, if you want to see the two sine waves that last the entire duration of your time interval clearly why not use wpviewcf? t=1:128; y=sin(2*pi*1/4*t)+sin(2*pi*1/8*t); wpt = wpdec(y,level,'haar'); wpviewcf(wpt,1) Wayne
From: Aino on 24 Mar 2010 07:03
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hmll1o$8s9$1(a)fred.mathworks.com>... > "Aino" <aino.tietavainen(a)removeThis.helsinki.fi> wrote in message <hmlfl9$n1g$1(a)fred.mathworks.com>... > > > Hi Aino, because the natural ordering of the wavelet packets as defined by the inductive process does not lead to wavelet packets with increasing zero crossings (analogous to frequency). For example, plot the first 7 (in natural ordering) Haar wavelet packets: > > > > > > [wfun,xgrid] = wpfun('haar',7,5); > > > for k=1:8 subplot(2,4,k); > > > plot(xgrid,wfun(k,:)); grid on; > > > title(['W ',num2str(k-1)]) > > > end > > > > > > Count the number of zero crossings in the Haar wavelet packets. See how the natural ordering does not correspond to an increasing number of zero crossings? > > > > > > If you are using the wavemenu GUI, you can view a frequency ordering. You can also do this via the command line with wpviewcf > > > > > > x = sin(8*pi*[0:0.005:1]); > > > T = wpdec(x,4,'db1'); > > > wpviewcf(T,1) > > > > > > Hope that helps, > > > Wayne > > > > Hi, > > > > thank you for your quick reply. I can see from your reply that I still have a lot to understand about wavelet packets.. The reason why I asked about the order of the nodes had to do with the way that I am used to plot them. Matlab has those plots that have only one column in the plot, like in your last example. I made a little code that plots the tree as it is structured: > > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > %Original signal with two main frequencies > > t=1:128; > > y=sin(2*pi*1/4*t)+sin(2*pi*1/8*t); > > figure;plot(t,y) > > > > %WPT > > level=5; > > wpt = wpdec(y,level,'haar'); > > > > TheMatrix=nan(2^level, level+1); > > for i=0:level > > stop=2^i-1; > > parts=2^level/2^i; > > > > for j=0:stop > > > > first=i*2^level+1; > > start =parts*j+first; > > stop=parts*(j+1)+first-1; > > > > y=wpcoef(wpt, [i j]); > > > > %Average energy > > E=1/(length(y))*dot(y,y); > > TheMatrix(start:stop)=E; > > > > end > > end > > > > TheMatrix=TheMatrix'; > > figure;imagesc(TheMatrix) > > colormap(gray) > > colorbar > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > > > If the nodes would be organized as I suggested in my first post, the last row in the imagesc figure should have only two highlighted parts corresponding to the two frequencies of the original signal. Now the picture is a bit more scrambled. Is there any way of getting the two frequencies shown in the last row? > > > > -Aino > > Hi Aino, if you want to see the two sine waves that last the entire duration of your time interval clearly why not use wpviewcf? > > t=1:128; > y=sin(2*pi*1/4*t)+sin(2*pi*1/8*t); > wpt = wpdec(y,level,'haar'); > wpviewcf(wpt,1) > > Wayne Hi again, I believe that wpviewcf only shows the last row of the WPD. I need to see the whole tree in my application. What I am supposed to do is the same thing as in this link in Fig. 2: http://www.bearcave.com/misl/misl_tech/wavelets/packfreq/index.html I just can't figure out the right way of coding that. -Aino |