Skip to main content

FFT

FFT [flags] srcWave

The FFT operation computes the Discrete Fourier Transform of srcWave using a multidimensional prime factor decomposition algorithm. By default, srcWave is overwritten by the transform.

Output Wave Name

For compatibility with earlier versions of Igor, if you use FFT with no flags or with just the /Z flag, the operation overwrites srcWave.

If you use any flag other than /Z, FFT uses default output wave names: W_FFT for a 1D FFT and M_FFT for a multidimensional FFT.

We recommend that you use the /DEST flag to make the output wave explicit and to prevent overwriting srcWave.

Flags

/COLSComputes the 1D FFT of 2D srcWave one column at a time, storing the results in the destination wave
I[t1][n]=k=0N1f[t1][k]exp(i2πkn/N).\displaystyle I\left[t_{1}\right][n]=\sum_{k=0}^{N-1} f\left[t_{1}\right][k] \exp (i 2 \pi k n / N) .
You must specify a destination wave using the /DEST flag. No other flags are allowed with this flag. The number of rows must be even. If srcWave is a real (NxM) wave, the output matrix will be (1+N/2,M) in analogy with 1D FFT. To avoid changes in the number of points you can convert srcWave to complex data type. This flag applies only to 2D source waves. See also the /ROWS flag.
/DEST=destWave
Specifies the output wave created by the FFT operation.
It is an error to specify the same wave as both srcWave and destWave.
When used in a function, the FFT operation by default creates a complex wave reference for the destination wave. See Automatic Creation of Wave References for details.
/FREECreates destWave as a free wave.
/FREE is allowed only in functions and only if destWave, as specified by /DEST, is a simple name or wave reference structure field.
See Free Waves for more discussion.
The /FREE flag was added in Igor Pro 7.00.
/HCCHypercomplex transform (cosine). Computes the integral
Ic(ω1,ω2)=f(t1,t2)cos(t1ω1)exp(it2ω2)dt1dt2\displaystyle I_{c}\left(\omega_{1}, \omega_{2}\right)=\iint_{-\infty}^{\infty} f\left(t_{1}, t_{2}\right) \cos \left(t_{1} \omega_{1}\right) \exp \left(i t_{2} \omega_{2}\right) d t_{1} d t_{2}
using the 2D FFT (see Details).
/HCSHypercomplex transform (sine). Computes the integral
Is(ω1,ω2)=f(t1,t2)sin(t1ω1)exp(it2ω2)dt1dt2\displaystyle I_{s}\left(\omega_{1}, \omega_{2}\right)=\iint_{-\infty}^{\infty} f\left(t_{1}, t_{2}\right) \sin \left(t_{1} \omega_{1}\right) \exp \left(i t_{2} \omega_{2}\right) d t_{1} d t_{2}
using the 2D FFT (see Details).
/MAGSaves just the magnitude of the FFT in the output wave. See comments under /OUT.
/MAGSSaves the squared magnitude of the FFT in the output wave. See comments under /OUT.
/OUT=mode
mode =1:Default for complex output.
mode =2:Real output.
mode =3:Magnitude.
mode =4:Magnitude square.
mode =5:Phase.
mode =6:Scaled magnitude.
mode =7:Scaled magnitude squared.
You can also identify modes 2-4 using the convenience flags /REAL, /MAG, and /MAGS. The convenience flags are mutually exclusive and are overridden by the /OUT flag.
The scaled quantities apply to transforms of real valued inputs where the output is normally folded in the first dimension (because of symmetry). The scaling applies a factor of 2 to the squared magnitude of all components except the DC. The scaled transforms should be used whenever Parseval's relation is expected to hold.
/PAD={dim1 [, dim2, dim3, dim4 ]}
Converts srcWave into a padded wave of dimensions dim1, dim2.... The padded wave contains the original data at the start of the dimension and adds zero entries to each dimension up to the specified dimension size. The dim1... values must be greater than or equal to the corresponding dimension size of srcWave. If you need to pad just the lowest dimension(s) you can omit the remaining dimensions; for example, /PAD=dim1 will set dim2 and above to match the dimensions in srcWave.
/REALSaves just the real part of the transform in the output wave. See comments under /OUT.
/ROWSCalculates the FFT of only the first dimension of a 2D srcWave. It thus computes the 1D FFT of one row at a time, storing the results in the destination wave.
N[n][t2]=k=0M1f[k][t2]exp(i2πkn/M)N[n]\left[t_{2}\right]=\displaystyle \sum_{k=0}^{M-1} f[k]\left[t_{2}\right] \exp (i 2 \pi k n / M)
You must specify a destination wave using the /DEST flag. No other flags are allowed with this flag. The number of columns must be even. If srcWave is a real (NxM) wave, the output matrix will be (N,1+M/2) in analogy with 1D FFT. To avoid changes in the number of points you can convert srcWave to complex data type. See also /COLS flag.
/RP=[startPoint,endPoint ]
/RX=(startX,endX )
Defines a segment of a 1D srcWave that will be transformed. By default the operation transforms the whole wave. It is sometimes useful to take advantage of this feature in order to transform just the defined interval, which includes both end points. You can define the interval using wave point indexing with the /RP flag or using the X-values with the /RX flag. The interval must include at least four data points and the total number of points must be an even number.
/WINF=windowKind
Premultiplies a 1D srcWave with the selected window function.
If you include the /PAD flag, the window function is applied to the pre-padded data.
See Window Functions below for details.
/ZDisables rotation of the FFT of a complex wave. Igor normally rotates the FFT result (which is also complex) by N/2 so that x=0 is at the center point (N/2). When /Z is specified, Igor does not perform this rotation and leaves x=0 at the first point (0).

