Class DepthFilter

Digital filter block that applies filtering along the depth (samples) dimension of each frame.

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.

"depthLP": {
  "Type": "DepthFilter",
  "Inputs": ["wulpusPy"],
  "Params": ["Lowpass", "IIR", 50, 150, 4, 64, 1000]
}

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

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

Key difference from Filter: The Filter block filters across time (sample-by-sample, maintaining state between frames). This block filters along the depth axis within each frame — filter state is reset per frame, so each frame is processed independently.

Designed for A-mode ultrasound lines or similar depth signals. Expects either a MathNet.Numerics.LinearAlgebra.Vector<T> of length nSamples or a MathNet.Numerics.LinearAlgebra.Matrix<T> of shape (nChannels × nSamples). The filter is applied independently to each row (channel) along the column (depth/sample) axis.

Uses the same FilterDesign factory and IOnlineFilter infrastructure as the time-domain Filter block. Filter parameters (type, cutoffs, order, taps) are fully adjustable at runtime via the UI.

Sample rate convention: For depth filtering, the "sample rate" represents the spatial sampling frequency of the depth signal (e.g., samples per unit distance). This is set via DepthSampleRate and defaults to 1000 if unset.

JSON configuration:

"depthLP": {
  "Type": "DepthFilter",
  "Inputs": ["wulpusPy"],
  "Params": ["Lowpass", "IIR", 50, 150, 4, 64, 1000]
}

Params: [FilterType, Implementation, CutoffLow, CutoffHigh, Order, FirTaps, DepthSampleRate]

Constructors

DepthFilter(string, double, FilterType, FilterImplementation, double, double, int, int, double)

Creates a new DepthFilter block.

Declaration
public DepthFilter(string name, double desiredRate = 0, FilterType filterType = FilterType.Lowpass, FilterImplementation implementation = FilterImplementation.IIR, double cutoffLow = 50, double cutoffHigh = 150, int order = 4, int firTaps = 64, double depthSampleRate = 1000)
Parameters
Type Name Description
string name
double desiredRate
FilterType filterType
FilterImplementation implementation
double cutoffLow
double cutoffHigh
int order
int firTaps
double depthSampleRate

Fields

_cachedFilter

Cached filter instance, rebuilt only on ApplyFilter().

Declaration
private IOnlineFilter? _cachedFilter
Field Value
Type Description
IOnlineFilter

_channelCount

Number of channels detected from the last input.

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

_cutoffHigh

Upper cutoff frequency (used for Bandpass/Bandstop).

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private double _cutoffHigh
Field Value
Type Description
double

_cutoffLow

Lower cutoff frequency in Hz (or spatial frequency units).

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private double _cutoffLow
Field Value
Type Description
double

_depthSampleRate

Spatial sample rate for the depth dimension. For ultrasound this represents the sampling frequency along the depth axis.

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private double _depthSampleRate
Field Value
Type Description
double

_filterLock

Declaration
private readonly object _filterLock
Field Value
Type Description
object

_filterType

Filter type (Lowpass, Highpass, Bandpass, Bandstop).

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private FilterType _filterType
Field Value
Type Description
FilterType

_firTaps

FIR filter tap count.

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

_framesProcessed

Total frames processed since creation.

Declaration
[ObservableProperty]
private long _framesProcessed
Field Value
Type Description
long

_implementation

Filter implementation (FIR or IIR).

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private FilterImplementation _implementation
Field Value
Type Description
FilterImplementation

_isEnabled

Whether filtering is active. When false, data passes through unchanged.

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

_needsApply

true when UI parameters differ from the active filter. Bound to a visual indicator so the user knows to press Apply.

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

_order

IIR filter order (Butterworth).

Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("FilterDescription")]
private int _order
Field Value
Type Description
int

Properties

ChannelCount

Number of channels detected from the last input.

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

CutoffHigh

Upper cutoff frequency (used for Bandpass/Bandstop).

Declaration
[ExcludeFromCodeCoverage]
public double CutoffHigh { get; set; }
Property Value
Type Description
double

