# Help me understand the stages involved in filtering a signal using Discrete Fourier Transform

I have a series of discrete values measured from a sensor. I want to filter the frequencies coming from this sequence of values. Then, if I understood the process correctly this is what I do:

1. I create a discrete fourier transform of the values
2. I identify the bins that correspond to the frequencies I want to remove from the original signal using the formula freq = (k * FPS)/N, where k is the bin number (starting at zero), FPS is the frames per second the signal is being captured and N is the number of samples.
3. supposing I want to remove from the signal every frequency below 10 Hz and the 9th bin is equal to 10 Hz, then I zero, all the real and imaginary bins from 0 to 9 of the DFT result.
4. then I reconstruct the signal using this inverse DFT results with certain bins zeroed (filtered).

If this process is correct, I do not understand one thing:

In my original signal I get only real values. I input these real values into the DFT algorithm using zeros for all imaginary parts. I get real and imaginary from the DFT. I filter the whole thing and do an inverse DFT. The final results is real and imaginary.

How do I get a real only signal after the inverse DFT? How do I get rid of the imaginary part and get a real only result?

• Is this a single buffer of data that you are filtering? Or is it a stream of data that you are filtering in frames? Mar 11, 2019 at 20:05
• This is real time. I let the sensor capturing data for 10 seconds. In 10 seconds I will have 256 readings. When the program hits 256 samples, I analyze it. Next sample will be added to the end of that array and the first one will be dropped. Every operation like DFT and so, are over this array of 256 samples.
– Duck
Mar 11, 2019 at 20:47
• the kind of filtering that you doing is linear convolution. and the kind of filtering that multiplying the DFT result is doing is circular convolution. now there are two methods of forcing the DFT (that knows how to do circular convolution) into doing linear convolution. they are Overlap-add and Overlap-Save. you are doing Overlap-Save with the buffer size of 1 sample and an FIR length having the same length of the DFT. because that is 256 samples, you can independently control the magnitude and phase of 63 frequencies and the magnitude (and not phase) of DC and Nyquist component. Mar 12, 2019 at 6:55