Real-time Wavelet Transform

Started by nehavedam 5 years ago9 replieslatest reply 5 years ago641 views


I have a real time system where incoming data rate is 512 Hz. This signal needs to be filtered in real time. My algorithm has a mix of wavelet filters and FIR filters.

During my algorithm development, I used MATLAB and the whole signal (about 10 minutes long) was processed in one go.

I know FIR filters can be implemented in real time using Overlap-Add or Overlap-Save Method. I tried this out by breaking my signal into blocks of 512 and this method of FIR filtering is working well.

However, I'm pretty clueless about how to approach the wavelet transform with respect to segmentation as well as real time processing. Wavelet filtering seems to be done only offline and on the whole signal at once.

I saw something about Segmented Wavelet Transform (SegWT) but it's really confusing and I'm not able to understand it entirely.

My questions are:

1. How do I approach this?

2. Is wavelet transform on real time data even possible? (Like real time FIR filtering is possible)

3. Or can I directly apply the concept of OLA Method to Wavelet transform, although because of the many decomposition levels, the overlap length might not be entirely clear. 



[ - ]
Reply by Moldy01February 6, 2018

I don't know that this is the answer for you, more like some things to think about. 

CWT (continuous wavelet transform) is "Concerned" with time as well as frequencies.  Keep in mind that the output is a "time-frequency" space.  Which means that you select a time "over which" you perform the transform.  There is nothing stopping one from "sliding" that reference time along a time-line to keep it more-or-less real time (RT), but technically it is not going to be RT as it relies on a 'chunk' of time from which to work.  I know, technically, that same argument follows for all filtering, though, in this case, it is difficult to reduce the time chunk (related to the largest scale (lowest frequency) that you use) enough to fit normal RT requirements.  For audio, it will probably inject some unwanted effects.

As for the OLA method:  In the end, though I've never tried it, the CWT is a lot like an FFT and should yield itself to your OLA for the same reasons that it works on an FFT, though it will require a bit more 'housekeeping'.  That is, at each scale, you are merely convolving the mother function across your chosen time section.  Obviously, if you keep track of each scale, individually, (yes, the extra housekeeping), in theory, you should be able to accomplish similar results. Just keep in mind, that as you 'scale' the mother function, it varies the number of 'translations' across the time chunk.  So you have to vary with the largest scale selected (lowest frequency), i.e. if you're trying to eek out 2Hz signals, you'll have to move at 500ms chunks.

Hope that all made sense.

[ - ]
Reply by nehavedamFebruary 7, 2018

I understood the point you're trying to make. Actually I thought roughly the same thing in the beginning. DTWT - Discrete Time Wavelet Transform - however when performed for many levels of decomposition, involves varying signal length at each level. So when I am trying to accomplish a 7 level decomposition, the length of the signal which gets filtered is different at each level. And the coefficients need to be later filtered again to get back the original signal. So if I'm to try to implement the OLA method here, I will have to shift-overlap and add the reconstructed signal in the end. So do I just assume the overlap length to be equal to the length of the filter used in the reconstruction? Or do I have to "do-something" to the signal while it is being decomposed. I'm a beginner in wavelet transform and so I'm actually finding it difficult to wrap my head around this concept.


[ - ]
Reply by SlartibartfastFebruary 6, 2018

I'm not enough of a wavelet expert to comment specifically about implementation of that, other than to say that real-time processing of almost anything at 512Hz should be easily doable with the right platform.   Is your platform limited in processing capability such that this causes concern?

In order to do something real-time one just needs enough processing capability for the algorithms to keep up with the sample rate.   Your sample rate is actually *very* low, so even a modest laptop or tablet could do a *lot* of real-time processing on that signal.  These days people do quite a bit of real-time stuff with sampling dongles plugged into the USB ports of Raspberry Pis, with sampling rates on the order of 1MHz.

So unless you are very limited on processing budget, I would think that you may have a number of options regarding algorithm selection for implementing your transforms.

[ - ]
Reply by nehavedamFebruary 7, 2018

I'm facing a problem with the implementation of the wavelet transform algorithm in real time. As of now processing capability isn't a bottleneck. 


[ - ]
Reply by Rick LyonsFebruary 6, 2018

Hi Nehavedam.  In your original post you wrote that your signal "needs to be filtered in real time."  Perhaps it would help if you descried your desired filtering in more detail.  Do seek a lowpass, bandpass, or highpass filter?  What transition band width(s) (relative to the Fs sample rate) do you need. What is your desired stopband attenuation (relative to your passband magnitude response). Must your filter be a linear-phase filter?

[ - ]
Reply by nehavedamFebruary 7, 2018

Hi Mr. Rick Lyons. My algorithm is for a bio-medical application (like an ECG). The algorithm processes the signal by first passing it through FIR filters. This filters the signal to a frequency band of interest to me. Then Daubechie wavelet (db4) is used to decompose the signal to level 7 and then it is reconstructed. This results in the final filtered signal.

MATLAB was performing this algorithm on the signal off-line. The entire signal would be passed to MATLAB and it would take its full size and process it in one go.

But now I have to implement this in a real-time ("on-line") system. I was able to achieve FIR filtering through breaking the signal into segments and performing fast convolution (OLA method) on it.

I'm however not able to understand how wavelet transform can be implemented in real time. I was able to find a few papers (by the same person) which talks about a new method called Segmented Wavelet Transform. Although I couldn't find a lot of support or research around the same.

So this made me think, is the implementation of wavelet transform in real time still in research stages or is it known and I'm not aware of it? 

Currently how and where do I start because I'm finding it difficult to wrap my head around this concept.


[ - ]
Reply by SlartibartfastFebruary 7, 2018

You may want to provide some more details to help understand the problem.  Why can't you run a traditional FIR in real-time?   i.e., why do you need to use OLA?  Is the impulse response of the filter exceptionally long?

How long is the expected vector, or do you need to run continuously?

Searching on "real time wavelet transform" yields a number of alternative algorithms, and even a thesis on development of a real-time wavelet library.  Do the alternative methods offer any insight on solving the problem?

[ - ]
Reply by nehavedamFebruary 8, 2018

The problem lies with the FFT operation. When operating in real time, each second I have access to only specific number of data (like 512 in this case). Filtering is done efficiently using fast convolution (i.e. filtering in frequency domain by taking the FFT of the signal and filter, multiplying them and taking the IFFT). But the signal that we get after IFFT cannot be simply cascaded with the previous output. They have to have some overlap length and need to be "overlap-added". This is why OLA method needs to be used. 

The real time data will be received at a rate of 512 samples per second. 

Since I would rate myself as just a beginner in the field of wavelets, I'm having trouble wrapping my head around the concept development that is talked in these papers. I also want to know if real-time wavelet transform implementation is really in its development stage?


[ - ]
Reply by Rick LyonsFebruary 8, 2018
Hi Nehavedam.  Eric Jacobsen and I have asked you to give us more details regarding the kind of FIR filtering you need (desire).  But you haven't given us those details.  What concerns me is that perhaps you do NOT need to perform frequency-domain filtering by using the FFT.  Perhaps you're making your FIR filtering process more complicated than it needs to be. Of course I cannot tell if that's true or not because I don't know the exact details of the filtering you desire.

The more you withhold filter details from us the less likely it is that we can make any useful suggestions to you.