DSPRelated.com
Forums

Reduce Ringing in FIRs

Started by Randy Yates December 15, 2015
>These are ECG signals. If the patient has a pace maker, there are >short spikes intermixed with the ECG data. If the filter has wiggles, >the spikes ring. ring == bad (according to the customer, who is >always right :) >-- >Randy Yates, DSP/Embedded Firmware Developer >Digital Signal Labs >http://www.digitalsignallabs.com
Hi Randy, I have had the same problem on ECG in the past. The solution was: - for the high frequency noise: using a smoother filter (wider transition band) - for the power line removal filter (the biggest problem, for which the transition bandwidth is necessarily narrow): using an adaptative filter to track the power line (phase and magnitude) and remove it on the fly. It is so insensible to QRS spikes. I don't remember the book I had taken the method from (I have sold it since...), but it was something like "biomedical signal processing", or something like that. If you are interested, I can try to find back. Kind regards, Julien --------------------------------------- Posted through http://www.DSPRelated.com
On Wednesday, December 16, 2015 at 6:45:53 AM UTC-5, tsd822 wrote:
> >These are ECG signals. If the patient has a pace maker, there are > >short spikes intermixed with the ECG data. If the filter has wiggles, > >the spikes ring. ring == bad (according to the customer, who is > >always right :) > >-- >
Sharp transition bands and no ringing are contradictory requirements. Call me Mr Gibbs. why does an ECG (EKG?) filter need to be linear phase? Mark
Randy Yates wrote:
> Les Cargill <lcargill99@comcast.com> writes: > >> Randy Yates wrote: >>> Gentle comp.dsp readers, >>> >>> A requirement just popped up in one of my projects to redesign an FIR >>> lowpass filter so that it doesn't create so much time-domain ringing on >>> spikes. I had originally used octave's firls to design a linear-phase >>> lowpass filter (Fs = 625 Hz, Fp = 100 Hz, Fs = 150 Hz), but its response >>> has got a lot of wigglies. >>> >> >> Erm.... 3rd order (? what order?) Butterworth IIR? Should be pretty smooth. >> >> ( .24 = 150/625 = 30/125 = 6/25 = 0.24 ) >> >> Command line: mkfilter.exe -Bu -Lp -o 3 -a .24 >> raw alpha1 = 0.2400000000 >> ... >> >> Recurrence relation: >> y[n] = ( 1 * x[n- 3]) >> + ( 3 * x[n- 2]) >> + ( 3 * x[n- 1]) >> + ( 1 * x[n- 0]) >> >> + ( 0.0105030013 * y[n- 3]) >> + ( -0.3368436806 * y[n- 2]) >> + ( 0.1152020629 * y[n- 1]) >> >> > > Les, thanks, that was a very nice try, but this has to be linear-phase. >
Well, no IIR for you then! For some reason, I translated "linear phase" to "minimum phase." -- Les Cargill
keskiviikko 16. joulukuuta 2015 4.45.07 UTC+2 Randy Yates kirjoitti:
> Les Cargill <lcargill99@comcast.com> writes: > > > Randy Yates wrote: > >> Gentle comp.dsp readers, > >> > >> A requirement just popped up in one of my projects to redesign an FIR > >> lowpass filter so that it doesn't create so much time-domain ringing on > >> spikes. I had originally used octave's firls to design a linear-phase > >> lowpass filter (Fs = 625 Hz, Fp = 100 Hz, Fs = 150 Hz), but its response > >> has got a lot of wigglies. > >> > > > > Erm.... 3rd order (? what order?) Butterworth IIR? Should be pretty smooth. > > > > ( .24 = 150/625 = 30/125 = 6/25 = 0.24 ) > > > > Command line: mkfilter.exe -Bu -Lp -o 3 -a .24 > > raw alpha1 = 0.2400000000 > > ... > > > > Recurrence relation: > > y[n] = ( 1 * x[n- 3]) > > + ( 3 * x[n- 2]) > > + ( 3 * x[n- 1]) > > + ( 1 * x[n- 0]) > > > > + ( 0.0105030013 * y[n- 3]) > > + ( -0.3368436806 * y[n- 2]) > > + ( 0.1152020629 * y[n- 1]) > > > > > > Les, thanks, that was a very nice try, but this has to be linear-phase. > -- > Randy Yates, DSP/Embedded Firmware Developer > Digital Signal Labs > http://www.digitalsignallabs.com
Running the signal twice through the IIR, first in normal time order and second time in time-reversed order. So, if you can process the signal off-line, you could use IIR. http://www.dspguide.com/ch19/4.htm
Mark:

