Class WaveformLength

Computes the Waveform Length (WL) feature for each channel in a windowed input signal.

JSON configuration

Use these block entries inside a pipeline configuration. Input names must match other blocks in that pipeline; device addresses and file paths must match your setup.

JSON configuration:

{
  "WL": {
    "Type": "WaveformLength",
    "Inputs": [ "SlidingWindow1" ],
    "DesiredRate": 100,
    "Path": "C:/Data/session1"
  }
}

Params: None.

How Type, Inputs and Params work · Block catalogue and parameter reference

Inheritance
WaveformLength
Inherited Members
Namespace: MOSAIC.Models.FlowControl
Assembly: MOSAIC.dll
Syntax
public class WaveformLength : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks

Formula: WL = Σ|x[n] − x[n−1]| for n = 1 to N−1, where N is the window size.

Input: A MathNet.Numerics.LinearAlgebra.Matrix<T> of double where rows represent samples and columns represent channels (typically from an upstream SlidingWindow block).

Output: A MathNet.Numerics.LinearAlgebra.Vector<T> of double containing one WL value per channel, published to all downstream subscribers.

Waveform Length is a cumulative measure of signal complexity — it captures both amplitude and frequency information by summing consecutive sample-to-sample differences.

CSV logging: When a Path is specified, Dumper automatically logs the output vector via Publish(object).

Constructors

WaveformLength(string, double)

Initializes a new WaveformLength block.

Declaration
public WaveformLength(string name, double desiredRate = 0)
Parameters
Type Name Description
string name

Display name of the block.

double desiredRate

Desired processing rate in Hz (typically inherited).

Fields

_outputChannels

Gets the number of output channels, determined from the column count of the input matrix.

Declaration
[ObservableProperty]
private int _outputChannels
Field Value
Type Description
int

_windowSize

Gets the window size (row count) from the most recent input matrix.

Declaration
[ObservableProperty]
private int _windowSize
Field Value
Type Description
int

Properties

DumpFilePrefix

Recordings from this block are named <block>_wl.csv.

Declaration
protected override string DumpFilePrefix { get; }
Property Value
Type Description
string
Overrides
BaseBlock.DumpFilePrefix

JsonTypeName

Block type identifier for JSON serialization. Override for a custom name.

Declaration
protected override string JsonTypeName { get; }
Property Value
Type Description
string
Overrides
BaseBlock.JsonTypeName

OutputChannels

Gets the number of output channels, determined from the column count of the input matrix.

Declaration
[ExcludeFromCodeCoverage]
public int OutputChannels { get; set; }
Property Value
Type Description
int

Visualization

This block's visualization, or null when it has none.

Declaration
protected override BlockVisualization? Visualization { get; }
Property Value
Type Description
BlockVisualization
Overrides
BaseBlock.Visualization
Remarks

Blocks own their scope as a public Viz property rather than inheriting one, so the base class has no way to reach it. Overriding this is what lets the rate below be wired up automatically. With correct publication metadata, the bundle derives the time axis for one vector per publication or fixed-size contiguous sample packets from the feed shape.

When a plot needs a rate that publication frequency and feed shape cannot express (for example, variable-sized packets or overlapping windows), declare it with Viz.UpdateSignalRate. An explicit declaration wins over the derived rate. A block with several bundles must configure each one; this hook exposes only one bundle.

Viz

Visualization helper for binding the WL output to the UI scope.

Declaration
public BlockVisualization? Viz { get; }
Property Value
Type Description
BlockVisualization

WindowSize

Gets the window size (row count) from the most recent input matrix.

Declaration
[ExcludeFromCodeCoverage]
public int WindowSize { get; set; }
Property Value
Type Description
int

Methods

ConfigureInput(IServiceProvider, JsonModel)

Creates a WaveformLength from a JSON pipeline definition.

Declaration
public static WaveformLength ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
Type Name Description
IServiceProvider sp

Service provider for dependency injection.

JsonModel m

JSON model containing configuration.

Returns
Type Description
WaveformLength

A configured WaveformLength instance.

Dispose()

Releases visualization and base class resources (including CSV dumper if configured).

Declaration
public override void Dispose()
Overrides
BaseBlock.Dispose()

OnOutputChannelsChanged(int)

Executes the logic for when OutputChannels just changed.

Declaration
private void OnOutputChannelsChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of OutputChannels is changed.

OnOutputChannelsChanged(int, int)

Executes the logic for when OutputChannels just changed.

Declaration
private void OnOutputChannelsChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of OutputChannels is changed.

OnOutputChannelsChanging(int)

Executes the logic for when OutputChannels is changing.

Declaration
private void OnOutputChannelsChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of OutputChannels is changed.

OnOutputChannelsChanging(int, int)

Executes the logic for when OutputChannels is changing.

Declaration
private void OnOutputChannelsChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of OutputChannels is changed.

OnReceive(object, object?)

Processes an incoming windowed matrix and publishes the computed WL vector.

Declaration
protected override void OnReceive(object sender, object? value)
Parameters
Type Name Description
object sender

The upstream block.

object value

Expected to be a MathNet.Numerics.LinearAlgebra.Matrix<T> of double (rows = samples, columns = channels). Non-matrix inputs are rejected and reported through ReportError(string, Exception?); activity status remains automatic.

Overrides
BaseBlock.OnReceive(object, object)

OnWindowSizeChanged(int)

Executes the logic for when WindowSize just changed.

Declaration
private void OnWindowSizeChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of WindowSize is changed.

OnWindowSizeChanged(int, int)

Executes the logic for when WindowSize just changed.

Declaration
private void OnWindowSizeChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of WindowSize is changed.

OnWindowSizeChanging(int)

Executes the logic for when WindowSize is changing.

Declaration
private void OnWindowSizeChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of WindowSize is changed.

OnWindowSizeChanging(int, int)

Executes the logic for when WindowSize is changing.

Declaration
private void OnWindowSizeChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of WindowSize is changed.

Implements

INotifyPropertyChanged
INotifyPropertyChanging
ISubscriber
IPublisher
IBaseBlockProps
IJsonExportable
IDisposable
IAsyncDisposable

Search documentation

Start typing to search the documentation.