Discussion:
[SciPy-User] Signal to noise ratio
Nils Wagner
2010-02-24 13:12:30 UTC
Permalink
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
j***@gmail.com
2010-02-24 14:33:12 UTC
Permalink
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Ivo Maljevic
2010-02-24 15:16:19 UTC
Permalink
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
Post by j***@gmail.com
Post by Nils Wagner
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).
Post by j***@gmail.com
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
j***@gmail.com
2010-02-24 15:23:11 UTC
Permalink
Post by Ivo Maljevic
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
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
Post by Ivo Maljevic
Nils, your question is way too generic for anyone to help you directly. I
Post by j***@gmail.com
Post by Nils Wagner
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).
Post by j***@gmail.com
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Ivo Maljevic
2010-02-24 15:35:23 UTC
Permalink
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
Post by j***@gmail.com
Post by Ivo Maljevic
One would think that you can always rely on wikipedia when it comes to
math
Post by Ivo Maljevic
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
Post by Ivo Maljevic
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
Post by Ivo Maljevic
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
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
Post by Ivo Maljevic
Nils, your question is way too generic for anyone to help you directly. I
Post by j***@gmail.com
Post by Nils Wagner
10*math.log10(0.0447)
-13.496924768680636
Maybe your signal is to narrow compared to the overal band you are
working
Post by Ivo Maljevic
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).
Post by j***@gmail.com
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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
Post by Ivo Maljevic
Post by j***@gmail.com
I never use it, but the interpretation will depend on what your
level/mean/expected_value means.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Ivo Maljevic
2010-02-24 15:47:00 UTC
Permalink
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
Post by j***@gmail.com
Post by Ivo Maljevic
One would think that you can always rely on wikipedia when it comes to
math
Post by Ivo Maljevic
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
Post by Ivo Maljevic
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
Post by Ivo Maljevic
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
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
Post by Ivo Maljevic
Nils, your question is way too generic for anyone to help you directly. I
Post by j***@gmail.com
Post by Nils Wagner
10*math.log10(0.0447)
-13.496924768680636
Maybe your signal is to narrow compared to the overal band you are
working
Post by Ivo Maljevic
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).
Post by j***@gmail.com
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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
Post by Ivo Maljevic
Post by j***@gmail.com
I never use it, but the interpretation will depend on what your
level/mean/expected_value means.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
j***@gmail.com
2010-02-24 16:30:33 UTC
Permalink
Post by Ivo Maljevic
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.
Post by Ivo Maljevic
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
Post by Ivo Maljevic
Ivo
Post by j***@gmail.com
Post by Ivo Maljevic
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
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
   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
Post by Ivo Maljevic
Nils, your question is way too generic for anyone to help you directly. I
Post by j***@gmail.com
Post by Nils Wagner
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).
Post by j***@gmail.com
On Wed, Feb 24, 2010 at 8:12 AM, Nils Wagner
Post by Nils Wagner
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.
Post by Nils Wagner
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
Post by Nils Wagner
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Warren Weckesser
2010-02-24 15:51:20 UTC
Permalink
Post by Nils Wagner
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
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Ariel Rokem
2010-03-04 02:20:32 UTC
Permalink
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 <
Post by Warren Weckesser
Post by Nils Wagner
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
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
Ivo Maljevic
2010-03-04 03:17:46 UTC
Permalink
I just tried Warren's example and it works on Ubuntu.

Ivo
Post by Ariel Rokem
Hi Warren,
thanks for this example!
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 <
Post by Warren Weckesser
Post by Nils Wagner
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
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
Warren Weckesser
2010-03-04 17:24:19 UTC
Permalink
Post by Ariel Rokem
Hi Warren,
thanks for this example!
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
Post by Ariel Rokem
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser
Post by Nils Wagner
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
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Warren
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
Ivo Maljevic
2010-03-04 17:48:50 UTC
Permalink
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
Post by Warren Weckesser
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)
Post by Warren Weckesser
ws3
0.040000000000000001
Post by Warren Weckesser
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])
Post by Warren Weckesser
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])
Post by Warren Weckesser
[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
Post by Warren Weckesser
Hi Warren,
thanks for this example!
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
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
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
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
Ariel Rokem
2010-03-04 18:47:33 UTC
Permalink
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 <
Post by Warren Weckesser
Post by Ariel Rokem
Hi Warren,
thanks for this example!
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
Post by Ariel Rokem
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser
Post by Nils Wagner
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
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Post by Ariel Rokem
Warren
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
Ivo Maljevic
2010-03-04 19:20:20 UTC
Permalink
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
Post by Ariel Rokem
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 <
Post by Warren Weckesser
Post by Ariel Rokem
Hi Warren,
thanks for this example!
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
Post by Ariel Rokem
Cheers,
Ariel
On Wed, Feb 24, 2010 at 7:51 AM, Warren Weckesser
Post by Nils Wagner
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
http://mail.scipy.org/pipermail/scipy-user/2010-January/024032.html
Post by Ariel Rokem
Warren
Post by Nils Wagner
How can I eliminate noise from the signal ?
Nils
_______________________________________________
SciPy-User mailing list
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
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
http://mail.scipy.org/mailman/listinfo/scipy-user
Continue reading on narkive:
Loading...