Usually, ECG filters need to be linear phase because clinicians who look at the time traces want minimal (or no) distortions in the waveform's shape (QRS complex). They use the peak latencies, shapes, duration of complex, etc to do their clinical assessments.

On Wednesday, December 16, 2015 at 8:50:58 AM UTC-5, mako...@yahoo.com wrote:
> On Wednesday, December 16, 2015 at 6:45:53 AM UTC-5, tsd822 wrote: > > >These are ECG signals. If the patient has a pace maker, there are > > >short spikes intermixed with the ECG data. If the filter has wiggles, > > >the spikes ring. ring == bad (according to the customer, who is > > >always right :) > > >-- > > > > Sharp transition bands and no ringing are contradictory requirements. > > Call me Mr Gibbs. > > why does an ECG (EKG?) filter need to be linear phase? > > Mark
f.quivira@gmail.com writes:

> Mark: > > Usually, ECG filters need to be linear phase because clinicians who > look at the time traces want minimal (or no) distortions in the > waveform's shape (QRS complex). They use the peak latencies, shapes, > duration of complex, etc to do their clinical assessments.
Yup, you nailed it. --Randy
> > On Wednesday, December 16, 2015 at 8:50:58 AM UTC-5, mako...@yahoo.com wrote: >> On Wednesday, December 16, 2015 at 6:45:53 AM UTC-5, tsd822 wrote: >> > >These are ECG signals. If the patient has a pace maker, there are >> > >short spikes intermixed with the ECG data. If the filter has wiggles, >> > >the spikes ring. ring == bad (according to the customer, who is >> > >always right :) >> > >-- >> > >> >> Sharp transition bands and no ringing are contradictory requirements. >> >> Call me Mr Gibbs. >> >> why does an ECG (EKG?) filter need to be linear phase? >> >> Mark >
-- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
"tsd822" <110497@DSPRelated> writes:

>>These are ECG signals. If the patient has a pace maker, there are >>short spikes intermixed with the ECG data. If the filter has wiggles, >>the spikes ring. ring == bad (according to the customer, who is >>always right :) >>-- >>Randy Yates, DSP/Embedded Firmware Developer >>Digital Signal Labs >>http://www.digitalsignallabs.com > > Hi Randy, > > I have had the same problem on ECG in the past. > > The solution was: > - for the high frequency noise: using a smoother filter (wider > transition band) > - for the power line removal filter (the biggest problem, for which the > transition bandwidth is necessarily narrow): using an adaptative filter to > track the power line (phase and magnitude) and remove it on the fly. It is > so insensible to QRS spikes. > > I don't remember the book I had taken the method from (I have sold it > since...), but it was something like "biomedical signal processing", or > something like that. If you are interested, I can try to find back. > > Kind regards, > > Julien
Thank you for the suggestions and book recommendation, Julien. I too considered a larger transition band. Another approach that came to mind was to use a Gaussian filter. This is (I think, if I understood my 5 minutes of reading) a "perfect" filter for the time-domain, but its passband (frequency) response is pretty crappy. I'm thinking of widening it out so that it meets passband variation criteria (e.g., 0 dB, -1 dB), but haven't analytically thought through that. I'd appreciate any thoughts you have on this approach. -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
Randy Yates  <yates@digitalsignallabs.com> wrote:

