Reply by Max December 16, 20152015-12-16
On Tue, 15 Dec 2015 18:05:58 -0500, Randy Yates
<yates@digitalsignallabs.com> 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.
Randy, Just a couple tangential thoughts: The high end of the audio industry has been pursuing solutions to ringing, including use of minimal phase filters to push the ringing to an area that will be masked, or at least perceived as less intrusive. There has been mention of 'apodizing filtters' for this purpose. I'm not sure why that would need to be a separate filter, and it's certainly no free lunch. But companies like Meridian have been pursuing it, and they're not typical purveyers of mystical audio voodoo. Or perhaps some type of adaptive filter? You already know that you're working with a specific response (QRS), so there may be nonlinear transforms that can be adapted. I imagine that most signals fit a finite set of profiles. Or how about neural networks? They're being used more often for signal processing apps now. A shot in the dark: There's a book by Timothy Masters called "Signal and Image Processing with Neural Networks" (ISBN 0471049638) that may have something. I know he deals with statistical filtering methods. That book is rather old (comes with a diskette!) but it's inexpensive and the data is relevant. Another of his books: "Neural, Novel & Hybrid Algorithms for Time Series Prediction" may also be useful. Amazon has a preview of the latter. Source code for both on his site: http://timothymasters.info/ The thing that occurred to me is the possibility of doing analysis of the waveform using a neural net. They're incredibly good at pattern matching, so you may be able to train a simple network with healthy profiles and known aberrations, and get some idea of a match with new input. It is being done with other medical signals, and even radiographs. BTW, I have both of the Timothy Masters books somewhere. If you have specific questions, I'll dig 'em up and take a look. You might also sound Timothy out about this,as he knows both sides of the tracks.
Reply by Greg Berchin December 16, 20152015-12-16
On Wednesday, December 16, 2015 at 1:26:58 PM UTC-6, Steve Pope wrote:

> 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).
The classical approach is to design the frequency response and then evaluate the resulting time domain response. Don't forget duality -- design the impulse response and then evaluate the resulting frequency response. It might be a faster path to an acceptable solution. Harris' "windows" paper might be a good starting point: https://www.utdallas.edu/~cpb021000/EE%204361/Great%20DSP%20Papers/Harris%20on%20Windows.pdf Greg
Reply by Eric Jacobsen December 16, 20152015-12-16
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
Reply by Tim Wescott December 16, 20152015-12-16
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
Reply by Steve Pope December 16, 20152015-12-16
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
Reply by Randy Yates December 16, 20152015-12-16
"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
Reply by Randy Yates December 16, 20152015-12-16
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
Reply by December 16, 20152015-12-16
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
Reply by December 16, 20152015-12-16
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
Reply by Les Cargill December 16, 20152015-12-16
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