0
$\begingroup$

I have a strongly aperiodic signal and I get weird artifacts after running a fft, using a low-pass filter, and then doing an inverse fft. I believe the artifacts are due to the way the signal is assumed to be periodic and "wrapped" at the ends. (Like I said, I'm a complete beginner here.)

I understand the usual way of handling aperiodic signals is via a window function, but applying a window function (say, Hamming) to my data looks like it squishes the data too much and like it would generate worse artifacts.

What sort of seems like it works is to

  1. surround the signal with silence, by prepending and appending a segment of 0s,

  2. doing the fft, applying the filter, etc., and then inverting the fft, then

  3. clipping off the silence segments off the beginning and end.

The result of step 1 looks like applying a rectangular window function to a longer signal, so I think that's ok, but...

  1. Is what I'm doing in any way reasonable?

  2. If so, what are the effects? And what is the best way to determine the length of the segments of 0s? (Currently, 10% of the original signal seems like it's not bad.)

  3. If not, is there another way to do this?

$\endgroup$
  • 1
    $\begingroup$ Why don't you apply a low-pass filter without doing an FFT and IFFT? $\endgroup$ – Matt L. Aug 5 '15 at 17:28
  • $\begingroup$ The specific details don't seem important but if they are, I am fooling with Matthew Jockers' Syuzhet package, which attempts to discover information about the large-scale plot of a book from sentiment data picked out of the text automatically. The whole idea is sketchy, but it seems like Jockers and everyone has given up entirely on the DFT, while I think it's really neat and would be good in other areas even if this particular application is incompletely baked. $\endgroup$ – Tommy McGuire Aug 5 '15 at 17:30
  • $\begingroup$ @Matt L., ultimately, I'm interested in the frequency domain data rather than the specific application. Plus, I don't know what I'm doing. $\endgroup$ – Tommy McGuire Aug 5 '15 at 17:33
  • 1
    $\begingroup$ I'm asking because if you try to implement a low-pass filter by simply zeroing the corresponding FFT bins, then the filter you get is quite bad. See this question and its answers. $\endgroup$ – Matt L. Aug 5 '15 at 17:36
  • 1
    $\begingroup$ A side comment: The DFT doesn't have issues with non-periodic signals. If you look closely at the relationship between the DFT and the DFS (series) you'll notice that the DFT is exactly one period of the DFS where the DFS takes your original, finite-length signal and periodically replicates it to create an infinite length periodic signal. People use symmetric windows to enforce continuity to reduce side-lobe effects in the spectrum, but mathematically it's not necessary. $\endgroup$ – curiousStudent Aug 5 '15 at 18:27
1
$\begingroup$

It sounds to me like you are experiencing time-domain aliasing. First, two basic facts:

  1. Recall that if $x[n]$ is of length $N$ and $h[n]$ is of length $M$ then $x[n]\ast h[n]$ is of length $N+M-1$.

Fact 1 does not matter in what domain you perform the convolution/filtering. So, if you modify the DFT of $x[n]$ by "shaping" its spectrum, then there exists an equivalent filter $h[n]$ in the time domain, which defines an implicit length $M$.

  1. Taking an $N_1$-point IDFT of an $N_2$-point signal for $N_1 < N_2$ results in time-aliasing.

Fact 2 is the dual to frequency aliasing by undersampling. I'll illustrate this as follows: let $x_1[n]$ denote a signal of size $N_1$. Then, if we take an $N_1$-point DFT of $x_1$ and modify its spectrum so the size should be $N_2>N_1$, then taking an $N_1$-point IDFT is equivalent to obtaining the signal $x_2$ given by: \begin{eqnarray} x_2[n] = \sum_{p=0}^{\infty}x[n+pN_1] \end{eqnarray}

This seems to be consistent with what you have mentioned. As you correctly noted, zero padding the original signal is exactly the solution! Essentially just zero-pad such that the terms in the above equation for $p>0$ are all zero-valued. Also, using the ideas above gives you a way to understand the exact amount of zero-padding necessary based on the implicit filter $h[n]$ your frequency domain shaping yields. Good luck!

$\endgroup$
  • $\begingroup$ I'd like to thank you and hotpaw2 (in the other answer) between your answers and trying to figure out what you were saying, I have learned a great deal. I think I understand now! Thanks! $\endgroup$ – Tommy McGuire Aug 7 '15 at 21:19
1
$\begingroup$

If you can determine the length of the impulse response of your filter (or a finite length above your desired noise floor), that's the amount of zeros you need to add as zero padding before your FFT-IFFT fast convolution filtering.

Note that an extremely sharp filter (similar to zeroing FFT bins) will have a longer and more "ripply" impulse response than one with a "softer" transition band.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.