# Tag Info

33

filtfilt is zero-phase filtering, which doesn't shift the signal as it filters. Since the phase is zero at all frequencies, it is also linear-phase. Filtering backwards in time requires you to predict the future, so it can't be used in "online" real-life applications, only for offline processing of recordings of signals. lfilter is causal forward-in-time ...

21

Isn't white noise supposed to have a flat magnitude response? (equal amounts for all frequencies) The expected magnitude response of white noise is flat (this is what JasonR calls the power spectral density). Any particular instance of a white noise sequence will not have precisely flat response (this is what JasonR's comment refers to as the power ...

19

The frequency response for the filter designed using the butter function is: But there is no reason to limit the filter to a constant monotonic filter design. If you desire a higher attenuation in the stopband and steeper transition band, other options exist. For more information on specifying a filter using iirdesing see this. As shown by the frequency ...

16

You have a bug in ft2. You are incrementing i, and freq together. That's not how you want your summation to work. I messed around with fixing it, but it got messy. I decided to rewrite it from a discrete perspective instead of trying to use the continuous terminology. In the DFT, the sampling rate is irrelevant. What matters is how many samples are ...

15

OK I've cracked this finally. The trick basically came down to putting some fftshift/ifftshifts in the right place so the 2D Fourier space representation was not wildly oscillatory and doomed to be impossible to interpolate accurately. At least that's what I think fixed it. Most of what limited understanding I do have of Fourier theory is based on the ...

15

As pointed out by @JohnRobertson in Bag of Tricks for Denoising Signals While Maintaining Sharp Transitions, Total Variaton (TV) denoising is another good alternative if your signal is piece-wise constant. This may be the case for the accelerometer data, if your signal keeps varying between different plateaux. Below is a Matlab code that performs TV ...

13

i'm not gonna deal with python nor numpy nor any other parochial computational platform. first, since "silence" is a perceptual property, you need to apply a weighting filter, such as A-weighting to boost the frequency components of the audio that our ears are more sensitive to and attenuate the portions we're less sensitive to. there are other weighting ...

12

It's not only about programming language but library you are using. I can think of the following: MATLAB - image processing capabilities are quite ok, but for more advanced and real time processing you would need some low-level stuff. Additionally, it does not offer very good portability. Mathematica - good for prototyping and quick visualization, but ...

10

Personally I find Python one of the best choices out there and did myself some work in area of audio identification. You are welcomed to check for instance my software for automatic identification of birds from noisy audio recordings: Ornithokrites. The program is used by Department of Conservation of New Zealand and they are happy about it. Based on this ...

9

A first attempt using Matlab: im = imread('squares.jpg'); im2 = rgb2gray(im); se = strel('disk', 15); for i = 1:16; t = 60+i*5; % try out a range of bw thresholds to see what works best labelled = bwlabel(im2>t); % label regions in the BW image closed = imclose(labelled, se); % close small regions cleared = imclearborder(~closed,4); % ...

9

You should not be using the analog filter - use a digital filter instead. You want the filter to be defined in Z-domain, not S-domain. Also, you should define the time vector with known sampling frequency to avoid any confusion. The design of the digital filter requires cut-off frequency to be normalized by fs/2. Here is a working example: import numpy as ...

8

In theory you can do this, but in practice it is difficult to do because the time and phase alignment must be pretty good for it to work. If the alignment is good you will get the destructive interference that you are seeking. If they aren't, you will get some constructive interference. Even worse, whether they are destructively or constructively ...

8

I had tried something else to improve my result in question. Below solution is on the assumption that first square(orange) is always detected in step 1. And it is practical due to its high contrast color compare to background. Even the result I showed in question has detected it correctly Step 1 : Find as many squares possible I split the image to R,G,B,H,...

8

What's not clear to me is what the fundamental difference (if any) is between simulating an analog filter and making a digital filter. Either way, these functions will produce "ba" transfer function outputs, but the b and a are totally different. For a 2nd-order filter, for instance, b = [b0, b1, b2] and a = [a0, a1, a2]. These are the coefficients of the ...

8

