![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
Hi all, I have two questions concerning signal processing I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ? How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ? Nils
![](https://secure.gravatar.com/avatar/ad13088a623822caf74e635a68a55eae.jpg?s=120&d=mm&r=g)
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter. Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
One would think that you can always rely on wikipedia when it comes to math and engineering, but it seems that is not tha case. Josef, In the page you referenced, the SNR, or signal to noise ratio, is defined as the ratio between the signal and noise powers. Consequently, in terms of signals and standard deviations, it is defined as a ratio of the average signal power and the noise variance (NOT its squre root, or standard deviation). Or: SNR = P_s / sigma^2 where P_s is the average signal power, and the noise variance is used to measure the noise power. The assumption here is that the noise is a zero mean process, otherwise variance and power wouldn't be the same thing. Nils, your question is way too generic for anyone to help you directly. I can only point to you that your signal to noise ratio is quite low:
10*math.log10(0.0447) -13.496924768680636
Maybe your signal is to narrow compared to the overal band you are working with (or you have DS spread spectrum signal?). Anyway, you will need to figure out which filter you want to use (e.g., butterworth for maximally flat characteristic in the passband, etc). On 24 February 2010 09:33, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition
I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter.
Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/ad13088a623822caf74e635a68a55eae.jpg?s=120&d=mm&r=g)
On Wed, Feb 24, 2010 at 10:16 AM, Ivo Maljevic <ivo.maljevic@gmail.com> wrote:
One would think that you can always rely on wikipedia when it comes to math and engineering, but it seems that is not tha case. Josef, In the page you referenced, the SNR, or signal to noise ratio, is defined as the ratio between the signal and noise powers. Consequently, in terms of signals and standard deviations, it is defined as a ratio of the average signal power and the noise variance (NOT its squre root, or standard deviation). Or:
SNR = P_s / sigma^2
where P_s is the average signal power, and the noise variance is used to measure the noise power. The assumption here is that the noise is a zero mean process, otherwise variance and power wouldn't be the same thing.
Note: I linked to #Statistical_definition not the top of the wikipedia page and I checked the source in scipy.stats: Calculates the signal-to-noise ratio, defined as the ratio between the mean and the standard deviation. m = np.mean(a, axis) sd = samplestd(a, axis) return np.where(sd == 0, 0, m/sd) I didn't know about the different definitions until I read the Wikipedia page, but that's what's currently in scipy.stats Josef
Nils, your question is way too generic for anyone to help you directly. I can only point to you that your signal to noise ratio is quite low:
10*math.log10(0.0447) -13.496924768680636
Maybe your signal is to narrow compared to the overal band you are working with (or you have DS spread spectrum signal?). Anyway, you will need to figure out which filter you want to use (e.g., butterworth for maximally flat characteristic in the passband, etc).
On 24 February 2010 09:33, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition
I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter.
Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
Josef, Maybe the definition you use is for some specific field I'm not familiar with. AFIK, SNR is defined as the ratio of powers and not amplitudes, but my background is in electrical engineering / communiation theory. Please take a look at the following links - but this is just a couple of links from the sea of ones you can find on the web: http://www.scholarpedia.org/article/Signal-to-noise_ratio where it says: Thus, the SNR equals [image: \mathsf{E}[S^2]/\sigma^2_N]. http://authors.library.caltech.edu/3763/1/CUIieeecl06a.pdf (formula 16) Ivo On 24 February 2010 10:23, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 10:16 AM, Ivo Maljevic <ivo.maljevic@gmail.com> wrote:
One would think that you can always rely on wikipedia when it comes to math and engineering, but it seems that is not tha case. Josef, In the page you referenced, the SNR, or signal to noise ratio, is defined as the ratio between the signal and noise powers. Consequently, in terms of signals and standard deviations, it is defined as a ratio of the average signal power and the noise variance (NOT its squre root, or standard deviation). Or:
SNR = P_s / sigma^2
where P_s is the average signal power, and the noise variance is used to measure the noise power. The assumption here is that the noise is a zero mean process, otherwise variance and power wouldn't be the same thing.
Note: I linked to #Statistical_definition not the top of the wikipedia page and I checked the source in scipy.stats: Calculates the signal-to-noise ratio, defined as the ratio between the mean and the standard deviation.
m = np.mean(a, axis) sd = samplestd(a, axis) return np.where(sd == 0, 0, m/sd)
I didn't know about the different definitions until I read the Wikipedia page, but that's what's currently in scipy.stats
Josef
Nils, your question is way too generic for anyone to help you directly. I can only point to you that your signal to noise ratio is quite low:
10*math.log10(0.0447) -13.496924768680636
Maybe your signal is to narrow compared to the overal band you are
working
with (or you have DS spread spectrum signal?). Anyway, you will need to figure out which filter you want to use (e.g., butterworth for maximally flat characteristic in the passband, etc).
On 24 February 2010 09:33, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation
http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition
I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter.
Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
Josef, Just to add, while one can define the "statistical SNR" as something else (that is, ratio E[s]/sigma_noise), what would be its used for? Astronomical optics? On the other hand, it doesn't really matter how it is defined in scipy.stats. Calculation of SNR is usually a bit more involved (you need to find the actual signal mean, and the noise variance), and I guess whoever needs to calculate the power based SNR will not call that function by mistake. Ivo On 24 February 2010 10:23, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 10:16 AM, Ivo Maljevic <ivo.maljevic@gmail.com> wrote:
One would think that you can always rely on wikipedia when it comes to math and engineering, but it seems that is not tha case. Josef, In the page you referenced, the SNR, or signal to noise ratio, is defined as the ratio between the signal and noise powers. Consequently, in terms of signals and standard deviations, it is defined as a ratio of the average signal power and the noise variance (NOT its squre root, or standard deviation). Or:
SNR = P_s / sigma^2
where P_s is the average signal power, and the noise variance is used to measure the noise power. The assumption here is that the noise is a zero mean process, otherwise variance and power wouldn't be the same thing.
Note: I linked to #Statistical_definition not the top of the wikipedia page and I checked the source in scipy.stats: Calculates the signal-to-noise ratio, defined as the ratio between the mean and the standard deviation.
m = np.mean(a, axis) sd = samplestd(a, axis) return np.where(sd == 0, 0, m/sd)
I didn't know about the different definitions until I read the Wikipedia page, but that's what's currently in scipy.stats
Josef
Nils, your question is way too generic for anyone to help you directly. I can only point to you that your signal to noise ratio is quite low:
10*math.log10(0.0447) -13.496924768680636
Maybe your signal is to narrow compared to the overal band you are
working
with (or you have DS spread spectrum signal?). Anyway, you will need to figure out which filter you want to use (e.g., butterworth for maximally flat characteristic in the passband, etc).
On 24 February 2010 09:33, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation
http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition
I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter.
Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/ad13088a623822caf74e635a68a55eae.jpg?s=120&d=mm&r=g)
On Wed, Feb 24, 2010 at 10:47 AM, Ivo Maljevic <ivo.maljevic@gmail.com> wrote:
Josef, Just to add, while one can define the "statistical SNR" as something else (that is, ratio E[s]/sigma_noise), what would be its used for? Astronomical optics?
I never use it, so I don't know.
On the other hand, it doesn't really matter how it is defined in scipy.stats. Calculation of SNR is usually a bit more involved (you need to find the actual signal mean, and the noise variance), and I guess whoever needs to calculate the power based SNR will not call that function by mistake.
I was only referring to the original question that used scipy.stats.signaltonoise It only has a meaning if the level is well defined. If I demean the observations first, then signaltonoise is infinite. If the level is my annual salary, then stats.signaltonoise is essentially the inverse of the coefficient of variation, stats.variation. I'm just looking up definitions, not arguing about the appropriate definitions and it's usefulness in different fields. Cheers, Josef
Ivo
On 24 February 2010 10:23, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 10:16 AM, Ivo Maljevic <ivo.maljevic@gmail.com> wrote:
One would think that you can always rely on wikipedia when it comes to math and engineering, but it seems that is not tha case. Josef, In the page you referenced, the SNR, or signal to noise ratio, is defined as the ratio between the signal and noise powers. Consequently, in terms of signals and standard deviations, it is defined as a ratio of the average signal power and the noise variance (NOT its squre root, or standard deviation). Or:
SNR = P_s / sigma^2
where P_s is the average signal power, and the noise variance is used to measure the noise power. The assumption here is that the noise is a zero mean process, otherwise variance and power wouldn't be the same thing.
Note: I linked to #Statistical_definition not the top of the wikipedia page and I checked the source in scipy.stats: Calculates the signal-to-noise ratio, defined as the ratio between the mean and the standard deviation.
m = np.mean(a, axis) sd = samplestd(a, axis) return np.where(sd == 0, 0, m/sd)
I didn't know about the different definitions until I read the Wikipedia page, but that's what's currently in scipy.stats
Josef
Nils, your question is way too generic for anyone to help you directly. I can only point to you that your signal to noise ratio is quite low:
10*math.log10(0.0447) -13.496924768680636
Maybe your signal is to narrow compared to the overal band you are working with (or you have DS spread spectrum signal?). Anyway, you will need to figure out which filter you want to use (e.g., butterworth for maximally flat characteristic in the passband, etc).
On 24 February 2010 09:33, <josef.pktd@gmail.com> wrote:
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
It's just mean over standard deviation
http://en.wikipedia.org/wiki/Signal-to-noise_ratio#Statistical_definition
I never use it, but the interpretation will depend on what your level/mean/expected_value means.
How can I filter out high frequencies using scipy ? How can I eliminate noise from the signal ?
(I'm no help here) There are many prefabricated filters in scipy.signal, but I only use lfilter.
Josef
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/b0f62d137f9ea1d0b6cc4e7e6f61b119.jpg?s=120&d=mm&r=g)
Nils Wagner wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
How can I filter out high frequencies using scipy ?
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here: http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html Warren
How can I eliminate noise from the signal ?
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/f75a7cfe036871a9a205a2fe1a935a8c.jpg?s=120&d=mm&r=g)
Hi Warren, thanks for this example! I am getting the following error: Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is? Cheers, Ariel On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser < warren.weckesser@enthought.com> wrote:
Nils Wagner wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
How can I filter out high frequencies using scipy ?
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
How can I eliminate noise from the signal ?
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
I just tried Warren's example and it works on Ubuntu. Ivo On 3 March 2010 21:20, Ariel Rokem <arokem@berkeley.edu> wrote:
Hi Warren,
thanks for this example!
I am getting the following error:
Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients)
For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is?
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser < warren.weckesser@enthought.com> wrote:
Nils Wagner wrote:
Hi all,
I have two questions concerning signal processing
I have used scipy.stats.signaltonoise to compute the signal-to-noise ratio. The value is 0.0447. How can I judge it ?
How can I filter out high frequencies using scipy ?
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
How can I eliminate noise from the signal ?
Nils _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/b0f62d137f9ea1d0b6cc4e7e6f61b119.jpg?s=120&d=mm&r=g)
Ariel Rokem wrote:
Hi Warren,
thanks for this example!
I am getting the following error:
Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients)
For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is?
Nils Wagner reported the same behavior a week or so ago, and I see the same behavior now ("BadCoefficients" and a flat line in the last plot). Try lowering the order of the Butterworth filter to order=6. Warren
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser <warren.weckesser@enthought.com <mailto:warren.weckesser@enthought.com>> wrote:
Nils Wagner wrote: > Hi all, > > I have two questions concerning signal processing > > I have used scipy.stats.signaltonoise to compute the > signal-to-noise ratio. > The value is 0.0447. > How can I judge it ? > > How can I filter out high frequencies using scipy ? >
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
> How can I eliminate noise from the signal ? > > Nils > _______________________________________________ > SciPy-User mailing list > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> > http://mail.scipy.org/mailman/listinfo/scipy-user >
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel ------------------------------------------------------------------------
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
If your signal is sampled at 200 Hz (like in this example), and you want to filter out everything above 4 Hz or 12 Hz, you might want to consider using a wider LPF first, downsapling the signal, and then doing the filtering. Usually, sampling rate is related to the frequency content of the signal (Nyquist), and since your signal of interest is much narrower, you have very high oversampling (maybe due to very wide noise?). In any case, even Matlab wouldn't help you much if you wanted to implement such a narrow LPF: Python:
b, a = butter(14, ws3, 'low') C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221: BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients) ws3 0.040000000000000001 b array([ 1.21542041e-16, 7.90023266e-16, 3.16009306e-15, 8.69025592e-15, 1.73805118e-14, 2.60707678e-14, 2.97951632e-14, 2.60707678e-14, 1.73805118e-14, 8.69025592e-15, 3.16009306e-15, 7.90023266e-16, 1.21542041e-16, 8.68157435e-18]) a array([ 1.00000000e+00, -1.28776717e+01, 7.70365408e+01, -2.83749831e+02, 7.18912579e+02, -1.32537586e+03, 1.83351674e+03, -1.93352359e+03, 1.56186993e+03, -9.61728148e+02, 4.44354147e+02, -1.49385526e+02, 3.45431991e+01, -4.91770336e+00, 3.25194854e-01])
Matlab:
[b,a]=butter(14, 0.04, 'low') b = Columns 1 through 12 0 0 0 0 0 0 0 0 0 0 0 0 Columns 13 through 15 0 0 0
a = 1.0e+003 * Columns 1 through 7 0.0010 -0.0129 0.0770 -0.2837 0.7189 -1.3254 1.8335 Columns 8 through 14 -1.9335 1.5619 -0.9617 0.4444 -0.1494 0.0345 -0.0049 Column 15 0.0003 On 4 March 2010 12:24, Warren Weckesser <warren.weckesser@enthought.com>wrote:
Ariel Rokem wrote:
Hi Warren,
thanks for this example!
I am getting the following error:
Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224:
BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients)
For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is?
Nils Wagner reported the same behavior a week or so ago, and I see the same behavior now ("BadCoefficients" and a flat line in the last plot). Try lowering the order of the Butterworth filter to order=6.
Warren
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser <warren.weckesser@enthought.com <mailto:warren.weckesser@enthought.com>> wrote:
Nils Wagner wrote: > Hi all, > > I have two questions concerning signal processing > > I have used scipy.stats.signaltonoise to compute the > signal-to-noise ratio. > The value is 0.0447. > How can I judge it ? > > How can I filter out high frequencies using scipy ? >
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
> How can I eliminate noise from the signal ? > > Nils > _______________________________________________ > SciPy-User mailing list > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> > http://mail.scipy.org/mailman/listinfo/scipy-user >
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel ------------------------------------------------------------------------
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/f75a7cfe036871a9a205a2fe1a935a8c.jpg?s=120&d=mm&r=g)
Interesting. It does work with lower filter order. In fact, there is a range of values of filter order for which I get the warning, but also some result. This results looks slightly flatter than the result with filter order set to 6, but is not completely flat. What does the filter order do, intuitively? Thanks - Ariel On Thu, Mar 4, 2010 at 9:24 AM, Warren Weckesser < warren.weckesser@enthought.com> wrote:
Ariel Rokem wrote:
Hi Warren,
thanks for this example!
I am getting the following error:
Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224:
BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients)
For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is?
Nils Wagner reported the same behavior a week or so ago, and I see the same behavior now ("BadCoefficients" and a flat line in the last plot). Try lowering the order of the Butterworth filter to order=6.
Warren
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser <warren.weckesser@enthought.com <mailto:warren.weckesser@enthought.com>> wrote:
Nils Wagner wrote: > Hi all, > > I have two questions concerning signal processing > > I have used scipy.stats.signaltonoise to compute the > signal-to-noise ratio. > The value is 0.0447. > How can I judge it ? > > How can I filter out high frequencies using scipy ? >
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
> How can I eliminate noise from the signal ? > > Nils > _______________________________________________ > SciPy-User mailing list > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> > http://mail.scipy.org/mailman/listinfo/scipy-user >
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel ------------------------------------------------------------------------
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
![](https://secure.gravatar.com/avatar/a882665c0be8c10a93b73ea403c53acd.jpg?s=120&d=mm&r=g)
Arieal, I just did a quick search and found the same thing I told you on Matlab site (i.e., narrowband filter): http://www.mathworks.com/access/helpdesk/help/toolbox/signal/f4-1046.html While it may be interesting to play with cuttoff frequencies and filter order, it is quite useless from a practical point of view. To use a tool, you need to understand what it does and what are its limitations. What you are trying to do with the filter is almost the same as if you are trying to find the mean value of the signal (hence the almost flat line). You definitely do not need butterworth filter for that, just find the mean value of the signal for such type of operation. As for your order question, it basically determines how many past samples are you using in the filtering operation. Maybe you can read this: http://en.wikipedia.org/wiki/Digital_filter#Difference_equation Cheers, Ivo On 4 March 2010 13:47, Ariel Rokem <arokem@berkeley.edu> wrote:
Interesting. It does work with lower filter order. In fact, there is a range of values of filter order for which I get the warning, but also some result. This results looks slightly flatter than the result with filter order set to 6, but is not completely flat. What does the filter order do, intuitively?
Thanks - Ariel
On Thu, Mar 4, 2010 at 9:24 AM, Warren Weckesser < warren.weckesser@enthought.com> wrote:
Ariel Rokem wrote:
Hi Warren,
thanks for this example!
I am getting the following error:
Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/scipy/signal/filter_design.py:224:
BadCoefficients: Badly conditionned filter coefficients (numerator): the results may be meaningless "results may be meaningless", BadCoefficients)
For any attempt to filter a low-pass below 12 Hz in this example (so - I don't get the plot you got - instead I get a flat line on the bottom subplot). Do you (or anyone?) have any idea why that is?
Nils Wagner reported the same behavior a week or so ago, and I see the same behavior now ("BadCoefficients" and a flat line in the last plot). Try lowering the order of the Butterworth filter to order=6.
Warren
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser <warren.weckesser@enthought.com <mailto:warren.weckesser@enthought.com>> wrote:
Nils Wagner wrote: > Hi all, > > I have two questions concerning signal processing > > I have used scipy.stats.signaltonoise to compute the > signal-to-noise ratio. > The value is 0.0447. > How can I judge it ? > > How can I filter out high frequencies using scipy ? >
I posted an example low-pass filtering using 'butter' and 'lfilter' from scipy.signal here:
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
> How can I eliminate noise from the signal ? > > Nils > _______________________________________________ > SciPy-User mailing list > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> > http://mail.scipy.org/mailman/listinfo/scipy-user >
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel ------------------------------------------------------------------------
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
-- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
participants (5)
-
Ariel Rokem
-
Ivo Maljevic
-
josef.pktd@gmail.com
-
Nils Wagner
-
Warren Weckesser