1

I want to write a code that involves the use of the undecimated discrete wavelet transform in python. I know that pywavelets contains the undecimated wavelet transform but to my understanding, this is different from the undecimated discrete wavelet transform. Right?

In Matlab I was able to do it using the Rice toolbox (rwt) https://github.com/ricedsp/rwt using this code:

samplelength=length(BTot(:,1));


    wname='coif2';

    Lps=7;          %   Low pass filter phase shift for level 1 Coiflet2
    Hps=4;          %   High pass filter phase shift for level 1 Coiflet2

    [h_0,h_1,~,~] = wfilters(wname);   % set up the filters

    nlevel = wmaxlev(samplelength,wname)   % maximum nr of levels

    % edge extension mode set to periodic extension by default with this
    % routine in the rice toolbox.

    pads=(2^(nextpow2(samplelength))) - samplelength;   % for edge extension

    %% Do the UDWT decompositon and reconstruction

    tempfiles = cell(1,3);

    for m=2:1:4

    % Gets the data size up to the next power of 2 due to UDWT restrictions
    % Although periodic extension is used for the wavelet edge handling we are
    % getting the data up to the next power of 2 here by extending the data
    % sample with a constant value

        y=[BTot(1,m).*ones(pads/2,1); BTot(:,m); BTot(end,m).*ones(pads/2,1)];

    % Decompose the signal using the UDWT

        tic
        [swa,swd,L] = mrdwt(y,h_0,nlevel);
        toc

        clear('y','L');

    % Reconstruct all the approximations and details at all levels

        tic

        mzero = zeros(size(swd));
        A = mzero;
        A(:,nlevel) = mirdwt(swa,mzero,h_0,nlevel);

        D = mzero;

        for i = 1:nlevel

            swcfs = mzero;
            swcfs(:,i) = swd(:,i);
            D(:,i) = mirdwt(zeros(length(swa),1),swcfs,h_0,nlevel);

        end

To my understanding rwt can also be used in Python. https://pythonhosted.org/pyrwt/install.html

However, I have tried installing by pip install rwt and pip install pyrwt but does not seem to be working.

jokerp
  • 157
  • 1
  • 8

0 Answers0