How can I combine detail coefficients from different levels of a wavelet decomposition?

8 views (last 30 days)
I am working with an EEG signal with a sampling frequency of 256 Hz. I have performed an 8-level discrete wavelet transformation using the function wavedec in MATLAB. This result in 8 levels of detail coefficients and 1 level of approximation coefficients. I want to combine the detail coefficients from level 6, 7, and 8 - i.e. the frequencies 2-4, 1-2, and 0.5-1. However, I do not know how to do this.
I cannot simply add the coefficients from the different levels since the coefficient vectors are of different length. I have tried to use wrcoef in order to obtain the details D6, D7, and D8 from the detail coefficients cD6, cD7, and cD8. These will be the same length as my signal, so now I can add them. But I want the frequency band 0.5-4 to be represented as detail coefficients and not details. How can I do this? Or is it a completely wrong approach for adding detail coefficients?
I am new to both MATLAB and the wavelet transformation, so any kind help would be highly appreciated! Thank you.

Answers (1)

Shreyas S
Shreyas S on 6 Jul 2021
If you want to visualize and play with the wavelet coefficients - use Wavelet Analyzer toolbox > Wavelet Coefficients Selection 1-D.
However, if you want to implement that using command lines use 'idwt' (Inverse Discrete Wavelet Transform).
Run this code where I have illustrated the use of 'idwt' function, and you'll understand how to use 'idwt'.
t=1:0.01:6*pi;
l=length(t);
sig=sin(2*pi*t)+0.5*rand(1,l);
plot(sig)
%%
[c,l] = wavedec(sig,2,'haar');
approx = appcoef(c,l,'haar');
[cd1 cd2] = detcoef(c,l,[1 2]);
%%
x = idwt(approx,cd2,'haar');
y = idwt(x(1:893),cd1,'haar');
plot(sig,'r')
hold on
plot(x,'b')
hold on
plot(y,'o')
For, reconstruction using filters, use this -
x = idwt(cA,cD,LoR,HiR) uses the specified low-pass and high-pass wavelet reconstruction filters LoR and HiR, respectively.
Read 'idwt' documentation for more information.

Categories

Find more on Filter Banks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!