Details

The data type of srcWave is arbitrary. The first dimension of srcWave must be an even number and the minimum length of srcWave is four points. When srcWave is a double precision wave, the FFT is computed in double precision. All other data types are transformed using single precision calculations. The result of the FFT operation is always a floating point number (single or double precision).

Depending on your choice of outputs, you may not be able to invert the transform in order to obtain the original srcWave.

srcWave or any of its intervals must have at least four data points and must not contain NaNs or INFs.

The FFT algorithm is based on prime number decomposition, which decomposes the number of points in each dimension of the wave into a product of prime numbers. The FFT is optimized for primes < 5. In time consuming applications it is frequently worthwhile to pad the data so that the total number of points factors into small prime numbers.

The hypercomplex transforms are computed by writing the sine and cosine as a sum of two exponentials. Let the 2D Fourier transform of the input signal be

F[n1][n2]=k1=0N11k2=0N21f[k1][k2]exp(i2πk1n1N1)exp(i2πk2n2N2)\displaystyle F\left[n_{1}\right]\left[n_{2}\right]=\sum_{k_{1}=0}^{N_{1}-1} \sum_{k_{2}=0}^{N_{2}-1} f\left[k_{1}\right]\left[k_{2}\right] \exp \left(i 2 \pi k_{1} \frac{n_{1}}{N_{1}}\right) \exp \left(i 2 \pi k_{2} \frac{n_{2}}{N_{2}}\right)

then the two hypercomplex transforms are given by

Ic[n1][n2]=12(F[n1][n2]+F[n1][n2])\displaystyle I_{c}\left[n_{1}\right]\left[n_{2}\right]=\frac{1}{2}\left(F\left[n_{1}\right][n 2]+F\left[-n_{1}\right][n 2]\right)

and

Is[n1][n2]=12i(F[n1][n2]F[n1][n2])\displaystyle I_{s}\left[n_{1}\right]\left[n_{2}\right]=\frac{1}{2 i}\left(F\left[n_{1}\right][n 2]-F\left[-n_{1}\right][n 2]\right)

Window Functions

The /F=windowKind flag premultiplies a 1D scrWave with the selected window function.

In the following window definitions, wn(n) is the value of the window function that multiplies the signal, N is the number of points in the signal wave (or range if /R is specified), and n is the wave point index. With /R, n=0 for the first datum in the range.

Choices for windowKind are in bold.

