Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

modwptdetails

Maximal overlap discrete wavelet packet transform details

Syntax

w = modwptdetails(x)
w = modwptdetails(x,wname)
w = modwptdetails(x,lo,hi)
w = modwptdetails(___,lev)
[w,packetlevs] = modwptdetails(___)
[w,packetlevs,cfreq] = modwptdetails(___)
[___] = modwptdetails(___,Name,Value)

Description

example

w = modwptdetails(x) returns the maximal overlap discrete wavelet packet transform (MODWPT) details for the 1-D real-valued signal, x. The MODWPT details provide zero-phase filtering of the signal. By default, modwptdetails returns only the terminal nodes, which are at level 4 or at level floor(log2(numel(x))), whichever is smaller.

Note

To decide whether to use modwptdetails or modwpt, consider the type of data analysis you need to perform. For applications that require time alignment, such as nonparametric regression analysis, use modwptdetails. For applications where you want to analyze the energy levels in different packets, use modwpt. For more information, see Algorithms

example

w = modwptdetails(x,wname) uses the orthogonal wavelet filter specified by the character vector wname.

example

w = modwptdetails(x,lo,hi) uses the orthogonal scaling filter, lo, and wavelet filter, hi.

w = modwptdetails(___,lev) returns the terminal nodes of the wavelet packet tree at positive integer level lev.

example

[w,packetlevs] = modwptdetails(___) returns a vector of transform levels corresponding to the rows of w.

[w,packetlevs,cfreq] = modwptdetails(___) returns, w, the center frequencies of the approximate passbands corresponding to the MODWPT details in .

example

[___] = modwptdetails(___,Name,Value) returns the MODWPT with additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

Obtain the MODWPT of an electrocardiogram (ECG) signal using the default length 18 Fejer-Korovkin ('fk18') wavelet and the default level, 4.

load wecg;
wptdetails = modwptdetails(wecg);

Demonstrate that summing the MODWPT details over each sample reconstructs the signal. The largest absolute difference between the original signal and the reconstruction is on the order of , which demonstrates perfect reconstruction.

