Class Crop
Crops (slices) incoming vectors or matrices to a sub-range along the depth and/or channel axis.
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.
// Vector crop (depth only):
"crop": {
"Type": "Crop",
"Inputs": ["wulpusPy"],
"Params": [10, 380]
}
// Matrix crop (rows + columns):
"crop": {
"Type": "Crop",
"Inputs": ["wulpusPy"],
"Params": [10, 380, 0, 4]
}
How Type, Inputs and Params work · Block catalogue and parameter reference
Implements
Inherited Members
Namespace: MOSAIC.Models.SignalProcessing
Assembly: MOSAIC.dll
Syntax
public sealed class Crop : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks
Vector input: Extracts a sub-vector starting at DepthIndex with length DepthCount.
Matrix input: Extracts a sub-matrix starting at row RowIndex with RowCount rows and column DepthIndex with DepthCount columns. When only two params are provided, the row range defaults to all rows.
Useful for trimming ultrasound A-mode lines to a region of interest, discarding metadata samples, or selecting a subset of channels from a multi-channel frame.
JSON configuration:
// Vector crop (depth only):
"crop": {
"Type": "Crop",
"Inputs": ["wulpusPy"],
"Params": [10, 380]
}
// Matrix crop (rows + columns):
"crop": {
"Type": "Crop",
"Inputs": ["wulpusPy"],
"Params": [10, 380, 0, 4]
}
2-param form: [DepthIndex, DepthCount] 4-param form: [DepthIndex, DepthCount, RowIndex, RowCount]
Constructors
Crop(string, double, int, int, int, int)
Creates a new Crop block.
Declaration
public Crop(string name, double desiredRate = 0, int depthIndex = 0, int depthCount = 1, int rowIndex = 0, int rowCount = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Block name. |
| double | desiredRate | Desired execution rate in Hz. |
| int | depthIndex | Start index along depth axis. |
| int | depthCount | Number of depth samples to keep. |
| int | rowIndex | Start row index (0 if unused). |
| int | rowCount | Number of rows to keep (0 if unused). |
Fields
_depthCount
Number of samples to keep along the depth axis.
Declaration
[ObservableProperty]
private int _depthCount
Field Value
| Type | Description |
|---|---|
| int |
_depthIndex
Start index along the depth (column / sample) axis.
Declaration
[ObservableProperty]
private int _depthIndex
Field Value
| Type | Description |
|---|---|
| int |
_hasRowCrop
Whether a 4-param (row + depth) crop is active.
Declaration
[ObservableProperty]
private bool _hasRowCrop
Field Value
| Type | Description |
|---|---|
| bool |
_inputShape
Dimensions of the last input received (for display).
Declaration
[ObservableProperty]
private string _inputShape
Field Value
| Type | Description |
|---|---|
| string |
_outputShape
Dimensions of the last output produced (for display).
Declaration
[ObservableProperty]
private string _outputShape
Field Value
| Type | Description |
|---|---|
| string |
_rowCount
Number of rows (channels) to keep. Only used for Matrix input.
Declaration
[ObservableProperty]
private int _rowCount
Field Value
| Type | Description |
|---|---|
| int |
_rowIndex
Start index along the row (channel) axis. Only used for Matrix input.
Declaration
[ObservableProperty]
private int _rowIndex
Field Value
| Type | Description |
|---|---|
| int |
_visualizedConfig
Index of the currently visualized channel (for matrix output).
Declaration
[ObservableProperty]
private int _visualizedConfig
Field Value
| Type | Description |
|---|---|
| int |
Properties
DepthCount
Number of samples to keep along the depth axis.
Declaration
[ExcludeFromCodeCoverage]
public int DepthCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
DepthIndex
Start index along the depth (column / sample) axis.
Declaration
[ExcludeFromCodeCoverage]
public int DepthIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
HasRowCrop
Whether a 4-param (row + depth) crop is active.
Declaration
[ExcludeFromCodeCoverage]
public bool HasRowCrop { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
InputShape
Dimensions of the last input received (for display).
Declaration
[ExcludeFromCodeCoverage]
public string InputShape { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
JsonTypeName
Block type identifier for JSON serialization. Override for a custom name.
Declaration
protected override string JsonTypeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
OutputShape
Dimensions of the last output produced (for display).
Declaration
[ExcludeFromCodeCoverage]
public string OutputShape { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
RowCount
Number of rows (channels) to keep. Only used for Matrix input.
Declaration
[ExcludeFromCodeCoverage]
public int RowCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
RowIndex
Start index along the row (channel) axis. Only used for Matrix input.
Declaration
[ExcludeFromCodeCoverage]
public int RowIndex { 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
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.
VisualizedConfig
Index of the currently visualized channel (for matrix output).
Declaration
[ExcludeFromCodeCoverage]
public int VisualizedConfig { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Viz
Visualization bundle for scope display of the cropped output.
Declaration
public BlockVisualization Viz { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Methods
ConfigureInput(IServiceProvider, JsonModel)
Creates a Crop from JSON pipeline configuration.
Declaration
public static Crop ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | sp | |
| JsonModel | m |
Returns
| Type | Description |
|---|---|
| Crop |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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
OnDepthCountChanged(int)
Executes the logic for when DepthCount just changed.
Declaration
private void OnDepthCountChanged(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 DepthCount is changed.
OnDepthCountChanged(int, int)
Executes the logic for when DepthCount just changed.
Declaration
private void OnDepthCountChanged(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 DepthCount is changed.
OnDepthCountChanging(int)
Executes the logic for when DepthCount is changing.
Declaration
private void OnDepthCountChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of DepthCount is changed.
OnDepthCountChanging(int, int)
Executes the logic for when DepthCount is changing.
Declaration
private void OnDepthCountChanging(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 DepthCount is changed.
OnDepthIndexChanged(int)
Executes the logic for when DepthIndex just changed.
Declaration
private void OnDepthIndexChanged(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 DepthIndex is changed.
OnDepthIndexChanged(int, int)
Executes the logic for when DepthIndex just changed.
Declaration
private void OnDepthIndexChanged(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 DepthIndex is changed.
OnDepthIndexChanging(int)
Executes the logic for when DepthIndex is changing.
Declaration
private void OnDepthIndexChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of DepthIndex is changed.
OnDepthIndexChanging(int, int)
Executes the logic for when DepthIndex is changing.
Declaration
private void OnDepthIndexChanging(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 DepthIndex is changed.
OnHasRowCropChanged(bool)
Executes the logic for when HasRowCrop just changed.
Declaration
private void OnHasRowCropChanged(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 HasRowCrop is changed.
OnHasRowCropChanged(bool, bool)
Executes the logic for when HasRowCrop just changed.
Declaration
private void OnHasRowCropChanged(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 HasRowCrop is changed.
OnHasRowCropChanging(bool)
Executes the logic for when HasRowCrop is changing.
Declaration
private void OnHasRowCropChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of HasRowCrop is changed.
OnHasRowCropChanging(bool, bool)
Executes the logic for when HasRowCrop is changing.
Declaration
private void OnHasRowCropChanging(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 HasRowCrop is changed.
OnInputShapeChanged(string)
Executes the logic for when InputShape just changed.
Declaration
private void OnInputShapeChanged(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of InputShape is changed.
OnInputShapeChanged(string?, string)
Executes the logic for when InputShape just changed.
Declaration
private void OnInputShapeChanged(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of InputShape is changed.
OnInputShapeChanging(string)
Executes the logic for when InputShape is changing.
Declaration
private void OnInputShapeChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of InputShape is changed.
OnInputShapeChanging(string?, string)
Executes the logic for when InputShape is changing.
Declaration
private void OnInputShapeChanging(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of InputShape is changed.
OnOutputShapeChanged(string)
Executes the logic for when OutputShape just changed.
Declaration
private void OnOutputShapeChanged(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of OutputShape is changed.
OnOutputShapeChanged(string?, string)
Executes the logic for when OutputShape just changed.
Declaration
private void OnOutputShapeChanged(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of OutputShape is changed.
OnOutputShapeChanging(string)
Executes the logic for when OutputShape is changing.
Declaration
private void OnOutputShapeChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of OutputShape is changed.
OnOutputShapeChanging(string?, string)
Executes the logic for when OutputShape is changing.
Declaration
private void OnOutputShapeChanging(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of OutputShape 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 data)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The publishing block, or whatever else delivered the value. |
| object | data |
Overrides
Remarks
Called on the dispatching thread, not the UI thread.
OnRowCountChanged(int)
Executes the logic for when RowCount just changed.
Declaration
private void OnRowCountChanged(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 RowCount is changed.
OnRowCountChanged(int, int)
Executes the logic for when RowCount just changed.
Declaration
private void OnRowCountChanged(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 RowCount is changed.
OnRowCountChanging(int)
Executes the logic for when RowCount is changing.
Declaration
private void OnRowCountChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of RowCount is changed.
OnRowCountChanging(int, int)
Executes the logic for when RowCount is changing.
Declaration
private void OnRowCountChanging(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 RowCount is changed.
OnRowIndexChanged(int)
Executes the logic for when RowIndex just changed.
Declaration
private void OnRowIndexChanged(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 RowIndex is changed.
OnRowIndexChanged(int, int)
Executes the logic for when RowIndex just changed.
Declaration
private void OnRowIndexChanged(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 RowIndex is changed.
OnRowIndexChanging(int)
Executes the logic for when RowIndex is changing.
Declaration
private void OnRowIndexChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of RowIndex is changed.
OnRowIndexChanging(int, int)
Executes the logic for when RowIndex is changing.
Declaration
private void OnRowIndexChanging(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 RowIndex is changed.
OnVisualizedConfigChanged(int)
Executes the logic for when VisualizedConfig just changed.
Declaration
private void OnVisualizedConfigChanged(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 VisualizedConfig is changed.
OnVisualizedConfigChanged(int, int)
Executes the logic for when VisualizedConfig just changed.
Declaration
private void OnVisualizedConfigChanged(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 VisualizedConfig is changed.
OnVisualizedConfigChanging(int)
Executes the logic for when VisualizedConfig is changing.
Declaration
private void OnVisualizedConfigChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of VisualizedConfig is changed.
OnVisualizedConfigChanging(int, int)
Executes the logic for when VisualizedConfig is changing.
Declaration
private void OnVisualizedConfigChanging(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 VisualizedConfig is changed.