Class Projector

Projects (selects) specific channels from an input vector or matrix by index, producing a reduced-dimension output.

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:

{
  "SelectChannels": {
    "Type": "Projector",
    "Inputs": [ "EMG" ],
    "Params": [ "0;2;4;6" ]
  }
}

Params[0]: semicolon-separated zero-based channel indices.

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

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

Vector input: Selects elements at the configured ProjectedIndices and publishes a shorter vector containing only those elements.

Matrix input [timesteps × channels]: Selects columns at the configured indices and publishes a narrower matrix. All timesteps are preserved.

Index validation: Indices outside the valid range [0, N−1] are silently skipped at runtime. The ValidationError and IsValid properties provide UI feedback when invalid indices are configured.

Constructors

Projector(string, int[]?, double)

Declaration
public Projector(string name, int[]? indices, double desiredRate = 0)
Parameters
Type Name Description
string name
int[] indices
double desiredRate

Fields

_inputChannels

Gets the number of input channels (detected from the input).

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

_projectedIndices

Gets or sets the indices to project from the input.

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

_projectedValue

Preallocated vector output buffer.

Declaration
private Vector<double>? _projectedValue
Field Value
Type Description
Vector<double>

Properties

ConfigSummary

Gets a human-readable summary of the projection mapping.

Declaration
public string ConfigSummary { get; }
Property Value
Type Description
string

DumpFilePrefix

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

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

InputChannels

Gets the number of input channels (detected from the input).

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

IsValid

Gets whether the current index configuration is valid.

Declaration
public bool IsValid { get; }
Property Value
Type Description
bool

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

MaxValidIndex

Gets the maximum valid index.

Declaration
public int MaxValidIndex { get; }
Property Value
Type Description
int

OutputChannels

Gets the number of output channels.

Declaration
public int OutputChannels { get; }
Property Value
Type Description
int

ProjectedIndices

Gets or sets the indices to project from the input.

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

ValidationError

Gets a validation error message, or null if valid.

Declaration
public string? ValidationError { get; }
Property Value
Type Description
string

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 projected output to the UI scope.

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

Methods

ConfigureInput(IServiceProvider, JsonModel)

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

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

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

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 ConfigureInput reads them, or null when the block takes no parameters.

Overrides
BaseBlock.GetJsonParams()

NotifyComputedProperties()

Declaration
private void NotifyComputedProperties()

OnInputChannelsChanged(int)

Executes the logic for when InputChannels just changed.

Declaration
private void OnInputChannelsChanged(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 InputChannels is changed.

OnInputChannelsChanged(int, int)

Executes the logic for when InputChannels just changed.

Declaration
private void OnInputChannelsChanged(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 InputChannels is changed.

OnInputChannelsChanging(int)

Executes the logic for when InputChannels is changing.

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

The new property value being set.

Remarks

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

OnInputChannelsChanging(int, int)

Executes the logic for when InputChannels is changing.

Declaration
private void OnInputChannelsChanging(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 InputChannels is changed.

OnProjectedIndicesChanged(int[])

Executes the logic for when ProjectedIndices just changed.

Declaration
private void OnProjectedIndicesChanged(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 ProjectedIndices is changed.

OnProjectedIndicesChanged(int[]?, int[])

Executes the logic for when ProjectedIndices just changed.

Declaration
private void OnProjectedIndicesChanged(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 ProjectedIndices is changed.

OnProjectedIndicesChanging(int[])

Executes the logic for when ProjectedIndices is changing.

Declaration
private void OnProjectedIndicesChanging(int[] value)
Parameters
Type Name Description
int[] value

The new property value being set.

Remarks

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

OnProjectedIndicesChanging(int[]?, int[])

Executes the logic for when ProjectedIndices is changing.

Declaration
private void OnProjectedIndicesChanging(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 ProjectedIndices is changed.

OnReceive(object, object?)

Processes incoming data from an upstream block. Must be implemented by derived classes.

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

The publishing block, or whatever else delivered the value.

object value

The payload. Blocks are wired by config rather than by type, so an implementation has to check the run-time type and reject or handle a shape it cannot use. Status is updated automatically from publication activity; it is not a per-value validation result.

Overrides
BaseBlock.OnReceive(object, object)
Remarks

Called on the dispatching thread, not the UI thread.

ProcessMatrix(Matrix<double>)

Projects columns from a [timesteps × channels] matrix by index.

Declaration
private void ProcessMatrix(Matrix<double> input)
Parameters
Type Name Description
Matrix<double> input

ProcessVector(Vector<double>)

Projects elements from a vector by index.

Declaration
private void ProcessVector(Vector<double> input)
Parameters
Type Name Description
Vector<double> input

Implements

INotifyPropertyChanged
INotifyPropertyChanging
ISubscriber
IPublisher
IBaseBlockProps
IJsonExportable
IDisposable
IAsyncDisposable

Search documentation

Start typing to search the documentation.