Class MuoviSingleProbe

A BaseBlock that streams high-density surface EMG (HD-sEMG), EEG, or IMU data from a single OT Bioelettronica Muovi probe over a direct Wi-Fi TCP connection.

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.

Block entry for a larger pipeline. Params are keyword tokens: emg selects the signal mode; matrix requests batched output. Configure the Wi-Fi probe to connect to this host before starting acquisition.

{
  "MuoviSingleProbe": {
    "Type": "muovisingleprobe",
    "Inputs": [],
    "Params": ["emg", "matrix"]
  }
}

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

Inheritance
MuoviSingleProbe
Namespace: MOSAIC.Models.Devices
Assembly: MOSAIC.dll
Syntax
public sealed class MuoviSingleProbe : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks

A BaseBlock represents one node in a processing graph. Blocks are typically created and linked based on a JSON configuration (pipeline definition).

Two Rate Properties:

PropertyPurpose
DesiredRate Emission / display rate in Hz. Determines how often a block publishes output. Modified by windowing blocks (e.g. SlidingWindow: input rows/s divided by stride). Used for status monitoring and tick rate display.
SignalRate True sample rate of the underlying signal in Hz. Used for DSP coefficient design (filter cutoffs, FFT bins, spectral resolution). Passes through windowing blocks unchanged — a SlidingWindow with stride 100 at 2000 Hz input still outputs data whose samples are at 2000 Hz, even though the windows arrive at 20 Hz.

Rate Inheritance: Both rates propagate downstream automatically via TryInheritRate(BaseBlock). Publication rates initially fill unset values; use UpdateAndPropagateRate(double, bool) for runtime changes. Sample rates refresh downstream unless a block declares that it derives its own rate.

Publishing: The Publish(object) method is thread-safe and non-blocking. If a publish call is already in progress, the new value is dropped and the block enters a "stumbling" state reflected in Status.

Automatic CSV Logging: Every successful Publish(object) call feeds Dumper whenever one is open. A dumper opens either because the config named a Path — BlockFactory calls InitDumper(IServiceProvider, string?) for every block it builds — or because IsRecording was switched on, which writes to the shared session folder instead. Either way the file is named by DumpFilePrefix. A block whose Path means something other than a recording folder overrides PathIsDumpFolder.

Constructors

MuoviSingleProbe(string, double)

Declaration
public MuoviSingleProbe(string name = "MuoviSingle", double desiredRate = 100)
Parameters
Type Name Description
string name
double desiredRate

Fields

BytesPerSample

Byte count for one sample frame: 38 columns × 2 bytes = 76 bytes.

Declaration
private const int BytesPerSample = 76
Field Value
Type Description
int

ListenPort

TCP port on which this block listens for the incoming probe connection.

Declaration
private const int ListenPort = 54321
Field Value
Type Description
int

TotalColumnsPerFrame

Total raw columns per frame (32 electrode + 4 IMU + 2 accessory).

Declaration
private const int TotalColumnsPerFrame = 38
Field Value
Type Description
int

_clientSocket

Declaration
private Socket? _clientSocket
Field Value
Type Description
Socket

_configByte

Declaration
private byte _configByte
Field Value
Type Description
byte

_conversionFactor

Declaration
private double _conversionFactor
Field Value
Type Description
double

_hasEmg

Declaration
[ObservableProperty]
private bool _hasEmg
Field Value
Type Description
bool

_hasImu

Declaration
[ObservableProperty]
private bool _hasImu
Field Value
Type Description
bool

_isStreaming

Declaration
private volatile bool _isStreaming
Field Value
Type Description
bool

_lastRamp

Declaration
private short _lastRamp
Field Value
Type Description
short

_latestImu

Declaration
private volatile Vector<double>? _latestImu
Field Value
Type Description
Vector<double>

_latestSample

Declaration
private volatile Vector<double>? _latestSample
Field Value
Type Description
Vector<double>

_listenSocket

Declaration
private Socket? _listenSocket
Field Value
Type Description
Socket

_matrixMode

Declaration
private bool _matrixMode
Field Value
Type Description
bool

_nominalRate

Declaration
private int _nominalRate
Field Value
Type Description
int

_rampInitialized

Declaration
private bool _rampInitialized
Field Value
Type Description
bool

_readerThread

Declaration
private Thread? _readerThread
Field Value
Type Description
Thread

_reading

Declaration
private volatile bool _reading
Field Value
Type Description
bool

_sampleReady

Declaration
private volatile bool _sampleReady
Field Value
Type Description
bool

_samplesPerBatch

Declaration
private int _samplesPerBatch
Field Value
Type Description
int

_stream

Declaration
private NetworkStream? _stream
Field Value
Type Description
NetworkStream

Properties

ChannelLabels

Declaration
public List<string> ChannelLabels { get; private set; }
Property Value
Type Description
List<string>

DumpFilePrefix

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

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

EmgChannelLabels

Declaration
public List<string> EmgChannelLabels { get; private set; }
Property Value
Type Description
List<string>

ForceMatrixMode

Explicit override for the publish strategy (JSON "matrix" / "vector"). null (default) keeps the legacy auto-derivation from DesiredRate; true forces per-packet MathNet.Numerics.LinearAlgebra.Matrix<T> push (lossless), false forces decimated single-MathNet.Numerics.LinearAlgebra.Vector<T> output. Must be set before Connect().

