0
$\begingroup$

Say I have a 1D (spatial) signal (resolution = $1000$) which is zero everywhere except from $x = 250$ to $750$, where it equals one.

enter image description here

I ultimately want to calculate the spatial width of this signal using FFTs. Of course we know the width here to be $500$; in actuality, I am dealing with a signal that evolves with time and wish to calculate the average "pulse" width over all the time frames, so I do not know the widths. I have opted to use FFTs in this pursuit, so I must conduct a "sanity check" to make sure the method works. This method was suggested to me by a colleague whose intuition is many leagues farther than my own, so if someone could explain the intuition to me, I would appreciate it a lot.

  • Step 1: Subtract the DC background (subtract the mean from every point of the signal).

  • Step 2: Take the FFT of the signal, then the power (the Fourier transform times the complex conjugate of it). Normalize the power spectrum.

  • Step 3: Calculate the half-width at half-maximum (HWHM); here half-width is the half-width of the peak in k-space, of course.

  • Step 4: Convert this k-space HWHM back to real-space: real-space width = 1 / (HWHM / resolution).

enter image description here

When I do these steps for the signal above, I calculate a real-space width of $1189427$, laughably off from $500$. Where does the method go wrong?

$\endgroup$
  • $\begingroup$ Do you mean "range=0–1000" where you say "resolution=1000"? $\endgroup$ – Marcus Müller Jul 31 '16 at 7:18
  • $\begingroup$ Why are you using the DFT at all, is what A_A and I are wondering? $\endgroup$ – Marcus Müller Jul 31 '16 at 17:23
1
$\begingroup$

Say I have a 1D (spatial) signal (resolution = $1000$) which is zero everywhere except from $x=250$ to $750$, where it equals one.

This is not "resolution". Resolution is 300 Dots Per Inch. In which case, we could say that the total physical length of your pulse is $\frac{500}{300} \approx 1.666$ inches (or any other unit of length).

I ultimately want to calculate the spatial width of this signal using FFTs.

Why?

I am dealing with a signal that evolves with time and wish to calculate the average "pulse" width over all the time frames, so I do not know the widths.

If there will be multiple pulses of different widths on the same signal, then by opting to detect them with the FFT you are setting yourself a very big challenge because the FFT would return to you information about the signal as a whole. So you could, for example, derive an average rate of pulses (even using the algorithm that is presented here) but not the widths of individual pulses.

If it is somehow guaranteed that within a window of 1000 samples, there will be a pulse whose length is guaranteed to be staying well below 1000 samples and all we have to do now is detect where the pulse is and how long it is, then opting for the FFT is an overkill.

The usual way to detect pulse widths is via the simple use of a threshold and a counter. Once the signal's amplitude goes above the threshold, the counter starts counting and it stops once the signal's amplitude goes below the threshold. If you are going to operate in a noisy environment, then there are a number of improvements to that such as adding hysterisis to the threshold, so that it doesn't respond to very short "bounces" of the waveform and adaptive thresholding where the threshold limit would be derived from the given window of observation (here, from the 1000 samples).

If you absolutely have to work in the frequency domain, it might be better to look into the discrete wavelet transform (DWT), whose output is a time/scale(frequency) representation. But the actual detection of the pulse width is likely to be happening (again) using some form of threhsolding on the output of the DWT. (So, again, huge overkill).

$\endgroup$
  • $\begingroup$ ha! both our answers have the same central point: The DFT is a tool that can often be applied, sometimes even yielding relevant results (which is not the case here). $\endgroup$ – Marcus Müller Jul 31 '16 at 7:31
  • $\begingroup$ Very close in timing as well I would think. Looking forward to finding out if there was a particular reason for using the FFT. $\endgroup$ – A_A Jul 31 '16 at 17:15
0
$\begingroup$

Step 1 already solves your problem: If your only states are 0 and 1, and you get a mean of $0\le a\le 1$, then $a$ is the fraction of time your pulse was "on". You can very often reduce more complex problems to a threshholding problem that is exactly this one.

Step 2: Take the FFT of the signal, then the power (the Fourier transform times the complex conjugate of it).

Redundant; when calculating the Mean in the first step, you could have already summed up the sample sqaures and thus gotten the power; and Parsevals theorem states that power in time and frequency domain are equivalent.

Step 3: Calculate the half-width at half-maximum (HWHM); here half-width is the half-width of the peak in k-space, of course.

which is the same operation, but on a less "clearly" bounded waveform, as "counting" the width of your pulse in the original time signal.


so all in all, you're really not after spectral properties of your signal; I don't see how applying the DFT helps here.

If you want so, first consider the square wave, of which we know the spectrum very well. Now apply the theorem of time-scaling to the Fourier transform, and you'll get a function describing non-unit-periodic square waves. Multiply with a rectangular window (convolve with a sinc in frequency domain), and you'll see that no matter what you're doing, you're not making the original problem easier to distinguish; you'd still be down to counting the zero-passes or edges of the spectrum, and that's not easier or more accurate than doing that in the time domain.

What one could argue is that you inherently, and unknowingly, while simply claiming you'd get the "half-width half-maximum" "just by looking at it" built a specific filter. And in fact, as hinted at in the very beginning, that's your easiest solution:

A "mean value" will give you the percentage of time your signal was 1; also, an average is nothing but a long FIR with constant taps. So, yeah, build a very low-pass filter, and you shall be done.

You're not really telling us how your overall waveform looks like, but it's thoroughly possible the opposite of the low-pass approach would be a good thing, too: Just use a very high-pass filter to only see the rising/falling edge of your pulse, and simple count the length between these two.

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