CutoffLow

Lower cutoff frequency in Hz (or spatial frequency units).

Declaration
[ExcludeFromCodeCoverage]
public double CutoffLow { get; set; }
Property Value
Type Description
double

DepthSampleRate

Spatial sample rate for the depth dimension. For ultrasound this represents the sampling frequency along the depth axis.

Declaration
[ExcludeFromCodeCoverage]
public double DepthSampleRate { get; set; }
Property Value
Type Description
double

FilterDescription

Human-readable filter description for UI display.

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

FilterType

Filter type (Lowpass, Highpass, Bandpass, Bandstop).

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

FirTaps

FIR filter tap count.

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

FramesProcessed

Total frames processed since creation.

Declaration
[ExcludeFromCodeCoverage]
public long FramesProcessed { get; set; }
Property Value
Type Description
long

Heatmap

Standalone heatmap for B-mode display (configs × samples grid).

Declaration
public HeatMapMonitor Heatmap { get; }
Property Value
Type Description
HeatMapMonitor

Implementation

Filter implementation (FIR or IIR).

Declaration
[ExcludeFromCodeCoverage]
public FilterImplementation Implementation { get; set; }
Property Value
Type Description
FilterImplementation

IsEnabled

Whether filtering is active. When false, data passes through unchanged.

Declaration
[ExcludeFromCodeCoverage]
public bool IsEnabled { get; set; }
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

NeedsApply

true when UI parameters differ from the active filter. Bound to a visual indicator so the user knows to press Apply.

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

Order

IIR filter order (Butterworth).

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

Snapshot

Standalone A-mode snapshot monitor (spatial waveform, multi-trace).

Declaration
public SnapshotMonitor Snapshot { get; }
Property Value
Type Description
SnapshotMonitor

Methods

ApplyFilter()

Rebuilds the cached filter from current UI parameters. Call from the ViewModel's Apply button.

Declaration
public void ApplyFilter()

ConfigureInput(IServiceProvider, JsonModel)

Creates a DepthFilter from JSON pipeline configuration.

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

CreateFirFilter(double)

Declaration
private IOnlineFilter CreateFirFilter(double fs)
Parameters
Type Name Description
double fs
Returns
Type Description
IOnlineFilter

CreateIirFilter(double)

Declaration
private IOnlineFilter CreateIirFilter(double fs)
Parameters
Type Name Description
double fs
Returns
Type Description
IOnlineFilter

Dispose()

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

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

FilterDepthVector(Vector<double>)

Filters a single depth vector using the cached filter. The filter state is reset before each vector so depth frames are independent.

Declaration
private Vector<double> FilterDepthVector(Vector<double> x)
Parameters
Type Name Description
Vector<double> x
Returns
Type Description
Vector<double>

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()

OnChannelCountChanged(int)

Executes the logic for when ChannelCount just changed.

