Forums

narrow band (notch?) filters at a range of frequencies

Started by Unknown February 28, 2008
hi,

i have two very noisy signals, and i am hoping to generate some sort
of "diff" of the two signals in frequency space.  so far, i have
computed a power spectral density estimate of each of the two
signals.  then i subtracted the PSD of one from the other (the idea
being that frequencies where one has low power and the other high
power, i should see a big difference... positive or negative, but big
differences where the power differs).  now i would like to filter one
of the signals, selecting only frequencies where there was a big
difference between the two.  this process may be better understood
with the following pseudocode of what i have done:

sig1 = signal1
sig2 = signal2

psd1 = computePSD(sig1)
psd2 = computePSD(sig2)

psdDiff = absoluteValue(psd1 - psd2)

diffPeaks = findPeaks(psdDiff)

filteredSig = filter(sig1, diffPeaks)


so, i have a couple questions:
1) does this make any sense whatsoever to do something like this?  a
simple "hell no, not even a little" would be tolerated, as i really
have very little idea wtf i am doing here.

2) if this is entirely nonsensical, what is a more standard way of
finding frequency-specific differences between two signals, and then
generating a third signal that is a frequency-dependent difference of
one signal from another?

3) if this is not a totally absurd approach, what sorts of things do i
need to concern myself with when doing something like this?
specifically, i am concerned about the following:  if i have diffPeaks
returning a bunch of frequencies (like 1, 4, 9, 11, 18 and 23 kHz),
what are the limitations/consequences of repeatedly filtering the
signal with a series of notch filters at the specified frequencies?
or can i generate all the notch filters, convolve them together, and
then use that as a single filter?  so this question amounts to: what
is a good way to filter a signal at a set of (non-continuous) specific
frequencies?

thanks for any insight on this,
bryan
On Thu, 28 Feb 2008 15:50:12 -0800, cssmwbs wrote:

