# Bandpass filter with Fourier and inverse.

My understanding of signals is limited. I did a signal processing subject in engineering, but I can't say I got much from it. For me, the subject wasn't taught with enough 'real world' explanation - all mathematics.

I want to take a signal from an experiment I am running, and remove the high frequencies (all above 3Hz).

By applying a fft, I am able to transform my signal into a frequency domain, showing a frequency spectrum and a range of amplitudes. I was lead to believe that if make the amplitudes of the signals I don't want, zero, then inverse transform the signal, I should effectively filter the unwanted frequencies. I have tried this, and it doesn't seem to work.

My thought on why this doesn't work is: In the time domain, the signal can be deconstructed into it's harmonics, each having an transient amplitude over the time period. When transforming to the frequency domain, we loose the time component, so when inverse transforming, we don't have any transient information, essentially we get a periodic signal comprised of all the harmonics superimposed, but the amplitudes of the harmonics don't change in time. Is this correct?

If so, is there a way of determining the amplitude transients in the original signal, masking the frequencies in the frequency domain, then reapplying the amplitude transients in the time domain?

• If you want to remove all frequencies above 3(Hz), then zeroing out the frequency bins that correspond to frequency values of 3(Hz) and higher will do that. That's just true by definition. The error is probably a programming one. Commented Jan 20, 2014 at 0:09
• Also, a harmonic that has a transient amplitude wouldn't be a harmonic, as any amplitude modulation other than unity will induce bandwidth. But you also seem to be hinting at time-frequency analysis. Not sure. Either way, if all you want to do is filter out the higher frequencies, then the right approach is the FFT --> mask --> IFFT method. Commented Jan 20, 2014 at 0:19
• Harmonics and "transients" has little to do with it. If you have conceptual problems, try this: build a signal that is the sum of two sinusoids, with frequencies (sy) 1Hz and 5 Hz. Apply your filter and check if you get the low frequency sinuoid. If it does not work, show us your result. Commented Jan 20, 2014 at 1:48
• What environment are you working in? Matlab, C/C++, Java, Python? Commented Jan 20, 2014 at 21:51
• I'm working with MATLAB. After discussing the problem with someone else, my understanding of it is much better. I thought that to reconstruct an original signal that wasn't periodic, I'd need the range of harmonics (frequency spectrum), with an amplitudes for each that varied over time. This came from my inderstanding of Fourier series, which is quite different to Fourier transformations. Seems I was wrong here. It appears that easiest filtering method is convolution in the time domain. I now just need to determine the window size and shape... Commented Jan 21, 2014 at 23:40

Your question doesn't contain enough detail to answer it. For example, you just just say you tried it and it didn't work. What exactly did you try? An FFT of your entire data set, or did you have to break it into chunks? If you broke it into chunks because it was a large set, there are many potential problems there and I can't begin to guess, but the correct procedure is complex. If you just did it in one go, did you pad your data? And so on.

That said, let me do my best to help you out with a few points:

• it is usually a good idea to do this kind of filtering in the time or spacial domain, rather than the frequency domain. Why? Some of that is covered here: http://blog.bjornroche.com/2012/08/why-eq-is-done-in-time-domain.html

• AnonSubmitter85 is not quite right in his comment when he says, "If you want to remove all frequencies above 3(Hz), then zeroing out the frequency bins that correspond to frequency values of 3(Hz) and higher will do that. That's just true by definition." What actually happens is a bit more complex: you guarantee that the signal at the frequency bins above 3Hz will be zero, but it says nothing about the values between the bins. In fact, a filter designed this way will have attenuation above 3Hz that fluctuates greatly depending on the exact frequency. This is known as filter ripple, and can be reduced in various ways, but not eliminated. Depending on how many bins and what your data looks like exactly, the effect of ripple may be little to no attenuation of high frequencies.

• Time domain filters called IIR filters might "smear" the time response of your data, but it depends on the type and exactly what you are concerned about. If you are eliminating high frequencies to smooth out noise you are probably fine. Here is a blog post I wrote about basic audio filters that can guide you as well: http://blog.bjornroche.com/2012/08/basic-audio-eqs.html That post describes a class of IIR filters. If you are extremely concerned, you can filter your data twice: once regularly and then again with your data set reversed.

• A lot of good info, but I think you might overload the OP with all of it. The post states he doesn't have the required background, so the short answer for him would be something like, "No, your theory about transients is wrong. Scaling the values of an FFT will indeed effectively remove your higher frequency components." Commented Jan 20, 2014 at 1:53
• I think the critical mistake I am making is that this is a time-varying system. Commented Jan 20, 2014 at 2:38
• My signal is a thermistor resistance change in time. How might I best go about filtering something like this? I suppose it'd be similar to filtering background noise from an audio signal. Commented Jan 20, 2014 at 3:08
• You can filter in the time or frequency domain. Judging by the posts around here people tend to try to filter in the frequency domain first because that makes intuitive sense, but The time domain is generally better approach. Commented Jan 23, 2014 at 19:40
• I would follow the instructions from the basic audio eqs link. You want to create a low-pass filter with a cutoff of 3Hz. You can use the FFT you did above to check your results. Commented Jan 23, 2014 at 19:42