>maury001@core.com writes:
>> I assume by a lot of wigglies you mean too much ripple in the pass >> band. > >Maury, thanks. I meant its IMPULSE response has a lot of wigglies. The >original filter has like 0.001 ripple in the passband.
One thing I have done in this type situation is, assuming I have a reaosnably capable filter-design program, run the program over a large range of slightly different parameters (number of taps, passband ripple, start/stop frequencies, etc.) and evaluate each for the issue in question (in your case, ringing). You might find, if you compare say a million possible filters that otherwise meet your spec, at least one of them will be low-ring. Steve
On Tue, 15 Dec 2015 21:47:20 -0500, Randy Yates wrote:

> Tim Wescott <seemywebsite@myfooter.really> writes: > >> On Tue, 15 Dec 2015 18:05:58 -0500, Randy Yates wrote: >> >>> Gentle comp.dsp readers, >>> >>> A requirement just popped up in one of my projects to redesign an FIR >>> lowpass filter so that it doesn't create so much time-domain ringing >>> on spikes. I had originally used octave's firls to design a >>> linear-phase lowpass filter (Fs = 625 Hz, Fp = 100 Hz, Fs = 150 Hz), >>> but its response has got a lot of wigglies. >>> >>> Any thoughts/papers/google searches/bickering/smart remarks/dumb >>> ideas/etc. appreciated. >> >> Fsampling = 625Hz, Fstop = 150Hz? 'cause Fs = 625 and Fs = 150 is a >> bit of a stretch for me... > > Yes, I realized that after I hit the big green SEND button. > >> I'm a philistine, > > Hebrew here. > >> so I'd just make a numerical optimization routine with a cost function >> that penalizes ringing and rewards fit to the ideal, then I'd let >> Scilab chew on it for a good long time to see if it comes up with >> something pretty. > > Oh, is that all? It would take a day just to look up all those terms and > figure out what you're saying!
< snip > Numerical optimization -- letting the computer jigger the parameters for you, and find the best solution. Cost function -- a way of measuring whether a solution is "best". More accurately, it's a way of measuring how "bad" a solution is. Most extant numerical optimization routines try to minimize the cost function. Scilab -- well, you know what that is. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Wed, 16 Dec 2015 13:56:57 -0500, Randy Yates
<yates@digitalsignallabs.com> wrote:

>"tsd822" <110497@DSPRelated> writes: > >>>These are ECG signals. If the patient has a pace maker, there are >>>short spikes intermixed with the ECG data. If the filter has wiggles, >>>the spikes ring. ring == bad (according to the customer, who is >>>always right :) >>>-- >>>Randy Yates, DSP/Embedded Firmware Developer >>>Digital Signal Labs >>>http://www.digitalsignallabs.com >> >> Hi Randy, >> >> I have had the same problem on ECG in the past. >> >> The solution was: >> - for the high frequency noise: using a smoother filter (wider >> transition band) >> - for the power line removal filter (the biggest problem, for which the >> transition bandwidth is necessarily narrow): using an adaptative filter to >> track the power line (phase and magnitude) and remove it on the fly. It is >> so insensible to QRS spikes. >> >> I don't remember the book I had taken the method from (I have sold it >> since...), but it was something like "biomedical signal processing", or >> something like that. If you are interested, I can try to find back. >> >> Kind regards, >> >> Julien > >Thank you for the suggestions and book recommendation, Julien. > >I too considered a larger transition band. Another approach that came to >mind was to use a Gaussian filter. This is (I think, if I understood my >5 minutes of reading) a "perfect" filter for the time-domain, but its >passband (frequency) response is pretty crappy. I'm thinking of widening >it out so that it meets passband variation criteria (e.g., 0 dB, -1 dB), >but haven't analytically thought through that. I'd appreciate any >thoughts you have on this approach. >-- >Randy Yates, DSP/Embedded Firmware Developer >Digital Signal Labs >http://www.digitalsignallabs.com
Like Mark said, the width fo the transition band and the ringing are linked. How bad time-domain ringing will be is pretty easy to assess by inspecting the impulse response; if the main lobe is narrow and/or the sidelobes are distinct, there's going to be ringing. A gaussian is its own Fourier Transform, so, yeah, you can have an impulse response with no ringing, but if you can't tolerate the gaussian frequency response then it's tough to do. Maybe something in-between that achieves a reasonable compromise, or combine techniques (like tracking the line frequency) if compromise is not possible. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com