# Time location of the DWT detail coefficients using MATLAB

When performing the Discrete Wavelet Transform in MATLAB using the command DWT or WAVEDEC, what it the exact time or pseudo-time location of the DWT coefficients?

At each level the time series is decimated by 2, this means that the coefficients should be localized at $$2^j \, T_s$$, where $$T_s$$ is the sampling frequency. However, the application of a reconstruction filter of length $$M$$ makes the coefficient arrays longer. And each level a longer coefficient array is then fed into a new DWT function, which modifies further its length. The arrays are also properly extended at each level, according to a criterion specified by the user using the command DWTMODE.

I see that in some MATLAB examples, just the central part of the array is shown using the command WKEEP. Is this approach sufficiently accurate, meaning that the external coefficients (those that are not central) are really NOT significant?

If I do not discard some coefficients, I clearly see a huge delay if I assign them to $$2^j \, T_s$$. I believe that the external coefficients are however necessary for the reconstruction.

How many coefficients can be discarded at each level, if they can be?

• That sounds like a complicated question to me. Theoretically, one should pre-project the discrete samples with information on the wavelet. Also, if the wavelet is not symmetric, time-offsets may appear. And DWT is not shift-invariant. So, many reasons to question: what is your DSP purpose here? – Laurent Duval Jun 8 at 20:23
• I was wondering whether it is possible to build a "time-frequency filter" using the DWT, by tresholding the DWT detail coefficients in each level of the decomposition not only based on their value, but also on the time location. For example, if I have a pulse located at a certain time $t_0$ with super-imposed noise, to de-noise I can keep the detail coeffs. around $t_0$ and treshold the others. It's just an intuitive idea, I am not sure if this is the right approach. What do you think? – EmThorns Jun 8 at 21:33
• This is what I meant. But how can I define this mask if I don't know the time location of the coefficients? When I apply the DWT, the number of coefficients produced is not exactly halved with respect to the previous level because of DWT algorithm (filter side effects, signal extension) and the things you mentioned before (time-offsets, non-shift invariance ... ). As you have a lot of experience in this field, maybe you can suggest to me a few papers where this procedure is carried out? I have not been able to find them. I would really appreciate. – EmThorns Jun 8 at 23:27
• Hi Laurent, sorry to bother you again. Have you not seen any paper of wavelet-domain masking? You don't remember anything off the top of your head? – EmThorns Jun 9 at 21:39
• Yes, it's ok. If in the meantime you can suggest a couple of papers to read, I will try to get them. Thanks. – EmThorns Jun 9 at 23:40

This question has multiple facets (after comments), so I will focus on the principal.

First, regarding coefficient localization: a discrete wavelet coefficient depends on several signal samples. The number of coefficients influenced by a single sample in a continuous wavelet representation typically depends on the properties of the mother wavelet and the signal regularity. This is illustrated on the following picture, with the modulus and the phase of a complex scalogram. Coefficients at discontinuities (in the signal, the derivatives, etc.) spread in cones of influence. This is well-described in many wavelet books. The situation is even more complicated when you discretize the wavelet plane: one should project the samples with prefiltering, take care of the discrete wavelet symmetries and the level of redundancy. Remember for instance that the DWT is not shift-invariant. Hence, the mask could change a bit.

I thereby propose two methods:

1. one heuristic, based on the deterministic part of the data: build a simple template signal of what you want to detect (e.g. a discrete Dirac), perform your favorite discrete wavelet (redundant or not) over shifted versions, undo the shift scale-wise, combine the envelop of the scalograms and threshold them to keep the top values (as a percentage of the maximum amplitude). You can used it as a binary or weighted mask.
2. one more involved, based on the stochastic part of the data: it is possible to compute, or estimate, the second-order characteristics of a "random noise" (like a Gaussian distribution. The decay of the covariance matrix can serve to assess the influence of a noise sample in its neighborhood. There were many papers on that topic. We notably deployed this approach with our $$M$$-band dual tree wavelets: they are slightly redundant, and therefore there are correlations between scales and wavelet trees. This is described, as well as pointers to the relevant literature, in section III of Noise Covariance Properties in Dual-Tree Wavelet Decompositions.

The resulting "regions of influence" were later used in A Nonlinear Stein-Based Estimator for Multichannel Image Denoising: the shape of the mask (across scales and subbands) defines a Reference Observation Vector (ROV), on which we estimate the "denoised" coefficient, based on generalized thresholding expressions.

The above was used primarily for denoising, but similar reasoning could apply for adaptive filtering, restoration, segmentation, etc.

• Hi Laurent, thanks for your answer. As I'm quite a newbie in wavelets, I will study your answer carefully. Clearly, it is not possible to define a precise time instant to a coefficient, s it is not possible to assign a particular frequency to a coefficient. This also come from the Heisenberg uncertainty principle. – EmThorns Jun 14 at 14:55
• I was jut wondering if, on first approximation, I can start from the code used to plot the coefficients in MATLAB using a map time-level. it.mathworks.com/help/wavelet/examples/… It seems that the code considers the coefficients at each level. The coefficients at level j are repeated $2^j$ times in order to build NxM matrix, where N is the number of samples and M is the number of points. After they are repeated, the first and last coefficients are removed. – EmThorns Jun 14 at 14:57
• The coefficients at the next level come from the application of the wavelet decomposition filter + a sub-sampling by 2. However, for end effects, the number of coefficients at the level $j+1$ are not half of the coefficients at level $j$. The first and last coefficients are removed from the final line of the DWT matrix to be plotted using the command WKEEP, which keeps exactly N (numer of samples) "plotting values". – EmThorns Jun 14 at 15:01
• I don't know if eliminating the first and the last coefficients is good, also because these coefficients are necessary for the reconstruction. However, the point is, how many coefficients are "reliable" in the original ones determined with the command detcoef or dwt? Can I assign them, on first apporximation to the time instant $2^j T_s$, where $T_s$ is the sampling period? How to manage the first and last coefficients? I believe that if I can solve this, maybe it is possible to perform a de-noising in time-level domain (still on first approximation, given also what yous said in your answer). – EmThorns Jun 14 at 15:06
• Did you try to stick to power-of-two length $N$ of signals, a number of levels $L$ such that $2^L$ divides $N$, and dwtmod(per) to reduce the overhead? – Laurent Duval Jun 14 at 15:06