Coherence¶
Calculate the magnitude-spared spectral coherence between any channel and all others.
For multi-channel time series, this is a measure of the coupling strength or synchrony between the individual channels. To yield a low-noise and smooth estimate, the Welch method is used, which computes the coherence in multiple successive (and usually overlapping) sub-windows within the moving window and averages the results. The frequency resolution can be increased by using longer (and therefore fewer) windows, but this comes with a cost of increased noise. The most common use case for either node is to apply it to segmented data ( i.e., following the Segmentation node), which will compute the coherence for each segment of the data. Another use case is to apply it in an offline fashion on an entire recording ( which yields the average spectral coherence of that recording). It is not useful to apply this node on streaming data without any buffering or segmentation, because this would try to estimate the coherence on the very short chunks of data without any averaging across chunks, yielding bad data. There is a node that was specifically made for this task, called Moving window coherence, and this will yield much better results in this scenario. At a technical level, this node will replace the time axis of the data by a frequency axis (since time is averaged out), but it will add a dummy time axis with one entry that is annotated with the average time value of the former time axis ( this is so that that information is not lost). It will also add a second space axis with the same number of channels, since coherence is calculated between all pairs of channels. If you need to remove the dummy time axis, e.g., because some subsequent node cannot handle multiple axes in the data, you can use the Fold Into Axis node to fold it into some other axis, e.g., space. You can also flatten the two space axes into a single longer space axis, simply by setting the flat space axis parameter. More Info... Version 1.0.0
Ports/Properties¶
data¶
Data to process.
- verbose name: Data
- default value: None
- port type: DataPort
- value type: Packet (can be None)
- data direction: INOUT
segment_samples¶
Sub-window length for averaging. 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 spectral resolution (but potentially less smooth and more noisy).
- verbose name: Sub-Window Length (Samples)
- default value: 256
- port type: IntPort
- value type: int (can be None)
overlap_samples¶
Number of samples of overlap between successive sub-windows. This determines by how much successive sub-windows are overlapped. If not given, defaults to half of the sub-window length. Can also be given as a value between 0 and 1, which is then taken as a fraction of the sub-window length (e.g., 0.8).
- verbose name: Overlap Between Sub-Windows
- default value: None
- port type: FloatPort
- value type: float (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 smooth 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: constant
- port type: EnumPort
- value type: str (can be None)
onesided¶
Return one-sided spectrum. If disabled, a two-sided (meaning: symmetric about the middle) spectrum will be computed, which is redundant for real-valeud data, but required for complex-valued data (for complex data, the spectrum is always two-sided.
- verbose name: Onesided Spectrum For Real-Valued Data
- default value: True
- port type: BoolPort
- value type: bool (can be None)
fft_size¶
Length of the FFT used. Using a higher number will yield a finer stepping along the frequency axis, without a change in frequency 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)
flat_space_axis¶
Flatten the two space axes into one. If checked, only one space axis with N squared channels will be returned. If False (the default), an array with two space axes is returned.
- verbose name: Flat Space Axis
- default value: False
- port type: BoolPort
- value type: bool (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)