# Digital filtering based on frequency component amplitude... why not?

I've got a very general question. I've just implemented a filter working in frequency domain that simply cuts every frequency component whose modulus amplitude falls below a certain threshold value. As to say, "just keep the main frequencies in the signal". See example below: Here is the effect in time domain on a noisy square wave: It could seem to have poor performance in time domain, but this 'frequency picking' worked perfectly for my particular problem. However, it seems to me that this is not so usual in DSP, and, since I'm not a DSP expert (I'm a physicist and not an electronic engineer), I wonder if this kind of approach (i.e. select the frequencies to keep based on their amplitude in the transformed domain and discard all the rest) is a known method in literature and, if it's so, what's its name. Or, on the contrary, I would be curious to know if there are some general reasons to avoid such a criterion. I found no reference on the web...

Thanks!

Federico

• The answers to this question explain why frequency-selective filtering by zeroing frequency bins generally results in a poor filter. However, that doesn't mean that this method might not be beneficial for certain applications. Commented May 15, 2020 at 11:15

This is a totally classical approach. Assuming that there is a noise floor in the spectrum, or in any suitable transformation of you data, setting to zero coefficients in the transformed domain (below a threshold), before going back to the original domain, can be called scalar hard-thresholding. Many variants have be developed, like "spectral subtraction", iterative versions, vector-thresholding (based on the energy of subgroups of coefficients).

The core of the process is the following hypotheses and actions:

• acquired signals or observations are composed of useful information (more or less structured) and noise/disturbances (more or less unstructured)
• the structured information can be better concentrated than the unstructured one (sparsity or parsimony) with some transformation of the data
• in the transformed domain, modify the coefficients according to their ampitude
• go back to the original domain (with caution on its domain of validity).

Meanwhile, all this should be performed with care. Going to Fourier, thresholding to zero and doing the inverse Fourier transform is by far not the best version, due to many potential artifacts. But there exist actual instances where iterative thresholding of large datasets is used, like in inverse computerized tomography.

• Does it make sense to treat the amplitude spectrum as a signal and apply a high pass filter? Commented Oct 9, 2023 at 13:50
• It depends on the purpose: just trying something, or having a goal in mind? So maybe yes: high-pass may be a step in a workflow for detecting sharp amplitude spectrum variations, that might be related to "something of interest". A difficult part may come from the lack of time localization in the magnitude Fourier domain Commented Oct 9, 2023 at 19:34
• Second thought: high-pass filtering alone might not be sufficient. Other hypotheses, and their modeling, could be used. Thinking of "spectral-like signals", we proposed PENDANTSS: PEnalized Norm-ratios Disentangling Additive Noise, Trend and Sparse Spikes to assess such issues. Not tested on Fourier spectra yet, though. Commented Oct 9, 2023 at 20:37
• For peak sharpening, and using a filter, maybe something like FILTFILT would not mess a lot with the frequency locations (never tried). For modelling, maybe an AR model could be applied and then play a bit with the peaks bandwidth by adjusting the poles (tried, and it works nicely). Commented Oct 13, 2023 at 0:24

I can tell you why I avoid such methods. When you pick some frequencies above threshold and remove others, you are using a kind of hard limit. In DSP this is same as Rectangular Windowing in frequency domain. It's effect in time domain will cause ringing. Because when you multiple in frequency domain with rectangular window, in time domain the signal gets convolved with a sinc function. There is a whole wikipedia page dedicated to this (Gibbs Phenomenon) - https://en.wikipedia.org/wiki/Gibbs_phenomenon

Again it depends on our requirements though. For example, if you see your filtered signal, the rise and fall time are not steep compared to original signal because you have eliminated higher frequencies which contribute to this. If my requirement was to apply a filter without compromising on fast rise time, I would not choose this method.