> hi, > > i have two very noisy signals, and i am hoping to generate some sort of > "diff" of the two signals in frequency space. so far, i have computed a > power spectral density estimate of each of the two signals. then i > subtracted the PSD of one from the other (the idea being that > frequencies where one has low power and the other high power, i should > see a big difference... positive or negative, but big differences where > the power differs). now i would like to filter one of the signals, > selecting only frequencies where there was a big difference between the > two. this process may be better understood with the following > pseudocode of what i have done: > > sig1 = signal1 > sig2 = signal2 > > psd1 = computePSD(sig1) > psd2 = computePSD(sig2) > > psdDiff = absoluteValue(psd1 - psd2) > > diffPeaks = findPeaks(psdDiff) > > filteredSig = filter(sig1, diffPeaks) > > > so, i have a couple questions: > 1) does this make any sense whatsoever to do something like this? a > simple "hell no, not even a little" would be tolerated, as i really have > very little idea wtf i am doing here.
It's hard to say without knowing what you want to do with the filtered signals. If you don't know why you want to do something that's a good indication that you haven't analyzed your problem enough.
> 2) if this is entirely nonsensical, what is a more standard way of > finding frequency-specific differences between two signals, and then > generating a third signal that is a frequency-dependent difference of > one signal from another? > > 3) if this is not a totally absurd approach, what sorts of things do i > need to concern myself with when doing something like this? > specifically, i am concerned about the following: if i have diffPeaks > returning a bunch of frequencies (like 1, 4, 9, 11, 18 and 23 kHz), what > are the limitations/consequences of repeatedly filtering the signal with > a series of notch filters at the specified frequencies? or can i > generate all the notch filters, convolve them together, and then use > that as a single filter? so this question amounts to: what is a good > way to filter a signal at a set of (non-continuous) specific > frequencies?
Do you mean _notch_ filters, which will filter the desired signal _out_, or do you mean _bandpass_ filters, which will filter out everything else? Whatever else you want to do, if you take a set of cascaded FIR filters you can, indeed, convolve their impulse responses to get one big filter. This may not be the wisest thing, but it's a thing that you can do. If you really want bandpass filters, then you don't want to cascade them -- unless the passbands overlap you'll just end up with nothing, and you can get that a lot quicker by multiplying your signal by 0. Instead, you want to add them (taking care that you're not messing them up if they overlap). -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Feb 28, 11:21 pm, Tim Wescott <t...@seemywebsite.com> wrote:
> On Thu, 28 Feb 2008 15:50:12 -0800, cssmwbs wrote: > > It's hard to say without knowing what you want to do with the filtered > signals. If you don't know why you want to do something that's a good > indication that you haven't analyzed your problem enough.
errrr... yes, i know exactly what i am going to do with the result... unfortunately i work for a company, and i cannot explain sufficiently well what i intend to do without giving more information than i can reasonably give over a usenet group. suffice it to say i have thought in considerable detail about how i will use the filtered and unfiltered signals, and they will basically be applied to a system in which we will measure response differences between the various signals.
> Do you mean _notch_ filters, which will filter the desired signal _out_, > or do you mean _bandpass_ filters, which will filter out everything else?
indeed, i mean bandpass filters... thank you for the correction.
> Whatever else you want to do, if you take a set of cascaded FIR filters > you can, indeed, convolve their impulse responses to get one big filter. > This may not be the wisest thing, but it's a thing that you can do.
ok... even though i do intend to use bandpass filters, why may this not be the wisest thing to do (convolve the filters to get one big filter)? what are the potential drawbacks of convolving 'cascaded FIR filters'? just for my edification.
> If you really want bandpass filters, then you don't want to cascade them > -- unless the passbands overlap you'll just end up with nothing, and you > can get that a lot quicker by multiplying your signal by 0. Instead, you > want to add them (taking care that you're not messing them up if they > overlap).
ok, thanks also for this insight. so if the impulse responsea of the passband filters have some overlap, i cannot add them, and instead should run the set of filters sequentially? how much overlap is ok, or is ANY overlap not ok? thanks again, bryan
Hi Bryan,
Not silly at all. You are creating a custom frequency response called a
"Wiener filter":

http://www.dspguide.com/ch17/3.htm

then you need to find the FIR filter that implements this frequency
response:

http://www.dspguide.com/ch17/1.htm
 
Regards,
Steve
On 29 Feb, 00:50, cssm...@gmail.com wrote:
> hi, > > i have two very noisy signals, and i am hoping to generate some sort > of "diff" of the two signals in frequency space. &#2013266080;so far, i have > computed a power spectral density estimate of each of the two > signals. &#2013266080;then i subtracted the PSD of one from the other (the idea > being that frequencies where one has low power and the other high > power, i should see a big difference... positive or negative, but big > differences where the power differs). &#2013266080;now i would like to filter one > of the signals, selecting only frequencies where there was a big > difference between the two. &#2013266080;this process may be better understood > with the following pseudocode of what i have done: > > sig1 = signal1 > sig2 = signal2 > > psd1 = computePSD(sig1) > psd2 = computePSD(sig2) > > psdDiff = absoluteValue(psd1 - psd2) > > diffPeaks = findPeaks(psdDiff) > > filteredSig = filter(sig1, diffPeaks) > > so, i have a couple questions: > 1) does this make any sense whatsoever to do something like this? &#2013266080;a > simple "hell no, not even a little" would be tolerated, as i really > have very little idea wtf i am doing here.
The end objective might make sense, but somehow I think subtracting PSDs might not be a very good way to do things. My gut feeling is that the cross spectrum ought to be used instead.
> 2) if this is entirely nonsensical, what is a more standard way of > finding frequency-specific differences between two signals, and then > generating a third signal that is a frequency-dependent difference of > one signal from another?
The cross spectrum is one approach to test. Mind you, it basically detects the frequency bands where both the two signals have large energy. You want to identify where one signal is large and the other is small. That might require some tweaking, which might not be worth the effort.
> 3) if this is not a totally absurd approach, what sorts of things do i > need to concern myself with when doing something like this? > specifically, i am concerned about the following: &#2013266080;if i have diffPeaks > returning a bunch of frequencies (like 1, 4, 9, 11, 18 and 23 kHz), > what are the limitations/consequences of repeatedly filtering the > signal with a series of notch filters at the specified frequencies?
As always it is a trade-off between bandwidth in frequency domain and ringing in time domain. A large notch bandwidth reduces ringing in time domain but might kill too much of the useful signal. And vice versa.
> or can i generate all the notch filters, convolve them together, and > then use that as a single filter? &#2013266080;
The two approaches are *formally* equivalent. There may be practical issues, though, e.g. numerical effects in fixed-point arithmetic, which favours one approach or the other.
> so this question amounts to: what > is a good way to filter a signal at a set of (non-continuous) specific > frequencies?
Rune
wbs wrote:
> On Feb 28, 11:21 pm, Tim Wescott <t...@seemywebsite.com> wrote: >> On Thu, 28 Feb 2008 15:50:12 -0800, cssmwbs wrote: >> >> It's hard to say without knowing what you want to do with the filtered >> signals. If you don't know why you want to do something that's a good >> indication that you haven't analyzed your problem enough. > > errrr... yes, i know exactly what i am going to do with the result... > unfortunately i work for a company, and i cannot explain sufficiently > well what i intend to do without giving more information than i can > reasonably give over a usenet group. suffice it to say i have thought > in considerable detail about how i will use the filtered and > unfiltered signals, and they will basically be applied to a system in > which we will measure response differences between the various > signals. > >> Do you mean _notch_ filters, which will filter the desired signal _out_, >> or do you mean _bandpass_ filters, which will filter out everything else? > > indeed, i mean bandpass filters... thank you for the correction. > >> Whatever else you want to do, if you take a set of cascaded FIR filters >> you can, indeed, convolve their impulse responses to get one big filter. >> This may not be the wisest thing, but it's a thing that you can do. > > ok... even though i do intend to use bandpass filters, why may this > not be the wisest thing to do (convolve the filters to get one big > filter)? what are the potential drawbacks of convolving 'cascaded FIR > filters'? just for my edification. > >> If you really want bandpass filters, then you don't want to cascade them >> -- unless the passbands overlap you'll just end up with nothing, and you >> can get that a lot quicker by multiplying your signal by 0. Instead, you >> want to add them (taking care that you're not messing them up if they >> overlap). > > ok, thanks also for this insight. so if the impulse responsea of the > passband filters have some overlap, i cannot add them, and instead > should run the set of filters sequentially? how much overlap is ok, > or is ANY overlap not ok?
If you have one filter that passes only blue light and you stack it with one that passes only red, nothing gets through. the only colors that get through cascaded filters are those that both pass. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
On Feb 29, 11:45 am, "SteveSmith" <Steve.Smi...@SpectrumSDI.com>
wrote:
> Hi Bryan, > Not silly at all. You are creating a custom frequency response called a > "Wiener filter": > > http://www.dspguide.com/ch17/3.htm > > then you need to find the FIR filter that implements this frequency > response: > > http://www.dspguide.com/ch17/1.htm > > Regards, > Steve
hi steve, very nice... thanks for the links. in matlab, i found a function called 'firwiener' but it is sparsely documented. it takes three arguments: filter order, and two signals. i wonder if this is generating a diff filter for me? i will have to look into this. thanks again, bryan
On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote:

