Skip to content

← signal_processing package

DetectLineNoise

Detects the line noise (mains) frequency of raw signal data, as a float.

Sets a stream property named mains_frequency to this value, and outputs the value through a port by the same name. Outputs a second port with a list of four values that include the falloff range and peak width of the mains frequency, which can, be wired into to a bandpass filter node (i.e., IIR Filter or FIR Filter), to remove line noise with a notch filter. Important: If using this node on streaming data, you must use the AccumulateCalibrationData node, or another buffering node, upstream create a buffer of several seconds of data from which to detect the line noise. Version 1.1.2

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
Packet (can be None)
data direction
INOUT

bandpass_list

Creates a list of values to be passed into a bandpass filter node, including peak width and falloff range values.

verbose name
Bandpass List
default value
None
port type
DataPort
value type
list (can be None)
data direction
OUT

mains_frequency

The frequency of the detected line noise, as a float.

verbose name
Mains Frequency
default value
None
port type
DataPort
value type
float (can be None)
data direction
OUT

verbose

Set to false to suppress warnings that rereferencing was not performed (no reference data, data is wrong shape, etc.) .

verbose name
Verbose
default value
True
port type
BoolPort
value type
bool (can be None)

window

Type of window function to apply to sub-windows. Different functions have different spectral and temporal localization characteristics. One of the simplest well-behaved windows is the Hann window (the default).

verbose name
Window Function For Sub-Windows
default value
hann
port type
EnumPort
value type
str (can be None)

detrend

Sub-window detrending method. In the Welch method, linear trends or constant offsets can be removed from each window prior to spectral estimation.

verbose name
Sub-Window Detrending
default value
off
port type
EnumPort
value type
str (can be None)

segment_samples

Length of the sub-windows for spectral estimation. This may have to be adjusted for data with high (multi-kilohertz) sampling rates. This node will extract successive windows from the given data of this length, which are overlapped according to the overlap samples parameter. Longer windows will give a higher-resolution spectrum, but at the same time the result will increase the smoothness (i.e., blurriness) along the time axis. The tradeoff between time resolution and frequency resolution that can be adjusted via this parameter is fundamental.

verbose name
Sub-Window Length (Samples)
default value
256
port type
FloatPort
value type
float (can be None)

fft_size

Length of the FFT used, in samples. Using a higher number will yield a finer stepping along the frequency axis, without a change in frequency or temporal detail (the frequency axis will be correspondingly more smooth to counter the finer stepping). If not given, it defaults to the sub-window length.

verbose name
Fft Size
default value
None
port type
IntPort
value type
int (can be None)

scaling

Scaling of the spectrum. In density mode, the result is divided by the frequency; this yields the power-spectral density, and is the default. However, this will incur a falloff towards higher frequencies which may be addressed separately using the frequency normalization node.

verbose name
Spectral Scaling Mode
default value
density
port type
EnumPort
value type
str (can be None)

fit_frequency_range

Fit the spectra between these frequency ranges to calculate alpha value. Default: all frequencies.

verbose name
Fit Frequency Range
default value
None
port type
ListPort
value type
list (can be None)

alpha

The exponent of 1/f^alpha used in the correction. Set to None to determine the value automatically.

verbose name
Alpha
default value
1.0
port type
FloatPort
value type
float (can be None)

frequency_band

Provide a plus-minus value to find the main frequency for a range around 50 Hz or 60 Hz. Default value of 0 calculates the PSD value specifically at 50 Hz or 60 Hz.

verbose name
Frequency Band
default value
0
port type
IntPort
value type
int (can be None)

left_falloff_range

Used for output when connecting to a FIR Filter or IIR Filter node. Specifies the falloff range to the left of the notch.

verbose name
Left Falloff Range
default value
0
port type
FloatPort
value type
float (can be None)

right_falloff_range

Used for output when connecting to a FIR Filter or IIR Filter node. Specifies the falloff range to the right of the notch.

verbose name
Right Falloff Range
default value
0
port type
FloatPort
value type
float (can be None)

peak_width

Used for output when connecting to a FIR Filter or IIR Filter node. Specifies the width on either side of the peak to be removed by a bandpass filter.

verbose name
Peak Width
default value
0
port type
FloatPort
value type
float (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)