xrec = sum(wptdetails);
max(abs(wecg-xrec'))
ans = 1.7903e-11

Obtain the MODWPT details for a signal containing 100 Hz and 450 Hz sine waves. Each row of the modwptdetails output corresponds to a separate frequency band.

dt = 0.001;
fs = 1/dt;
t = 0:dt:1;
x = (sin(2*pi*100*t)+sin(2*pi*450*t));
[lo,hi] = wfilters('fk22');
wptdetails = modwptdetails(x,lo,hi);

Use modwpt to obtain the energy and center frequencies of the signal. Plot the energy in the wavelet packets. The fourth and fifteenth frequency bands contain most of the energy. Other frequency bands have significantly less energy. The frequency ranges of fourth and fifteenth bands are approximately 94-125 Hz and 438-469 Hz, respectively.

[wpt,~,cfreqs,energy] = modwpt(x,lo,hi);
figure
bar(1:16,energy);
xlabel('Packet')
ylabel('Packet Energy')
title('Energy by Wavelet Packet')

Plot the power spectral density of the input signal.

pwelch(x,[],[],[],fs,'onesided');
title('Power Spectral Density of Input Signal')

Show that the MODWPT details have zero-phase shift from the 100 Hz input sine.

p4 = wptdetails(4,:);
plot(t,sin(2*pi*100*t).*(t>0.3 & t<0.7))
hold on
plot(t,p4.*(t>0.3 & t<0.7),'r')
legend('Sine Wave','MODWPT Details')

Obtain the MODWPT details for a 100 Hz time-localized sine wave in noise. The sampling rate is 1000 Hz. Obtain the MODWPT at level 4 using the length 22 Fejer-Korovkin ('fk22') wavelet.

dt = 0.001;     
t = 0:dt:1;
x = cos(2*pi*100*t).*(t>0.3 & t<0.7)+0.25*randn(size(t));
wptdetails = modwptdetails(x,'fk22');
p4 = wptdetails(4,:);

Plot the MODWPT details for level 4, packet number 4. The MODWPT details represent zero-phase filtering of the input signal with an approximate passband of , where is the sampling frequency.

plot(t,cos(2*pi*100*t).*(t>0.3 & t<0.7));
hold on
plot(t,p4,'r')
legend('Sine Wave','MODWPT Details')

Obtain the MODWPT details of an ECG waveform using the length 18 Fejer-Korovkin scaling and wavelet filters.

load wecg; 
[lo,hi] = wfilters('fk18');
wpt = modwptdetails(wecg,lo,hi);

Obtain the MODWPT details for the full wavelet packet tree of an ECG waveform. Use the default length 18 Fejer-Korovkin ('fk18') wavelet. Extract and plot the node coefficients at level 3, node 2.

load wecg;     
[w,packetlevels] = modwptdetails(wecg,'FullTree',true);
p3 = w(packetlevels==3,:);
plot(p3(3,:))
title('Level 3, Node 2 MODWPT Details')

Input Arguments

collapse all

Input signal, specified as a real-valued row or column vector. x must have at least two elements.

Data Types: double

Analyzing wavelet filter, specified as a character vector that corresponds to an orthogonal wavelet.

Valid orthogonal wavelet families begin with one of the following character vectors, followed by an integer, N. For example, sym4.

  • 'haarN' — Haar wavelet with N vanishing moments

  • 'dbN' — Daubechies wavelet with N vanishing moments

  • 'symN' — Symlets wavelet with N vanishing moments

  • 'coifN' — Coiflets wavelet with N vanishing moments

  • 'fkN' — Fejer-Korovkin wavelet with N coefficients

To check if your wavelet is orthogonal, use wavemngr('type',wname) and verify that it returns 1 as the wavelet type. To determine valid values for N, use waveinfo. For example, waveinfo('fk').

Scaling filter, specified as an even-length real-valued vector. lo must satisfy the conditions necessary to generate an orthogonal scaling function. You can specify the lo and hi scaling-wavelet filter pair only if you do not specify wname.

Wavelet filter, specified as an even-length real-valued vector. hi must satisfy the conditions necessary to generate an orthogonal wavelet. You can specify the lo and hi scaling-wavelet filter pair only if you do not specify wname.

Transform level, specified as a positive integer less than or equal to floor(log2(numel(x))).

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Fulltree',true returns the full wavelet packet tree

collapse all

Option to return full wavelet packet tree details, specified as the comma-separated pair consisting of 'FullTree' and either false or true. If you specify false, then modwptdetails returns details about only the terminal (final-level) wavelet packet nodes. If you specify true, then modwptdetails returns details about the full wavelet packet tree down to the default or specified level.

For the full wavelet packet tree, w is a 2j+1-2-by-numel(x) matrix. Each level, j, has 2j wavelet packet details.

Output Arguments

collapse all

Wavelet packet tree details, returned as a matrix with each row containing the sequency-ordered wavelet packet details for the terminal nodes. The terminal nodes are at level 4 or at level floor(log2(numel(x))), whichever is smaller. The MODWPT details are zero-phase-filtered projections of the signal onto the subspaces corresponding to the wavelet packet nodes. The sum of the MODWPT details over each sample reconstructs the original signal.

For the default terminal nodes, w is a 2j-by-numel(x) matrix. For the full packet table, at level j, w is a 2j+1-2-by-numel(x) matrix of sequency-ordered wavelet packet coefficients by level and index. The approximate passband for the nth row of w at level j is [n12(j+1),n2(j+1)) cycles per sample, where n = 1,2,...,2j.

Transform levels, returned as a vector. The levels correspond to the rows of w. If w contains only the terminal level coefficients, packetlevs is a vector of constants equal to the terminal level. If w contains the full wavelet packet tree of details, packetlevs is a vector with 2j-1 elements for each level, j. To select all the MODWPT details at a particular level, use packetlevs with logical indexing.

Center frequencies of the approximate passbands in the w rows, returned as a vector. The center frequencies are in cycles per sample. To convert the units to cycles per unit time, multiply cfreq by the sampling frequency.

Algorithms

The MODWPT details (modwptdetails) are the result of zero-phase filtering of the signal. The features in the MODWPT details align exactly with features in the input signal. For a given level, summing the details for each sample returns the exact original signal.

The output of the MODWPT (modwpt) is time delayed compared to the input signal. Most filters used to obtain the MODWPT have a nonlinear phase response, which makes compensating for the time delay difficult. All orthogonal scaling and wavelet filters have this response, except the Haar wavelet. It is possible to time align the coefficients with the signal features, but the result is an approximation, not an exact alignment with the original signal. The MODWPT partitions the energy among the wavelet packets at each level. The sum of the energy over all the packets equals the total energy of the input signal.

References

[1] Percival, D. B., and A. T. Walden. Wavelet Methods for Time Series Analysis. Cambridge, UK: Cambridge University Press, 2000.

[2] Walden, A.T., and A. Contreras Cristan. “The phase-corrected undecimated discrete wavelet packet transform and its application to interpreting the timing of events.” Proceedings of the Royal Society of London A. Vol. 454, Issue 1976, 1998, pp. 2243-2266.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

|

Introduced in R2016a

Was this topic helpful?