Hot answers tagged

30

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 ...


23

The fact that the result is complex is to be expected. I want to point out a couple things: You are applying a brick-wall frequency-domain filter to the data, attempting to zero out all FFT outputs that correspond to a frequency greater than 0.005 Hz, then inverse-transforming to get a time-domain signal again. In order for the result to be real, then the ...


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 ...


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 ...


13

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 ...


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 ...


11

ICA in raw form is only suitable for use with phase synchronised observation mixtures. Using microphones as you have described will introduce a phase delay as pointed out by other posters. However this phase delay can be used to great avail. The best known algorithm that deals with stereo separation in the presence of delays is DUET. The links are broken but ...


11

Here are the matplotlib.specgram parameters matplotlib.mlab.specgram(x, NFFT=256, Fs=2, detrend=<function detrend_none at 0x1dd6410>, window=<function window_hanning at 0x1e0b1b8>, noverlap=128, ...


11

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 ...


9

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); % ...


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

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 spotted this: ...


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

First, have a look at the squares.py sample provided by OpenCV. It should handle a fair number of button types with some tweaking. Here is the output I got (with some tweaking) for your Calculator example: I made the following tweaks to the squares application: Change this code (starting on line 84): if(result.total == 4 and abs(cv.ContourArea(result)...


7

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 ...


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

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 ...


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

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 ...


6

As I say further down the page: it turns out that ICA doesn’t actually work well when the signals occur at different delays in the different sensor channels; it assumes instantaneous mixing (that the signals are in perfect sync with each other in all the different recordings). Delay would happen in a real-life situation with performers and microphones, ...


6

It seems to be a time/frequency resolution problem. Your Praat plot has a worse frequency resolution (you cannot even clearly see the harmonics) and a better time resolution. Try reducing the window size (NFFT) to 16000 x 0.05 = 80 samples. I'd suggest using a bigger power of 2 in pad_to (128 or 256).


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