Declaration
public bool? ForceMatrixMode { get; set; }
Property Value
Type Description
bool?

HasEmg

Declaration
[ExcludeFromCodeCoverage]
public bool HasEmg { get; set; }
Property Value
Type Description
bool

HasImu

Declaration
[ExcludeFromCodeCoverage]
public bool HasImu { get; set; }
Property Value
Type Description
bool

ImuChannelLabels

Declaration
public List<string> ImuChannelLabels { get; private set; }
Property Value
Type Description
List<string>

IsStreaming

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

MaxInputs

Gets the maximum number of input connections allowed for this block.

Declaration
public override int MaxInputs { get; }
Property Value
Type Description
int
Overrides
BaseBlock.MaxInputs
Remarks

Override in derived classes to specify input requirements. Default is 1 (most blocks accept exactly one input). Use MaxValue for blocks that accept unlimited inputs (e.g., Joiner).

MinInputs

Gets the minimum number of input connections required for this block.

Declaration
public override int MinInputs { get; }
Property Value
Type Description
int
Overrides
BaseBlock.MinInputs
Remarks

Override in derived classes to specify input requirements. Default is 1 (most blocks require exactly one input). Source blocks (devices, generators) should return 0.

OutputChannels

Number of output channels: 32 electrode, plus optionally 4 IMU.

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

ScopeEmg

Scope monitor for real-time visualisation of the electrode (EMG / EEG) channels.

Declaration
public ScopeMonitor ScopeEmg { get; }
Property Value
Type Description
ScopeMonitor

ScopeImu

Scope monitor for real-time visualisation of the IMU quaternion channels.

Declaration
public ScopeMonitor ScopeImu { get; }
Property Value
Type Description
ScopeMonitor

SignalMode

Signal acquisition mode. Must be set before Connect().

Declaration
public MuoviSignalMode SignalMode { get; set; }
Property Value
Type Description
MuoviSignalMode

StreamImu

Whether the four IMU quaternion channels are included.

Declaration
public bool StreamImu { get; set; }
Property Value
Type Description
bool

StreamInfo

Observable telemetry counters for binding in a device card view.

Declaration
public MuoviStreamInfo StreamInfo { get; }
Property Value
Type Description
MuoviStreamInfo

Methods

BuildChannelLabels()

Declaration
private void BuildChannelLabels()

CheckRamp(byte[], int)

Declaration
private void CheckRamp(byte[] frame, int offset)
Parameters
Type Name Description
byte[] frame
int offset

ConfigureInput(IServiceProvider, JsonModel)

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

Connect()

Declaration
public void Connect()

ConnectAsync()

Declaration
public Task ConnectAsync()
Returns
Type Description
Task

DecodeSampleInline(byte[], int)

Declaration
private void DecodeSampleInline(byte[] frame, int offset)
Parameters
Type Name Description
byte[] frame
int offset

Disconnect()

Declaration
public void Disconnect()

Dispose()

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

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

ExtractElectrodeMatrix(Matrix<double>)

Returns a [rows × electrodeChannels] sub-matrix containing only the electrode columns. When StreamImu is false the input matrix is returned unchanged.

Declaration
private Matrix<double> ExtractElectrodeMatrix(Matrix<double> full)
Parameters
Type Name Description
Matrix<double> full
Returns
Type Description
Matrix<double>

OnHasEmgChanged(bool)

Executes the logic for when HasEmg just changed.

Declaration
private void OnHasEmgChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

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

OnHasEmgChanged(bool, bool)

Executes the logic for when HasEmg just changed.

Declaration
private void OnHasEmgChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

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

OnHasEmgChanging(bool)

Executes the logic for when HasEmg is changing.

Declaration
private void OnHasEmgChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

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

OnHasEmgChanging(bool, bool)

Executes the logic for when HasEmg is changing.

Declaration
private void OnHasEmgChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

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

OnHasImuChanged(bool)

Executes the logic for when HasImu just changed.

Declaration
private void OnHasImuChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

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

OnHasImuChanged(bool, bool)

Executes the logic for when HasImu just changed.

Declaration
private void OnHasImuChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

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

OnHasImuChanging(bool)

Executes the logic for when HasImu is changing.

Declaration
private void OnHasImuChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

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

OnHasImuChanging(bool, bool)

Executes the logic for when HasImu is changing.

Declaration
private void OnHasImuChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of HasImu 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 tNow)
Parameters
Type Name Description
object sender

The publishing block, or whatever else delivered the value.

object tNow
Overrides
BaseBlock.OnReceive(object, object)
Remarks

Called on the dispatching thread, not the UI thread.

PublishMatrixBatch(byte[], int)

Declaration
private void PublishMatrixBatch(byte[] buf, int batchOffset)
Parameters
Type Name Description
byte[] buf
int batchOffset

ReadInt16BigEndian(byte[], int)

Declaration
private static short ReadInt16BigEndian(byte[] buf, int offset)
Parameters
Type Name Description
byte[] buf
int offset
Returns
Type Description
short

ReaderLoop()

Declaration
private void ReaderLoop()

Implements

INotifyPropertyChanged
INotifyPropertyChanging
ISubscriber
IPublisher
IBaseBlockProps
IJsonExportable
IDisposable
IAsyncDisposable

Search documentation

Start typing to search the documentation.