> The end objective might make sense, but somehow I think > subtracting PSDs might not be a very good way to do things. > My gut feeling is that the cross spectrum ought to be used > instead.
yes, fair enough... this is kinda what i was wondering, and why i posted this here. i am not so sure what it means mathematically to go subtracting PSDs from each other.
> > 2) if this is entirely nonsensical, what is a more standard way of > > finding frequency-specific differences between two signals, and then > > generating a third signal that is a frequency-dependent difference of > > one signal from another? > > The cross spectrum is one approach to test. Mind you, it > basically detects the frequency bands where both the two > signals have large energy. You want to identify where one > signal is large and the other is small. That might require > some tweaking, which might not be worth the effort.
right, so i first looked at the cross spectrum of the two signals, and then didn't really know what to do with that. while this may not be 'worth the effort' i wonder if you can help me figure out how i might actually use the cross-PSD to get at this issue. regards, bryan
On Fri, 29 Feb 2008 13:45:12 -0600, SteveSmith wrote:

> Hi Bryan, > Not silly at all. You are creating a custom frequency response called a > "Wiener filter": >
<snip> Does that mean it doesn't let the hot dogs through, or that it only lets the hot dogs through. (sorry, I'm tired, can't resist). -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On 1 Mar, 00:43, wbs <cssm...@gmail.com> wrote:
> On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> > > 2) if this is entirely nonsensical, what is a more standard way of > > > finding frequency-specific differences between two signals, and then > > > generating a third signal that is a frequency-dependent difference of > > > one signal from another? > > > The cross spectrum is one approach to test. Mind you, it > > basically detects the frequency bands where both the two > > signals have large energy. You want to identify where one > > signal is large and the other is small. That might require > > some tweaking, which might not be worth the effort. > > right, so i first looked at the cross spectrum of the two signals, and > then didn't really know what to do with that. &#2013266080;while this may not be > 'worth the effort' i wonder if you can help me figure out how i might > actually use the cross-PSD to get at this issue.
A *very* peliminary, naive approach (not to mention untested!) would be to first compute the energy normalized autospetcra: pxx(f) = Pxx(f)/Px pyy(f) = Pyy(f)/Py where Px means 'Pxx(f) integrated over f'. Then compute the cross spectrum cxy(f) with the same normalization - I wouldn't be surprised if this would look something like cxy(f)^2 = Cxy(f)^2/sqrt(Px*Py) This, all of a sudden, looks very similar to measuring the coherence between x and y. Which, in turn, *might* suggest that fitting a filter to the coherence spectrum between x and y might help you in your task. Just keep in mind that I post this on an 'early' saturday morning following a late friday night, long before I got any hint of breakfast. If you still take the chance to follow up on my dubious hunches, you might want to check out Bendat & Piersol: "Random Data" Rune