Maximal overlap discrete wavelet packet transform
The output of the 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. This is true for all orthogonal scaling and wavelet filters, 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. The output of MODWPT is useful for applications where you want to analyze the energy levels in different packets.
The MODWPT details (
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 details is useful
for applications that require time-alignment, such as nonparametric
Obtain the MODWPT of an electrocardiogram (ECG) signal using the default length 18 Fejer-Korovkin (
load wecg; wpt = modwpt(wecg);
wpt is a 16-by-2048 matrix containing the sequency-ordered wavelet packet coefficients for the wavelet packet transform nodes. In this case, the nodes are at level 4. Each node corresponds to an approximate passband filtering of , where n = 0,...,15, and is the sampling frequency. Plot the wavelet packet coefficients at node (4,2), which is level 4, node 2.
plot(wpt(3,:)) title('Node 4 Wavelet Packet Coefficients')
Obtain the MODWPT of Southern Oscillation Index data with the Daubechies extremal phase wavelet with two vanishing moments (
load soi; wsoi = modwpt(soi,'db2');
Verify that the size of the resulting transform contains 16 nodes. Each node is in a separate row.
ans = 1×2 16 12998
Obtain the MODWPT of an ECG waveform using the Fejer-Korovkin length 18 scaling and wavelet filters.
load wecg; [lo,hi] = wfilters('fk18'); wpt = modwpt(wecg,lo,hi);
Obtain the MODWPT and full wavelet packet tree of an ECG waveform using the default length 18 Fejer-Korovkin (
'fk18') wavelet. Extract and plot the node coefficients at level 3, node 2.
load wecg; [wpt,packetlevels,cfreq] = modwpt(wecg,'FullTree',true); p3 = wpt(packetlevels==3,:); plot(p3(3,:)) title('Level 3, Node 2 Wavelet Coefficients')
Display the center frequencies at level 3.
ans = 8×1 0.0312 0.0938 0.1562 0.2188 0.2812 0.3438 0.4062 0.4688
Obtain and plot the MODWPT energy and relative energy of an ECG waveform.
load wecg [wpt,~,cfreq,energy,relenergy] = modwpt(wecg);
Show that the sum of the MODWPT energies is equal to the sum of the energy in the original signal. The difference between the total MODWPT energy and the signal energy is small enough to be considered insignificant.
disp(['Difference between MODWPT energy and signal energy: ',num2str(sum(energy)-sum(wecg.^2))])
Difference between MODWPT energy and signal energy: 3.6122e-09
Plot the MODWPT energy by node.
figure bar(1:16,energy) xlabel('Node') ylabel('Energy') title('Energy by Node')
disp(['Total power in passband: ',num2str(energy(1))])
Total power in passband: 200.8446
Plot the relative energy and show the percentage of signal energy in the first passband [0,5.6250].
figure bar(1:16,relenergy*100) xlabel('Node') ylabel('Percent Energy') title('Energy Relative to Signal Energy by Node')
disp(['Percentage of signal power in passband: ',num2str(relenergy(1)*100)])
Percentage of signal power in passband: 67.3352
Obtain the time-aligned MODWPT of two intermittent sine waves in noise. The sine wave frequencies are 150 Hz and 200 Hz. The data is sampled at 1000 Hz.
dt = 0.001; t = 0:dt:1-dt; x = cos(2*pi*150*t).*(t>=0.2 & t<0.4)+ sin(2*pi*200*t).*(t>0.6 & t<0.9); y = x+0.05*randn(size(t)); [wpta,~,Falign] = modwpt(x,'TimeAlign',true); [wptn,~,Fnon] = modwpt(x);
Compare the nonaligned and time-aligned time-frequency plots.
subplot(2,1,1); contour(t,Fnon.*(1/dt),abs(wptn).^2); grid on; ylabel('Hz'); title('Time-Frequency Plot (Nonaligned)'); subplot(2,1,2) contour(t,Falign.*(1/dt),abs(wpta).^2); grid on; xlabel('Time'); ylabel('Hz'); title('Time-Frequency Plot (Aligned)');
x— Input signal
Input signal, specified as a real-valued row or column vector.
have at least two elements.
wname— Analyzing wavelet filter
Valid orthogonal wavelet families begin with one of the following, followed by an integer,
N, for example,
Note, however, that
'haar' is not followed by an integer.
'haar' — Haar wavelet, which is the
same as Daubechies wavelet with one vanishing moment,
Daubechies wavelet with
Symlets wavelet with
Coiflets wavelet with
Fejer-Korovkin wavelet with
To check if your wavelet is orthogonal, use
verify that it returns
1 as the wavelet type. To
determine valid values for N, use
waveinfo, for example,
lo— Scaling filter
Scaling filter, specified as an even-length real-valued vector.
satisfy the conditions necessary to generate an orthogonal scaling
function. You cannot specify both the scaling-wavelet filters and
hi— Wavelet filter
Wavelet filter, specified as an even-length real-valued vector.
satisfy the conditions necessary to generate an orthogonal wavelet.
You cannot specify both the scaling-wavelet filters and the
lev— Transform level
Transform level, specified as a positive integer less than or
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'Fulltree',truereturns the full wavelet packet tree
FullTree— Full packet tree
Option to return the full wavelet packet tree, specified as
the comma-separated pair consisting of
true. If you
only the terminal (final-level) wavelet packet nodes. If you specify
modwpt returns the full wavelet packet tree
down to the specified level.
TimeAlign— Signal time alignment
Option to time align wavelet packet coefficients with signal
features, specified as the comma-separated pair consisting of
true to time align or
The scaling and wavelet filters have a time delay. Circularly
shifting the wavelet packet coefficients in all nodes aligns the signal
and wavelet coefficients in time. If you want to reconstruct the signal,
such as by using
do not shift the coefficients because time alignment is done during
the inversion process.
wpt— Wavelet packet transform
Wavelet packet tree, returned as a matrix with each row containing
the sequency-ordered wavelet packet coefficients. By default,
only the terminal level for the MODWPT. The default terminal level
is either level 4 or
is smaller. At level 4,
wpt is a 16-by-
matrix. For the full tree, at level j,
matrix, with each row containing the packet coefficients by level
and index. The approximate passband for the nth
wpt at level j is cycles/sample,
where n = 1,2,...2j.
packetlevs— Transform levels
Transform levels, returned as a vector. The levels correspond
to the rows of
only the terminal level coefficients,
a vector of constants equal to the terminal level. If
the full wavelet packet table,
a vector with 2j elements
for each level, j. To select all the wavelet packet
nodes at a particular level, use
cfreq— Center frequencies of passbands
Center frequencies of the approximate passbands in the
returned as a vector. The center frequencies are in cycles/sample.
To convert the units to cycles/unit time, multiply
the sampling frequency.
energy— Energy of the wavelet packet coefficients
Energy of the wavelet packet coefficients for the
returned as a vector. The sum of the energies (squared L2 norms) for
the wavelet packets at each level equals the energy in the signal.
relenergy— Relative energy
Relative energy for each level, returned as a vector. The relative energy is the proportion of energy in each wavelet packet by level, relative to the total energy of that level. The sum of relative energies in all packets at each level equals 1.
modwpt performs a discrete wavelet
packet transform and produces a sequency-ordered wavelet packet tree.
Compare the sequency-ordered and normal (Paley)-ordered trees.
 Percival, D. B., and A. T. Walden. Wavelet Methods for Time Series Analysis. Cambridge, UK: Cambridge University Press, 2000.
 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.
Usage notes and limitations:
wname must be constant.