Table Of Contents

Peak Detector (G Dataflow)

Last Modified: December 18, 2017

Finds the location, amplitude, and second derivative of peaks or valleys in the input signal.

connector_pane_image
datatype_icon

end of data?

A Boolean or an array of Booleans that determines whether to process only one block of data.

True Processes only one block of data.
False Processes consecutive blocks of data.

After processing the last block of data, this node manages internal data. If you only want to process one block of data, set this input to True. If you want to process consecutive blocks of data, set this input to False for all but the last block of data.

This input is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers

Default: True

datatype_icon

reset

A Boolean or an array of Booleans that determines whether to process only the first block of data.

True Processes only the first block of data, or resets the internal state of the node.
False Processes consecutive blocks of data, or keeps the internal state of the node.

When you wire a double-precision, floating-point number to signal, this input determines whether to reset the internal state of the node and restart the peak detection.

How to Set up reset at the Beginning of a Loop

When signal is a waveform, an array of waveforms, or an array of double-precision, floating-point numbers, this node requires some internal setup at the beginning for proper operation. If you only want to process one block of data, set this input to True. If you want to process consecutive blocks of data, set this input to True for the first block and False for all other blocks of data.

Default: True

datatype_icon

signal

The input signal.

This input accepts the following data types:

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

threshold

The threshold at which this node ignores peaks and valleys. This node ignores peaks if the fitted amplitude is less than this input. This node ignores valleys if the fitted trough is greater than this input.

This input accepts a double-precision, floating-point number or a 1D array of double-precision, floating-point numbers. This input accepts a 1D array of double-precision, floating-point numbers when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

Default: 0

datatype_icon

width

The number of consecutive data points to use in the quadratic least squares fit. This input is coerced to a value greater than or equal to 3.

This input accepts a 32-bit signed integer or a 1D array of 32-bit signed integers. This input accepts a 1D array of 32-bit signed integers when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

The value of width should be no more than about 1/2 of the half-width of the peaks or valleys and can be much smaller (but >2) for noise-free data.

How width Affects Detecting False Peaks

Large widths can reduce the apparent amplitude of peaks and shift the apparent location. For noisy data, this modification is unimportant since the noise obscures the actual peak. Ideally, the width should be as small as possible but must be balanced against the possibility of false peak detection due to noise.

Default: 3

datatype_icon

peaks/valleys

A value that determines whether the node looks for peaks or valleys in the input signal.

This input accepts an enum or a 1D array of enums. This input accepts a 1D array of enums when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

Name Description
Peaks

Looks for peaks in the input signal.

Valleys

Looks for valleys in the input signal.

Default: Peaks

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

dt

Sampling interval of the signal.

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

Default: 1

datatype_icon

location mode

Mode in which to retrieve peak and valley locations.

This input accepts a ring or a 1D array of rings. This input accepts a 1D array of rings when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

This input is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
Name Value Description
Index 0 Retrieves the peak or valley locations as array indexes.
Time 1 Retrieves the peak or valley locations as time in seconds.

Default: Index

datatype_icon

locations

Locations of peaks or valleys detected in terms of array index or time in seconds.

This output can return a 1D array of double-precision, floating-point numbers or a 1D array of clusters.

This output is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers

Algorithm for Calculating the Location by Time

This node calculates location by time according to the following equation:

Time = Index * dt

When the input signal is a waveform or a 1D array of waveforms, dt is contained in the input signal.

Why the Peaks Found May not be the Actual Points in the Input Data

Because the peak detection algorithm uses a quadratic fit to find the peaks, the algorithm interpolates between the data points. Therefore, the indexes are not integers. In other words, the peaks found may not be actual points in the input data but may be at fractions of an index and at amplitudes not found in the input array.

datatype_icon

detected?

A Boolean that indicates whether this node detected a peak or valley.

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

datatype_icon

amplitudes

The amplitudes of peaks or valleys found in the current block of data.

This output can return a 1D array of double-precision, floating-point numbers or a 1D array of clusters.

spd-note-note
Note  

The locations and amplitudes of peaks or valleys might deviate from actual peaks or valleys for noisy signals with large dynamic ranges.

This output is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

2nd derivatives

The measurements of the second derivative of the amplitude at each of the peaks or valleys found in the current block of data.

This output can return a 1D array of double-precision, floating-point numbers or a 1D array of clusters.

This output gives an approximate measure of the sharpness of each peak or valley. If this node detects peaks, these values are negative. If this node detects valleys, the values are positive.

spd-note-note
Note  

It is assumed that dt, the time difference between samples, is equal to 1.

This output is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

count

The number of peaks or valleys found in the current block of data.

This output can return a 32-bit signed integer or a 1D array of 32-bit signed integers.

This output is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
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 Calculating Peaks or Valleys

This node uses an algorithm that fits a quadratic polynomial to sequential groups of data points. The input width specifies the number of data points to use in the fit.

For each peak or valley, this node tests the quadratic fit against the input threshold. This node ignores peaks with heights lower than threshold or valleys with troughs higher than threshold. This node detects peaks and valleys only after processing approximately width/2 data points beyond the location of the peak or valley. This delay has implications only for real-time processing.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application


Recently Viewed Topics