Answer by @endolith is complete and correct! Please read his post first, and then this one in addition to it. Due to my low reputation I was unable to respond to comments where @Thomas Arildsen and @endolith argue about effective order of filter obtained by filtfilt: lfilter does apply given filter and in Fourier space this is like applying filter transfer ...

8

Is this meant to happen? Yes, that is absolutely a well known effect of using any window function. Taking a look through the Wikipedia article on window functions, we find that the rectangular window has the sharpest peak. This is quite simply due to the fact that the rectangular window acquires the most data, meaning that it can distinguish between ...

8

I found the answer finally. I found a great article that explains many different libraries that can be utilized for peak detection. I now have the peaks I am really interested in, and can now create the output I am requiring. Finding Peaks in Python

8

Parseval's theorem will hold, but take into account that your signal in the time domain will no longer be $x[n]$. Namely, if you have that $$\sum_{n=0}^{N-1} \Big| x[n] \Big|^2 = \frac{1}{N} \sum_{k=0}^{N-1} \Big| X[k] \Big|^2$$ then, if you window the signal $x[n]$ with a window $w[n]$, your signal will now be $\hat{x}[n]=x[n]w[n]$, and the theorem will ...

8

Since this is a constant spectrogram, you could just as well have just averaged the |FFT|² and plotted that! (The most colorful way of visualizing things isn't always the optimal one; your signal doesn't change over time, so you don't need the time axis of the spectrogram at all.) Quite possibly, in that "easier" representation, you would have ...

7

The problem is that your noise has a flat spectrum. If you assume white Gaussian noise (which turns out to be a good assumption) its power spectrum density is constant. Roughly speaking, it means that your noise contains all frequencies. That's why any frequency approach, e.g. DFT or low-pass filters, is not a good one. What would be your cut-off frequencies ...

7

Two potential problems with your approach: You are computing the FFT on your whole signal, which will be terribly inefficient if your input data gets too large, and prevents you from using windowing. If you want to do frequency-domain modifications of your signal, consider using a Short-Term Fourier Transform, processing the resulting FFT frames, and ...

7

Just had a look, and from the wikipedia definition of the Goertzel algorithm, the frequency in the cosine weight should be a normalized frequency (as for the DFT, by the way). If you modify your code as below, you should get the right output (note also that your computation of the power led to negative powers -sic-, removing a redundant factor 2 solved that ...

7

I would recommend doing some proper reading of books/tutorials etc on the Fourier transform and the Discrete Fourier Transform (DFT). You will also want to look at filters and probably convolution for the bandpass filter. But regardless, here's some info that should help with your current state: Use matplotlib to plot the FT that you've calculated: fs = ...

7

Your signal recording clearly shows that you have long streaks of 1.0 – that probably means you're clipping. Your signal is thus broken. Make a new recording with less gain.

7

Change the following line : time1 = np.linspace(0, capture_size1 * timestep1, capture_size1) To the following: time1 = np.linspace(0, capture_size1 * timestep1, capture_size1, endpoint=false) You will see correct results. Your original time instances is not what you intend because Python will create 2048 equally spaced point between 0 and 2048*Ts. ...

7

[EDITED FROM DISCUSSION] On the first order, your data looks like a decay with a positive origin on a small-valued range $[0.7 \; 0.49]\times 10^{-7}$, and very tiny fluctuations with respect to the area under the curve. So from afar, your data is much closer to an almost constant function than to some putative oscillations. So the the zero, or DC-...

6

Linear FIR filters are applied to a signal (like your audio file) using discrete convolution. Convolution can be implemented efficiently using the FFT. Two separate schemes for doing this are called the overlap-save and overlap-add methods. I personally prefer overlap-save, as it's a bit simpler to implement. It's not clear from your question exactly what ...

6

I have had good time implementing what this guy says: http://mpastell.com/2010/01/18/fir-with-scipy/ A typical low pass filter I use, got from the given link, is this: def firfilt(interval, freq, sampling_rate): nfreq = freq/(0.5*sampling_rate) taps = sampling_rate + 1 a = 1 b = scipy.signal.firwin(taps, cutoff=nfreq) return scipy....

Only top voted, non community-wiki answers of a minimum length are eligible