Declaration
private void OnChannelCountChanged(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 ChannelCount is changed.

OnChannelCountChanged(int, int)

Executes the logic for when ChannelCount just changed.

Declaration
private void OnChannelCountChanged(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 ChannelCount is changed.

OnChannelCountChanging(int)

Executes the logic for when ChannelCount is changing.

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

The new property value being set.

Remarks

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

OnChannelCountChanging(int, int)

Executes the logic for when ChannelCount is changing.

Declaration
private void OnChannelCountChanging(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 ChannelCount is changed.

OnCutoffHighChanged(double)

Executes the logic for when CutoffHigh just changed.

Declaration
private void OnCutoffHighChanged(double value)
Parameters
Type Name Description
double value

The new property value that was set.

Remarks

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

OnCutoffHighChanged(double, double)

Executes the logic for when CutoffHigh just changed.

Declaration
private void OnCutoffHighChanged(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 CutoffHigh is changed.

OnCutoffHighChanging(double)

Executes the logic for when CutoffHigh is changing.

Declaration
private void OnCutoffHighChanging(double value)
Parameters
Type Name Description
double value

The new property value being set.

Remarks

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

OnCutoffHighChanging(double, double)

Executes the logic for when CutoffHigh is changing.

Declaration
private void OnCutoffHighChanging(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 CutoffHigh is changed.

OnCutoffLowChanged(double)

Executes the logic for when CutoffLow just changed.

Declaration
private void OnCutoffLowChanged(double value)
Parameters
Type Name Description
double value

The new property value that was set.

Remarks

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

OnCutoffLowChanged(double, double)

Executes the logic for when CutoffLow just changed.

Declaration
private void OnCutoffLowChanged(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 CutoffLow is changed.

OnCutoffLowChanging(double)

Executes the logic for when CutoffLow is changing.

Declaration
private void OnCutoffLowChanging(double value)
Parameters
Type Name Description
double value

The new property value being set.

Remarks

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

OnCutoffLowChanging(double, double)

Executes the logic for when CutoffLow is changing.

Declaration
private void OnCutoffLowChanging(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 CutoffLow is changed.

OnDepthSampleRateChanged(double)

Executes the logic for when DepthSampleRate just changed.

Declaration
private void OnDepthSampleRateChanged(double value)
Parameters
Type Name Description
double value

The new property value that was set.

Remarks

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

OnDepthSampleRateChanged(double, double)

Executes the logic for when DepthSampleRate just changed.

Declaration
private void OnDepthSampleRateChanged(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 DepthSampleRate is changed.

OnDepthSampleRateChanging(double)

Executes the logic for when DepthSampleRate is changing.

Declaration
private void OnDepthSampleRateChanging(double value)
Parameters
Type Name Description
double value

The new property value being set.

Remarks

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

OnDepthSampleRateChanging(double, double)

Executes the logic for when DepthSampleRate is changing.

Declaration
private void OnDepthSampleRateChanging(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 DepthSampleRate is changed.

OnFilterTypeChanged(FilterType)

Executes the logic for when FilterType just changed.

Declaration
private void OnFilterTypeChanged(FilterType value)
Parameters
Type Name Description
FilterType value

The new property value that was set.

Remarks

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

OnFilterTypeChanged(FilterType, FilterType)

Executes the logic for when FilterType just changed.

Declaration
private void OnFilterTypeChanged(FilterType oldValue, FilterType newValue)
Parameters
Type Name Description
FilterType oldValue

The previous property value that was replaced.

FilterType newValue

The new property value that was set.

Remarks

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

OnFilterTypeChanging(FilterType)

Executes the logic for when FilterType is changing.

Declaration
private void OnFilterTypeChanging(FilterType value)
Parameters
Type Name Description
FilterType value

The new property value being set.

Remarks

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

OnFilterTypeChanging(FilterType, FilterType)

Executes the logic for when FilterType is changing.

Declaration
private void OnFilterTypeChanging(FilterType oldValue, FilterType newValue)
Parameters
Type Name Description
FilterType oldValue

The previous property value that is being replaced.

FilterType newValue

The new property value being set.

Remarks

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

OnFirTapsChanged(int)

Executes the logic for when FirTaps just changed.

Declaration
private void OnFirTapsChanged(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 FirTaps is changed.

OnFirTapsChanged(int, int)

Executes the logic for when FirTaps just changed.

Declaration
private void OnFirTapsChanged(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 FirTaps is changed.

OnFirTapsChanging(int)

Executes the logic for when FirTaps is changing.

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

The new property value being set.

Remarks

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

OnFirTapsChanging(int, int)

Executes the logic for when FirTaps is changing.

Declaration
private void OnFirTapsChanging(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 FirTaps is changed.

OnFramesProcessedChanged(long)

Executes the logic for when FramesProcessed just changed.

Declaration
private void OnFramesProcessedChanged(long value)
Parameters
Type Name Description
long value

The new property value that was set.

Remarks

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

OnFramesProcessedChanged(long, long)

Executes the logic for when FramesProcessed just changed.

Declaration
private void OnFramesProcessedChanged(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that was replaced.

long newValue

The new property value that was set.

Remarks

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

OnFramesProcessedChanging(long)

Executes the logic for when FramesProcessed is changing.

Declaration
private void OnFramesProcessedChanging(long value)
Parameters
Type Name Description
long value

The new property value being set.

Remarks

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

OnFramesProcessedChanging(long, long)

Executes the logic for when FramesProcessed is changing.

Declaration
private void OnFramesProcessedChanging(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that is being replaced.

long newValue

The new property value being set.

Remarks

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

OnImplementationChanged(FilterImplementation)

Executes the logic for when Implementation just changed.

Declaration
private void OnImplementationChanged(FilterImplementation value)
Parameters
Type Name Description
FilterImplementation value

The new property value that was set.

Remarks

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

OnImplementationChanged(FilterImplementation, FilterImplementation)

Executes the logic for when Implementation just changed.

Declaration
private void OnImplementationChanged(FilterImplementation oldValue, FilterImplementation newValue)
Parameters
Type Name Description
FilterImplementation oldValue

The previous property value that was replaced.

FilterImplementation newValue

The new property value that was set.

Remarks

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

OnImplementationChanging(FilterImplementation)

Executes the logic for when Implementation is changing.

Declaration
private void OnImplementationChanging(FilterImplementation value)
Parameters
Type Name Description
FilterImplementation value

The new property value being set.

Remarks

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

OnImplementationChanging(FilterImplementation, FilterImplementation)

Executes the logic for when Implementation is changing.

Declaration
private void OnImplementationChanging(FilterImplementation oldValue, FilterImplementation newValue)
Parameters
Type Name Description
FilterImplementation oldValue

The previous property value that is being replaced.

FilterImplementation newValue

The new property value being set.

Remarks

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

OnIsEnabledChanged(bool)

Executes the logic for when IsEnabled just changed.

Declaration
private void OnIsEnabledChanged(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 IsEnabled is changed.

OnIsEnabledChanged(bool, bool)

Executes the logic for when IsEnabled just changed.

Declaration
private void OnIsEnabledChanged(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 IsEnabled is changed.

OnIsEnabledChanging(bool)

Executes the logic for when IsEnabled is changing.

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

The new property value being set.

Remarks

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

OnIsEnabledChanging(bool, bool)

Executes the logic for when IsEnabled is changing.

Declaration
private void OnIsEnabledChanging(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 IsEnabled is changed.

OnNeedsApplyChanged(bool)

Executes the logic for when NeedsApply just changed.

Declaration
private void OnNeedsApplyChanged(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 NeedsApply is changed.

OnNeedsApplyChanged(bool, bool)

Executes the logic for when NeedsApply just changed.

Declaration
private void OnNeedsApplyChanged(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 NeedsApply is changed.

OnNeedsApplyChanging(bool)

Executes the logic for when NeedsApply is changing.

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

The new property value being set.

Remarks

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

OnNeedsApplyChanging(bool, bool)

Executes the logic for when NeedsApply is changing.

Declaration
private void OnNeedsApplyChanging(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 NeedsApply is changed.

OnOrderChanged(int)

Executes the logic for when Order just changed.

Declaration
private void OnOrderChanged(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 Order is changed.

OnOrderChanged(int, int)

Executes the logic for when Order just changed.

Declaration
private void OnOrderChanged(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 Order is changed.

OnOrderChanging(int)

Executes the logic for when Order is changing.

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

The new property value being set.

Remarks

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

OnOrderChanging(int, int)

Executes the logic for when Order is changing.

Declaration
private void OnOrderChanging(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 Order is changed.

OnReceive(object, object)

Receives upstream data (Vector or Matrix) and applies the depth filter to each frame.

Declaration
protected override void OnReceive(object sender, object data)
Parameters
Type Name Description
object sender
object data
Overrides
BaseBlock.OnReceive(object, object)

Implements

INotifyPropertyChanged
INotifyPropertyChanging
ISubscriber
IPublisher
IBaseBlockProps
IJsonExportable
IDisposable
IAsyncDisposable

Search documentation

Start typing to search the documentation.