Bartlet

A synonym for Bartlett.

Bartlett

w(n)={2nNn=0,1,N222nNn=N2,N1w(n)=\left\{\begin{array}{cc} \displaystyle \frac{2 n}{N} & n=0,1, \ldots \frac{N}{2} \\ \\ \displaystyle 2-\frac{2 n}{N} & n=\frac{N}{2}, \ldots N-1 \end{array}\right.

Blackman367, Blackman361, Blackman492, Blackman474

w(n)=a0a1cos(2πNn)+a2cos(2πN2n)a3cos(2πN3n)n=0,1,2N1.\begin{array}{l} \displaystyle w(n)=a_{0}-a_{1} \cos \left(\frac{2 \pi}{N} n\right)+a_{2} \cos \left(\frac{2 \pi}{N} 2 n\right)-a_{3} \cos \left(\frac{2 \pi}{N} 3 n\right) \\ \\ \displaystyle n=0,1,2 \ldots N-1. \end{array}
windowKinda0a1a2a3
Blackman3670.426590710.496560620.076848670
Blackman3610.449590.493640.056770
Blackman4920.358750.488290.141280.01168
Blackman4740.402170.497030.093920.00183

Cos1, Cos2, Cos3, Cos4

w(n)=cos(nNπ)α,n=N2,,1,0,1,,N2.\begin{array}{l} \displaystyle w(n)=\cos \left(\frac{n}{N} \pi\right)^{\alpha}, \\ \\ \displaystyle n=-\frac{N}{2}, \ldots,-1,0,1, \ldots, \frac{N}{2} . \end{array}

Cos1: α =1; Cos2: α =2; Cos3: α =3; Cos4: α =4

Hamming

w(n)={0.54+0.46cos(2πnN)n=N2,,1,0,1,,N20.540.46cos(2πnN)n=0,1,2,,N1w(n)=\left\{\begin{array}{ll} \displaystyle 0.54+0.46 \cos \left(\frac{2 \pi n}{N}\right) & n=-\frac{N}{2}, \ldots,-1,0,1, \ldots, \frac{N}{2} \\ \\ \displaystyle 0.54-0.46 \cos \left(\frac{2 \pi n}{N}\right) & n=0,1,2, \ldots, N-1 \end{array}\right.

Hanning

w(n)={12[1+cos(2πnN)]n=N2,,1,0,1,,N212[1cos(2πnN)]n=0,1,2,,N1w(n)=\left\{\begin{array}{ll} \displaystyle \frac{1}{2}\left[1+\cos \left(\frac{2 \pi n}{N}\right)\right] & n=-\frac{N}{2}, \ldots,-1,0,1, \ldots, \frac{N}{2} \\ \\ \displaystyle \frac{1}{2}\left[1-\cos \left(\frac{2 \pi n}{N}\right)\right] & n=0,1,2, \ldots, N-1 \end{array}\right.

KaiserBessel20, KaiserBessel25, KaiserBessel30

w(n)=I0(πα1(2nN)2)I0(πα)0nN2.w(n)=\frac{\displaystyle I_{0}\left(\pi \alpha \sqrt{1-\left(\frac{2 n}{N}\right)^{2}}\right)}{I_{0}(\pi \alpha)} \quad 0 \leq|n| \leq \frac{N}{2} .

where I0 is the zero-order modified Bessel function of the first kind.

KaiserBessel20: α =2.0; KaiserBessel25: α =2.5; KaiserBessel30: α =3.0

Parzen

w(n)=12nN20nN2.\displaystyle w(n)=1-\left|\frac{2 n}{N}\right|^{2} \quad 0 \leq|n| \leq \frac{N}{2} .

Poisson2, Poisson3, Poisson4

w(n)=exp(α2nN)0nN2.\displaystyle w(n)=\exp \left(-\alpha \frac{2|n|}{N}\right) \quad 0 \leq|n| \leq \frac{N}{2} .

Poisson2: α =2; Poisson3: α =3; Poisson4: α =4

Riemann

w(n)=sin(2πnN)(2πnN)0nN2.w(n)=\frac{\displaystyle \sin \left(\frac{2 \pi n}{N}\right)}{\left(\frac{\displaystyle 2 \pi n}{N}\right)} \quad 0 \leq|n| \leq \frac{N}{2} .

Flat-Top

The flat-top windows are defined as a sum of cosine terms:

w(n)=k=0mckcos(kz),\displaystyle w(n)=\sum_{k=0}^{m} c_{k} \cos (k z), z=2πjN,j=0,1,N1.\displaystyle z=\frac{2 \pi j}{N}, \quad j=0,1, \ldots N-1 .

Here are the supported flat-top window keywords for use as windowKind with the /WINF flag. These keywords require Igor Pro 8.00 or later:

windowKindCosine Terms
SFT3Fc0=0.26526, c1=-0.5, c2=0.23474.
SFT3Mc0=0.28235, c1=-0.52105, c2=0.19659.
FTNIc0=0.2810639, c1=-0.5208972, c2=0.1980399.
SFT4Fc0=0.21706, c1=-0.42103, c2=0.28294, c3=-0.07897.
SFT5Fc0=0.1881, c1=-0.36923, c2=0.28702, c3=-0.13077, c4=0.02488.
SFT4Mc0=0.241906, c1=-0.460841, c2=0.255381, c3=-0.041872.
FTHPc0=1.0, c1=-1.912510941, c2=1.079173272, c3=-0.1832630879.
HFT70c0=1.0, c1=-1.90796, c2=1.07349, c3=-0.18199.
FTSRSc0=1.0, c1=-1.93, c2=1.29, c3=-0.388, c4=0.028.
SFT5Mc0=0.209671, c1=-0.407331, c2=0.281225, c3=-0.092669, c4=0.0091036.
HFT90Dc0=1.0, c1=-1.942604, c2=1.340318, c3=-0.440811, c4=0.043097.
HFT95c0=1.0, c1=-1.9383379, c2=1.3045202, c3=-0.4028270, c4=0.0350665.
HFT116Dc0=1.0, c1=-1.9575375, c2=1.4780705, c3=-0.6367431, c4=0.1228389, c5=-0.0066288.
HFT144Dc0=1.0, c1=-1.96760033, c2=1.57983607, c3=-0.81123644, c4=0.22583558, c5=-0.02773848, c6=0.00090360.
HFT169Dc0=1.0, c1=-1.97441842, c2=1.65409888, c3=-0.95788186, c4=0.33673420, c5=-0.06364621, c6=0.00521942, c7=-0.00010599.
HFT196Dc0=1.0, c1=-1.979280420, c2=1.710288951, c3=-1.081629853, c4=0.448734314, c5=-0.112376628, c6=0.015122992, c7=-0.000871252, c8=0.000011896.
HFT223Dc0=1.0, c1=-1.98298997309, c2=1.75556083063, c3=-1.19037717712, c4=0.56155440797, c5=-0.17296769663, c6=0.03233247087, c7=-0.00324954578, c8=0.00013801040, c9=-0.0000013275.
HFT248Dc0=1.0, c1=-1.985844164102, c2=1.791176438506, c3=-1.282075284005, c4=0.667777530266, c5=-0.240160796576, c6=0.056656381764, c7=-0.008134974479, c8=0.000624544650, c9=-0.000019808998, c10=0.000000132974.

References

For more information about the use of window functions see:

Harris, F.J., "On the use of windows for harmonic analysis with the discrete Fourier Transform", Proc, IEEE, 66, 51-83, 1978.

Heinzel, G., Rüdiger, A., & Schilling, R. (2002). "Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new at-top windows", http://hdl.handle.net/11858/00-001M-0000-0013-557A-5.

See Also

Fourier Transforms for an example that compares the FFT result with the continuous Fourier transform values.

IFFT, DWT, CWT, STFT, HilbertTransform, WignerTransform, DSPPeriodogram, LombPeriodogram, Unwrap, MatrixOp

Demos

Open FFTSwappingDemo.pxp

Open PSD Demo