DSPRelated.com
Forums

removing phase shift - reversing the signal

Started by lxf5 July 26, 2009
I am using matlab, and I have run my data through this filter

d=fdesign.lowpass('fp,fst,ap,ast',24,36,1,5,Fs);
hd=design(d,'butter');

with this command
filtsig=filter(hd,signal);

then reversed the signal

revsig=filtsig(1024:-1:1);
filtrevsig=filter(hd,revsig);

to achieve a doubly filtered signal with no (?) phase lag:

dblFiltSig=filtrevsig(1024:-1:1);

I have assessed the combined filter magnitude performance by
cascading the filters with

dblhd = dfilt.cascade(hd,hd);

The original filter was designed with this cascaded result in mind
and I am happy with this filtering of the magnitude.

It all seems to work just fine and but I want to be sure that
it is correct to say that I have filtered the data with the
cascaded filter and that there is no phase lag.  Is there any
error in this approach or conclusion.

Lee


On Jul 26, 10:47&#4294967295;am, "lxf5" <l...@case.edu> wrote:
...
> > The original filter was designed with this cascaded result in mind > and I am happy with this filtering of the magnitude. > > It all seems to work just fine and but I want to be sure that > it is correct to say that I have filtered the data with the > cascaded filter and that there is no phase lag. &#4294967295;Is there any > error in this approach or conclusion?
it depends on where you define the "zeroth" sample in your output. does not filtsig=filter(hd,signal); make filtsig longer than signal? if you define y[0] to be at the correct place in dblFiltSig, then the phase lag is zero. try processing a simple signal that is zero everywhere except for one sample set to 1 (the discrete-time impulse function) and see where your symmetrical output peaks. r b-j
lxf5 wrote:
> I am using matlab, and I have run my data through this filter > > d=fdesign.lowpass('fp,fst,ap,ast',24,36,1,5,Fs); > hd=design(d,'butter'); > > with this command > filtsig=filter(hd,signal); > > then reversed the signal > > revsig=filtsig(1024:-1:1); > filtrevsig=filter(hd,revsig); > > to achieve a doubly filtered signal with no (?) phase lag: > > dblFiltSig=filtrevsig(1024:-1:1); > > I have assessed the combined filter magnitude performance by > cascading the filters with > > dblhd = dfilt.cascade(hd,hd); > > The original filter was designed with this cascaded result in mind > and I am happy with this filtering of the magnitude. > > It all seems to work just fine and but I want to be sure that > it is correct to say that I have filtered the data with the > cascaded filter and that there is no phase lag. Is there any > error in this approach or conclusion.
That depends on what you mean by "phase lag". There is certainly delay. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Jul 26, 10:47&#4294967295;am, "lxf5" <l...@case.edu> wrote:
> I am using matlab, and I have run my data through this filter > > d=fdesign.lowpass('fp,fst,ap,ast',24,36,1,5,Fs); > hd=design(d,'butter'); > > with this command > filtsig=filter(hd,signal); > > then reversed the signal > > revsig=filtsig(1024:-1:1); > filtrevsig=filter(hd,revsig); > > to achieve a doubly filtered signal with no (?) phase lag: > > dblFiltSig=filtrevsig(1024:-1:1); > > I have assessed the combined filter magnitude performance by > cascading the filters with > > dblhd = dfilt.cascade(hd,hd); > > The original filter was designed with this cascaded result in mind > and I am happy with this filtering of the magnitude. > > It all seems to work just fine and but I want to be sure that > it is correct to say that I have filtered the data with the > cascaded filter and that there is no phase lag. &#4294967295;Is there any > error in this approach or conclusion. > > Lee
Hey, This seems like the exact approach of the matlab's FILTFILT function for 0 phase filtering (they set, however, the filter's initials conditions equal to the DC component of the signal). You do however, have to be careful that their input is long enough .
On Jul 26, 10:47&#4294967295;am, "lxf5" <l...@case.edu> wrote:
> I am using matlab, and I have run my data through this filter > > d=fdesign.lowpass('fp,fst,ap,ast',24,36,1,5,Fs); > hd=design(d,'butter'); > > with this command > filtsig=filter(hd,signal); > > then reversed the signal > > revsig=filtsig(1024:-1:1); > filtrevsig=filter(hd,revsig); > > to achieve a doubly filtered signal with no (?) phase lag: > > dblFiltSig=filtrevsig(1024:-1:1); > > I have assessed the combined filter magnitude performance by > cascading the filters with > > dblhd = dfilt.cascade(hd,hd); > > The original filter was designed with this cascaded result in mind > and I am happy with this filtering of the magnitude. > > It all seems to work just fine and but I want to be sure that > it is correct to say that I have filtered the data with the > cascaded filter and that there is no phase lag. &#4294967295;Is there any > error in this approach or conclusion. > > Lee
Hello Lee, Certainly it is okay to filter and then time reverse filter a signal to remove the dispersion. To be sure you will have an overall delay. In fact if your signal were extremely long, you can even break it up into blocks and use overlap to remove the glitches. But for a relatively modest duration a simple time reversal method works great. For example see Rader and Jackson,"Approximating Noncausual IIR Digital Filters Having Arbitrary Poles, Including New Hilbert Transformer Designs via Forward/Backward Block Recursion", IEEE trans on Circuits and Systems I: Regular Papers, Vol 53, Issue 12, Dec, 2006, pages 2779-2787 IHTH, Clay
On Jul 27, 2:42&#4294967295;pm, Neu <ikarosi...@hotmail.com> wrote:
> > This seems like the exact approach of the matlab's FILTFILT function > for 0 phase filtering
yeah, i knew that's what they called it, but i didn't remember where it was. i though it might have been an old unix tool that those C- sound guys were using. i knew what it was and had never actually used it. i first learned of it when i was talking with a guy named Avery Wang who wrote, with Julius Smith, an interesting paper about Truncated IIR filters (TIIR) that are recursive ways to do FIR filters. (a moving-average or moving-sum filter is the simple non- trivial example.) in fact, look at patent 5,548,543. they had a paper where they were using a stable TIIR in cascade with the unstable reflection (1/z) TIIR to get zero phase shift and twice the magnitude like filtfilt() does (but it does it in real time). even though they proved their system works, they can swap out the unstable TIIR i thought that a safer way to do is, after busting the signal into blocks to use a two identical and stable TIIR filters to filter a block of signal once forward and then reverse. since TIIRs are actually FIRs, the tail attached to the zero-ended block is finite, so you can in real time, wait for the tail to end and they filter that block in reverse. lastly, overlap add with the previous block. with a long TIIR impulse respone, you can as close to some classic IIR filter magnitude response (squared) as you want. like filtfilt(), you have to design your IIR filter to have half the dB response as your real target.
>(they set, however, &#4294967295;the filter's initials > conditions equal to the DC component of the signal).
or a weighted version of the DC component. that seems like a good thing to do for processing a sound file (which is what the utility was written to do) to minimize some click, but i *don't* think you want to that if you were using a filtfilt-like process to process blocks in a continuous steam. then you want the filter states cleared. listen, i know this TIIR stuff seems a little bit ancillary to filtfilt (), but at least one application of TIIR is to accomplish the same thing as filtfilt(). r b-j
>You do however, have to be careful that their input is long enough .
On 28 Jul., 01:11, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jul 27, 2:42=A0pm, Neu <ikarosi...@hotmail.com> wrote: > > > > > This seems like the exact approach of the matlab's FILTFILT function > > for 0 phase filtering > > yeah, i knew that's what they called it, but i didn't remember where > it was. =A0i though it might have been an old unix tool that those C- > sound guys were using. =A0i knew what it was and had never actually used > it. =A0i first learned of it when i was talking with a guy named Avery > Wang who wrote, with Julius Smith, an interesting paper about > Truncated IIR filters (TIIR) that are recursive ways to do FIR > filters. =A0(a moving-average or moving-sum filter is the simple non- > trivial example.) =A0in fact, look at patent 5,548,543. > > they had a paper where they were using a stable TIIR in cascade with > the unstable reflection (1/z) TIIR to get zero phase shift and twice > the magnitude like filtfilt() does (but it does it in real time). > even though they proved their system works, they can swap out the > unstable TIIR =A0i thought that a safer way to do is, after busting the > signal into blocks to use a two identical and stable TIIR filters to > filter a block of signal once forward and then reverse. =A0since TIIRs > are actually FIRs, the tail attached to the zero-ended block is > finite, so you can in real time, wait for the tail to end and they > filter that block in reverse. =A0lastly, overlap add with the previous > block. =A0with a long TIIR impulse respone, you can as close to some > classic IIR filter magnitude response (squared) as you want. =A0like > filtfilt(), you have to design your IIR filter to have half the dB > response as your real target. > > >(they set, however, =A0the filter's initials > > conditions equal to the DC component of the signal). > > or a weighted version of the DC component. =A0that seems like a good > thing to do for processing a sound file (which is what the utility was > written to do) to minimize some click, but i *don't* think you want to > that if you were using a filtfilt-like process to process blocks in a > continuous steam. =A0then you want the filter states cleared. > > listen, i know this TIIR stuff seems a little bit ancillary to filtfilt > (), but at least one application of TIIR is to accomplish the same > thing as filtfilt().
I remember when you first told me here on comp.dsp how to combine the Wang/Smith TIIR with the Powell/Chau OLA-Time-Reversal methods (was that in 2006?) - I thought the idea was tits! In the meantime, I have found a 2003-paper [1] by a bunch of Japanese guys that spells it out in excruciating detail. Do you want it? I also thought of adding a windowing section to the this type of filter. Instead of truncating the impulse response, one can use a window of the class described by Nuttall [2] to smoothen the frequency response. This is quite useful for online implementation if the OLA section length becomes non-negligible with respect to the impulse response length. However, when I tried it out the windowing only worked if I used quadruple-precision arithmetic. Should I ever find the muse, I'll try it out with one of those numerically super-stable state-space representations of a biquad section. Or maybe I'll get a student to do it. Regards, Andor [1] A. Kurosu et al, A Technique to Tuncate IIR Filter Impuse Response and Its Application to Real-Time Implementation of Linear-Phase IIR Filters, IEEE Transactions on Signal Processing Vol 51, May 2003. [2] A. H. Nutall, Some Windows with Very Good Sidelobe Behavior, IEEE TASSP, Vol 29, Feb. 1981.
On Jul 28, 3:56&#4294967295;am, Andor <andor.bari...@gmail.com> wrote:
> On 28 Jul., 01:11, robert bristow-johnson <r...@audioimagination.com> > wrote: > > > > > On Jul 27, 2:42&#4294967295;pm, Neu <ikarosi...@hotmail.com> wrote: > > > > This seems like the exact approach of the matlab's FILTFILT function > > > for 0 phase filtering > > > yeah, i knew that's what they called it, but i didn't remember where > > it was. &#4294967295;i though it might have been an old unix tool that those C- > > sound guys were using. &#4294967295;i knew what it was and had never actually used > > it. &#4294967295;i first learned of it when i was talking with a guy named Avery > > Wang who wrote, with Julius Smith, an interesting paper about > > Truncated IIR filters (TIIR) that are recursive ways to do FIR > > filters. &#4294967295;(a moving-average or moving-sum filter is the simple non- > > trivial example.) &#4294967295;in fact, look at patent 5,548,543. > > > they had a paper where they were using a stable TIIR in cascade with > > the unstable reflection (1/z) TIIR to get zero phase shift and twice > > the magnitude like filtfilt() does (but it does it in real time). > > even though they proved their system works, they can swap out the > > unstable TIIR &#4294967295;i thought that a safer way to do is, after busting the > > signal into blocks to use a two identical and stable TIIR filters to > > filter a block of signal once forward and then reverse. &#4294967295;since TIIRs > > are actually FIRs, the tail attached to the zero-ended block is > > finite, so you can in real time, wait for the tail to end and they > > filter that block in reverse. &#4294967295;lastly, overlap add with the previous > > block. &#4294967295;with a long TIIR impulse respone, you can as close to some > > classic IIR filter magnitude response (squared) as you want. &#4294967295;like > > filtfilt(), you have to design your IIR filter to have half the dB > > response as your real target. > > > >(they set, however, &#4294967295;the filter's initials > > > conditions equal to the DC component of the signal). > > > or a weighted version of the DC component. &#4294967295;that seems like a good > > thing to do for processing a sound file (which is what the utility was > > written to do) to minimize some click, but i *don't* think you want to > > that if you were using a filtfilt-like process to process blocks in a > > continuous steam. &#4294967295;then you want the filter states cleared. > > > listen, i know this TIIR stuff seems a little bit ancillary to filtfilt > > (), but at least one application of TIIR is to accomplish the same > > thing as filtfilt(). > > I remember when you first told me here on comp.dsp how to combine the > Wang/Smith TIIR with the Powell/Chau OLA-Time-Reversal methods (was > that in 2006?) - I thought the idea was tits! In the meantime, I have > found a 2003-paper [1] by a bunch of Japanese guys that spells it out > in excruciating detail. Do you want it?
yeah, sure. can you email me a pdf?
> [1] A. Kurosu et al, A Technique to Tuncate IIR Filter Impuse Response > and Its Application to Real-Time Implementation of Linear-Phase IIR > Filters, IEEE Transactions on Signal Processing Vol 51, May 2003.
well, i was talking with Bill Gardner about this at an IEEE Mohonk conference, and the last one of those i've been to was in 2001. i wonder where they got the idea. i gotta think about your idea a little more. r b-j
On 29 Jul., 05:49, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jul 28, 3:56&#4294967295;am, Andor <andor.bari...@gmail.com> wrote: > > > > > > > On 28 Jul., 01:11, robert bristow-johnson <r...@audioimagination.com> > > wrote: > > > > On Jul 27, 2:42&#4294967295;pm, Neu <ikarosi...@hotmail.com> wrote: > > > > > This seems like the exact approach of the matlab's FILTFILT function > > > > for 0 phase filtering > > > > yeah, i knew that's what they called it, but i didn't remember where > > > it was. &#4294967295;i though it might have been an old unix tool that those C- > > > sound guys were using. &#4294967295;i knew what it was and had never actually used > > > it. &#4294967295;i first learned of it when i was talking with a guy named Avery > > > Wang who wrote, with Julius Smith, an interesting paper about > > > Truncated IIR filters (TIIR) that are recursive ways to do FIR > > > filters. &#4294967295;(a moving-average or moving-sum filter is the simple non- > > > trivial example.) &#4294967295;in fact, look at patent 5,548,543. > > > > they had a paper where they were using a stable TIIR in cascade with > > > the unstable reflection (1/z) TIIR to get zero phase shift and twice > > > the magnitude like filtfilt() does (but it does it in real time). > > > even though they proved their system works, they can swap out the > > > unstable TIIR &#4294967295;i thought that a safer way to do is, after busting the > > > signal into blocks to use a two identical and stable TIIR filters to > > > filter a block of signal once forward and then reverse. &#4294967295;since TIIRs > > > are actually FIRs, the tail attached to the zero-ended block is > > > finite, so you can in real time, wait for the tail to end and they > > > filter that block in reverse. &#4294967295;lastly, overlap add with the previous > > > block. &#4294967295;with a long TIIR impulse respone, you can as close to some > > > classic IIR filter magnitude response (squared) as you want. &#4294967295;like > > > filtfilt(), you have to design your IIR filter to have half the dB > > > response as your real target. > > > > >(they set, however, &#4294967295;the filter's initials > > > > conditions equal to the DC component of the signal). > > > > or a weighted version of the DC component. &#4294967295;that seems like a good > > > thing to do for processing a sound file (which is what the utility was > > > written to do) to minimize some click, but i *don't* think you want to > > > that if you were using a filtfilt-like process to process blocks in a > > > continuous steam. &#4294967295;then you want the filter states cleared. > > > > listen, i know this TIIR stuff seems a little bit ancillary to filtfilt > > > (), but at least one application of TIIR is to accomplish the same > > > thing as filtfilt(). > > > I remember when you first told me here on comp.dsp how to combine the > > Wang/Smith TIIR with the Powell/Chau OLA-Time-Reversal methods (was > > that in 2006?) - I thought the idea was tits! In the meantime, I have > > found a 2003-paper [1] by a bunch of Japanese guys that spells it out > > in excruciating detail. Do you want it? > > yeah, sure. &#4294967295;can you email me a pdf?
I sent it to your audioimagination e-mail address.
> > [1] A. Kurosu et al, A Technique to Tuncate IIR Filter Impuse Response > > and Its Application to Real-Time Implementation of Linear-Phase IIR > > Filters, IEEE Transactions on Signal Processing Vol 51, May 2003. > > well, i was talking with Bill Gardner about this at an IEEE Mohonk > conference, and the last one of those i've been to was in 2001. &#4294967295;i > wonder where they got the idea. > > i gotta think about your idea a little more.
DSP riddle: Assume two rational transfer filters with impulse responses g = [g1, g2, ... ] and h = [h1, h2, ...]. How to construct a rational transfer filter with impulse response [g1 h1, g2 h2, ...}? :-) Regards, Andor
On Jul 29, 3:58&#4294967295;am, Andor <andor.bari...@gmail.com> wrote:
> On 29 Jul., 05:49, robert bristow-johnson <r...@audioimagination.com> > wrote: > > > > > On Jul 28, 3:56&#4294967295;am, Andor <andor.bari...@gmail.com> wrote: > > > > On 28 Jul., 01:11, robert bristow-johnson <r...@audioimagination.com> > > > wrote: > > > > > On Jul 27, 2:42&#4294967295;pm, Neu <ikarosi...@hotmail.com> wrote: > > > > > > This seems like the exact approach of the matlab's FILTFILT function > > > > > for 0 phase filtering > > > > > yeah, i knew that's what they called it, but i didn't remember where > > > > it was. &#4294967295;i though it might have been an old unix tool that those C- > > > > sound guys were using. &#4294967295;i knew what it was and had never actually used > > > > it. &#4294967295;i first learned of it when i was talking with a guy named Avery > > > > Wang who wrote, with Julius Smith, an interesting paper about > > > > Truncated IIR filters (TIIR) that are recursive ways to do FIR > > > > filters. &#4294967295;(a moving-average or moving-sum filter is the simple non- > > > > trivial example.) &#4294967295;in fact, look at patent 5,548,543. > > > > > they had a paper where they were using a stable TIIR in cascade with > > > > the unstable reflection (1/z) TIIR to get zero phase shift and twice > > > > the magnitude like filtfilt() does (but it does it in real time). > > > > even though they proved their system works, they can swap out the > > > > unstable TIIR &#4294967295;i thought that a safer way to do is, after busting the > > > > signal into blocks to use a two identical and stable TIIR filters to > > > > filter a block of signal once forward and then reverse. &#4294967295;since TIIRs > > > > are actually FIRs, the tail attached to the zero-ended block is > > > > finite, so you can in real time, wait for the tail to end and they > > > > filter that block in reverse. &#4294967295;lastly, overlap add with the previous > > > > block. &#4294967295;with a long TIIR impulse respone, you can as close to some > > > > classic IIR filter magnitude response (squared) as you want. &#4294967295;like > > > > filtfilt(), you have to design your IIR filter to have half the dB > > > > response as your real target. > > > > > >(they set, however, &#4294967295;the filter's initials > > > > > conditions equal to the DC component of the signal). > > > > > or a weighted version of the DC component. &#4294967295;that seems like a good > > > > thing to do for processing a sound file (which is what the utility was > > > > written to do) to minimize some click, but i *don't* think you want to > > > > that if you were using a filtfilt-like process to process blocks in a > > > > continuous steam. &#4294967295;then you want the filter states cleared. > > > > > listen, i know this TIIR stuff seems a little bit ancillary to filtfilt > > > > (), but at least one application of TIIR is to accomplish the same > > > > thing as filtfilt(). > > > > I remember when you first told me here on comp.dsp how to combine the > > > Wang/Smith TIIR with the Powell/Chau OLA-Time-Reversal methods (was > > > that in 2006?) - I thought the idea was tits! In the meantime, I have > > > found a 2003-paper [1] by a bunch of Japanese guys that spells it out > > > in excruciating detail. Do you want it? > > > yeah, sure. &#4294967295;can you email me a pdf? > > I sent it to your audioimagination e-mail address. > > > > [1] A. Kurosu et al, A Technique to Tuncate IIR Filter Impuse Response > > > and Its Application to Real-Time Implementation of Linear-Phase IIR > > > Filters, IEEE Transactions on Signal Processing Vol 51, May 2003. > > > well, i was talking with Bill Gardner about this at an IEEE Mohonk > > conference, and the last one of those i've been to was in 2001. &#4294967295;i > > wonder where they got the idea. > > > i gotta think about your idea a little more. > > DSP riddle: > > Assume two rational transfer filters with impulse responses > > g = [g1, g2, ... ] > > and > > h = [h1, h2, ...]. > > How to construct a rational transfer filter with impulse response > > [g1 h1, g2 h2, ...}? >
you've been using MATLAB too much. you're counting from 1.
> :-) >
my thoughts, exactly. r b-j