Class SlopeSignChanges
Computes the Slope Sign Changes (SSC) 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:
{
"SSC": {
"Type": "SlopeSignChanges",
"Inputs": [ "SlidingWindow1" ],
"Params": [ 0.01 ],
"DesiredRate": 100,
"Path": "C:/Data/session1"
}
}
Params:
| Index | Description |
|---|---|
| 0 |
Threshold (double, optional). Minimum absolute difference required for both
adjacent samples to count a slope sign change. Defaults to 0.0.
|
How Type, Inputs and Params work · Block catalogue and parameter reference
Implements
Inherited Members
Namespace: MOSAIC.Models.FlowControl
Assembly: MOSAIC.dll
Syntax
public class SlopeSignChanges : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks
Formula: SSC = Σ f[(x[n] − x[n−1]) × (x[n] − x[n+1])] where f[x] = 1 if |diff₁| ≥ threshold and |diff₂| ≥ threshold and diff₁ × diff₂ < 0, else 0.
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 SSC count per channel, published to all downstream subscribers.
Threshold: The configurable Threshold parameter suppresses noise by requiring both adjacent differences to exceed a minimum magnitude before counting a sign change. A threshold of 0 counts all sign changes.
CSV logging: When a Path is specified, Dumper
automatically logs the output vector via Publish(object).
Constructors
SlopeSignChanges(string, double, double)
Initializes a new SlopeSignChanges block.
Declaration
public SlopeSignChanges(string name, double threshold = 0, double desiredRate = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Display name of the block. |
| double | threshold | Minimum difference threshold for noise suppression. |
| 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 |
_threshold
Gets or sets the minimum difference threshold for noise suppression. Both adjacent differences must exceed this value to count as a sign change.
Declaration
[ObservableProperty]
private double _threshold
Field Value
| Type | Description |
|---|---|
| double |
_windowSize
Gets the window size (row count) from the most recent input matrix.
Declaration
[ObservableProperty]
private int _windowSize
Field Value
| Type | Description |
|---|---|
| int |
Properties
ConfigSummary
Gets a human-readable summary of the current configuration.
Declaration
public string ConfigSummary { get; }
Property Value
| Type | Description |
|---|---|
| string |
Description
Gets the formula description for display in the UI.
Declaration
public string Description { get; }
Property Value
| Type | Description |
|---|---|
| string |
DumpFilePrefix
Recordings from this block are named <block>_ssc.csv.
Declaration
protected override string DumpFilePrefix { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
JsonTypeName
Block type identifier for JSON serialization. Override for a custom name.
Declaration
protected override string JsonTypeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
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 |
Threshold
Gets or sets the minimum difference threshold for noise suppression. Both adjacent differences must exceed this value to count as a sign change.
Declaration
[ExcludeFromCodeCoverage]
public double Threshold { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Visualization
This block's visualization, or null when it has none.
Declaration
protected override BlockVisualization? Visualization { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Overrides
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 SSC 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 SlopeSignChanges from a JSON pipeline definition.
Declaration
public static SlopeSignChanges ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | sp | Service provider for dependency injection. |
| JsonModel | m | JSON model. |
Returns
| Type | Description |
|---|---|
| SlopeSignChanges | A configured SlopeSignChanges instance. |
Dispose()
Releases visualization and base class resources (including CSV dumper if configured).
Declaration
public override void Dispose()
Overrides
GetJsonParams()
Block-specific parameters for JSON. Override to provide custom parameters.
Declaration
protected override IReadOnlyList<object> GetJsonParams()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<object> | The values for Params, in the order this block's |
Overrides
NotifyConfigChanged()
Raises property-changed for the computed ConfigSummary.
Declaration
private void NotifyConfigChanged()
OnOutputChannelsChanged(int)
Notifies ConfigSummary when output channels change.
Declaration
private void OnOutputChannelsChanged(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
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 SSC 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
Remarks
For each channel, the algorithm iterates samples [1, N−2] and counts positions where the sign of the first difference flips (relative to the previous difference), provided both differences exceed Threshold.
OnThresholdChanged(double)
Notifies ConfigSummary when threshold changes.
Declaration
private void OnThresholdChanged(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value |
OnThresholdChanged(double, double)
Executes the logic for when Threshold just changed.
Declaration
private void OnThresholdChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that was replaced. |
| double | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of Threshold is changed.
OnThresholdChanging(double)
Executes the logic for when Threshold is changing.
Declaration
private void OnThresholdChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of Threshold is changed.
OnThresholdChanging(double, double)
Executes the logic for when Threshold is changing.
Declaration
private void OnThresholdChanging(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that is being replaced. |
| double | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of Threshold is changed.
OnWindowSizeChanged(int)
Notifies ConfigSummary when window size changes.
Declaration
private void OnWindowSizeChanged(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
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.