graetz23/JWave

Arbitrary length wavelet coefficients order

Opened this issue · 4 comments

Hello,

I have tried to understand the working of Ancient Egyptian Decomposition transform for wavelet transforms, but when trying to address the coefficients corresponding to a particular frequency band I am having difficulty in finding a pattern.

When we have a wavelet transform, it divides the coefficients in each level by 2 from the Low frequency (Approximate coefficients) copying detailed coefficients as it is in next level
Here it is easy to find a pattern as we know every time the approximate coefficients were divided in index by 2

But what would be the case when we are working with arbitrary length signals?

`

Wavelet demy =  WaveletBuilder.create( "Discrete Mayer" );
Transform fwt = new Transform(new AncientEgyptianDecomposition ( new FastWaveletTransform( demy ) ) );

int level_decomposed = 4;
double [] arrTime = getTimeSeriesData(); // returns an array of arbitrary length every time @30Hz

// These values for de-noising the signal only works for 2^p length signals
// Denoising to 0 - 3.75Hz 
int dcValuesP = pulse.length / (int) Math.pow(2.0, (double) level_decomposed);
int value_denoise = dcValuesP * 2;

double [] arrHilb = fwt.forward(arrTime);

for (int dp = value_denoise; dp < arrHilb.length; dp++) {
    arrHilb[dp] = 0.0D;
}

for (int i = 0; i < dcValuesP; i++) {
    arrHilb[i] = 0.0D;
}

double [] arrReco = fwt.reverse(arrHilb);
`

Could you help me in finding the pattern which would help me achieve similar denoising effect (0-30Hz to 0-3.75Hz using dmey wavelet) for arbitrary length time series data?

PS. I was working the same in Matlab there we get an array of index book keeping for a particular range of coefficients, if there is something similar to it, that would be great!

Hi there,

actually the pattern is just separated transforms of different length, and, therefore, of different level:

An array of length 15 is divided in time series (!) to four arrays of length: 8, 4, 2, and 1. For each of the four arrays a separated transform is applied to receive four Frequency / Hilbert Domain; actually the array of length 1 stays in both domains the same.

If you want to filter over all coefficients of your signal of odd (sampled) length in (full) time series, you have to adapt a new class like the AncientEgyptianDecomp, that fits, e.g. an array of length 13, 14, or 15 to a length of 16, the next possible length for the transform (2, .., 16, 32, .., 2^p | p = N). This would allow you to apply the dmey and decompose your signal according to your set sampling rate and sampling length.

The better way is to directly generate or cut out samples of length 2^p | p = {0,1,2,3,4,..}

P.S. Yes Matlab is different here, but only in how to apply the transform and, therefore, how the low and high pass coeffs are ordered and/or sampled. JWave was designed as simple as possible in code to adapt it to own needs; e.g. an own filtering scheme.

@cscheiblich Thanks, your library works like a charm! I had figured it out, your library helped a lot. I did use AncientEgyptianDecomposition to fit arbitrary length sequences, and implemented a filter by figuring out the order of coefficients w.r.t. their frequencies.

@uidp1499 many, many thanks and great to hear you figured it out! :-)

Ten years ago there was practically no Java library for wavelets and wavelet transforms, so I ported my C++ one, adding Junit tests .. may be I have to settle my C++ as open source, if JWave works like a charm ;-)

image
can i use this method to fetch the approximation information and high frequency information sequence?

image

In a word, I want to use JWavelet package to get this result

image