Table Of Contents

STFT Spectrogram (G Dataflow)

Version:
    Last Modified: March 15, 2017

    Computes the signal energy distribution in the joint time-frequency domain by using the short-time Fourier transform (STFT) algorithm.

    connector_pane_image
    datatype_icon

    time-frequency configuration

    Configuration of the FFT size of the STFT. This input determines the number of columns in the output STFT spectrogram.

    This input is available only if you wire a waveform or a 1D array of double-precision, floating-point numbers to x.

    datatype_icon

    force freq bins to power of 2?

    A Boolean that determines whether to coerce the frequency bins to a power of 2. If this input is True and the frequency bins is not a power of 2, this node sets the frequency bins to the nearest power of 2.

    True Coerces the frequency bins to a power of 2.
    False Does not coerce the frequency bins to a power of 2.

    Default: True

    datatype_icon

    exclude Nyquist frequency?

    A Boolean that determines whether to exclude the energy at the Nyquist frequency from the output STFT.

    True If the FFT size of the STFT is even and this input is True, the output STFT does not include the energy at the Nyquist frequency.
    False Includes the energy at the Nyquist frequency.

    If the FFT size of the STFT is odd, this node ignores this input.

    Default: True

    datatype_icon

    reset

    A Boolean that specifies whether to reset the internal state of the node.

    True Resets the internal state of the node.
    False Does not reset the internal state of the node.

    This input is available only if you wire a double-precision, floating-point number to x.

    Default: False

    datatype_icon

    x

    Input time-domain signal.

    This input accepts the following data types:

    • Waveform
    • Double-precision, floating-point number
    • 1D array of double-precision, floating-point numbers
    datatype_icon

    time-frequency sampling information

    The density to use to sample the signal in the joint time-frequency domain and to define the size of the resulting 2D time-frequency array.

    This input changes to time steps if you wire a double-precision, floating-point number to x.

    datatype_icon

    time steps

    Number of samples to shift the sliding window. When this input is less than or equal to zero, this node adjusts this input automatically so that no more than 512 rows exist in output STFT.

    Performance Considerations

    If you specify a small value for time steps, the node might return a large spectrogram, which requires a long computation time and more memory. NI recommends you set time steps so that the number of rows in STFT spectrogram does not exceed 512. If you need a small sampling rate to observe more details and the signal length is large, divide the signal into smaller segments and compute the spectrogram for each segment.

    Default: -1

    datatype_icon

    frequency bins

    FFT size of the STFT. If this input is less than or equal to zero, this node sets the input to 512. If this input is 1, this node coerces the input to 2.

    Default: 512

    datatype_icon

    time steps

    Number of samples to shift the sliding window. time steps must be greater than 0.

    This input changes to time-frequency sampling information if you wire a waveform or a 1D array of double-precision, floating-point numbers to x.

    Performance Considerations

    Increasing time steps decreases the computation time and reduces memory requirements but also reduces time-domain resolution. Decreasing time steps improves time-domain resolution but increases the computation time and memory requirements.

    Default: 1

    datatype_icon

    window information

    Information about the window to use to compute the STFT.

    datatype_icon

    type

    Type of window to use to compute the STFT.

    Name Value Description
    Rectangle 0 Applies a rectangle window.
    Hanning 1 Applies a Hanning window.
    Hamming 2 Applies a Hamming window.
    Blackman-Harris 3 Applies a Blackman-Harris window.
    Exact Blackman 4 Applies an Exact Blackman window.
    Blackman 5 Applies a Blackman window.
    Flat Top 6 Applies a Flat Top window.
    4 Term B-Harris 7 Applies a 4 Term B-Harris window.
    7 Term B-Harris 8 Applies a 7 Term B-Harris window.
    Low Sidelobe 9 Applies a Low Sidelobe window.
    Blackman Nuttall 11 Applies a Blackman Nutall window.
    Triangle 30 Applies a Triangle window.
    Bartlett-Hanning 31 Applies a Bartlett-Hanning window.
    Bohman 32 Applies a Bohman window.
    Parzen 33 Applies a Parzen window.
    Welch 34 Applies a Welch window.
    Kaiser 60 Applies a Kaiser window.
    Dolph-Chebyshev 61 Applies a Dolph-Chebyshev window.
    Gaussian 62 Applies a Gaussian window.
    Force 64 Applies a Force window.
    Exponential 65 Applies an Exponential window.

    Default: Hanning

    datatype_icon

    length

    Length of the window in samples. When you wire a waveform or a 1D array of double-precision, floating-point numbers to x, this node sets the input to 64 if length is less than or equal to zero. When you wire a double-precision, floating-point number to x, length must be greater than 0 and less than or equal to the sample length.

    Default: 64

    datatype_icon

    sample length

    Length of each set of data. The node performs computation for each set of data.

    sample length must be greater than zero.

    This input is available only if you wire a double-precision, floating-point number to x.

    Default: 100

    datatype_icon

    error in

    Error conditions that occur before this node runs.

    The node responds to this input according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

    Default: No error

    datatype_icon

    window parameter

    A value that affects the output coefficients when window type is Kaiser, Gaussian, or Dolph-Chebyshev.

    If window type is any other type of window, this node ignores this input.

    This input represents the following information for each type of window:

    • Kaiser—Beta parameter
    • Gaussian—Standard deviation
    • Dolph-Chebyshev—The ratio, s, of the main lobe to the side lobe

    This input is available only if you wire a waveform or a 1D array of double-precision, floating-point numbers to x.

    Default: NaN—Causes this node to set beta to 0 for a Kaiser window, the standard deviation to 0.2 for a Gaussian window, and s to 60 for a Dolph-Chebyshev window

    datatype_icon

    energy conservation?

    A Boolean that determines whether to scale the STFT spectrogram so that the energy in the joint time-frequency domain equals the energy in the time domain.

    True Scales the STFT spectrogram so that the energy in the joint time-frequency domain equals the energy in the time domain.
    False Does not scale the STFT spectrogram so that the energy in the joint time-frequency domain equals the energy in the time domain.

    Default: True

    datatype_icon

    STFT spectrogram

    A 2D array that describes the time waveform energy distribution in the joint time-frequency domain.

    datatype_icon

    error out

    Error information.

    The node produces this output according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

    Algorithm for Computing the STFT Spectrogram

    To compute the output STFT Spectrogram, this node completes the following process.

    1. Computes the STFT of the input signal x by using a sliding window to divide the signal into several blocks of data.
    2. Applies an N-points fast Fourier transform (FFT) to each block of data to obtain the frequency contents of each block of data, where N is the input frequency bins.
    3. The STFT aligns the center of the first sliding window with the first sample of x and extends the beginning of the signal by adding zeros.
    4. The sliding window moves time steps samples to the next block of data. If the window moves out of x, this node pads x with zeros.

    The following figure shows the procedure this node uses to compute the STFT.

    Algorithm for Calculating the STFT Spectrograms

    If the input force freq bins to power of 2? is True and the input frequency bins is not a power of 2, then the following equation holds true:

    K = 2 [ log 2 ( frequency bins ) ]

    where [   ] is the nearest operation.

    Otherwise, K is equal to frequency bins.

    If the result of the STFT is the matrix STFT { X } , then the size of STFT { X } is M-by-K, where the following are true:

    • M = { L time steps + 1  if  L  is even L 1 time steps + 1  if  L  is odd
    • L is the number of elements in x
    • [   ] is the round down operation

    You can use the STFT { X } to approximate the energy in the joint time-frequency domain using the following expression:

    time steps * i 0 M 1 j 0 K 1 STFT { X } i j

    This result almost equals the energy in the time domain, as shown in the following expression:

    i 0 L 1 | X ( i ) | 2

    After computing the STFT of X, this node computes the STFT spectrogram of X. This node calculates the STFT spectrogram as the magnitude square of the elements in STFT { X } . Because the FFT returns symmetric results, this node calculates the STFT spectrogram only on the left half of STFT { X } , as shown in the following equation:

    STFT spectrogram i , j = { | STFT { X } i , j | 2  if energy conservation? is False  1 K | STFT { X } i , j | 2  if energy conservation? is True

    where the following are true:

    • i = 0 , 1 , , M 1
    • j = 0 , 1 , , N 1
    • N = { K 1 2 + 1 K is odd K 1 2 + 1 K is even and exclude Nyquist frequency? is False K 1 2 K is even and exclude Nyquist frequency? is True
    •   is the round up operation

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics