This page hosts the documentation of the SmartCGMS software architecture and all of its components.

The documentation is being updated to acommodate the recent improvements. Please, be patient, we are working on it...

Error Metric Filter

When producing any time series such as glucose-level prediction or performing a glucose-level control, we need to quantify how well we do - i.e.; how much we differ from a desired data series. With prediction, we need to quantify how much is the prediction different from the referenced, measured glucose levels. With glucose-level control, we need to quantify how much we differ from a desired glucose level, or how much time we spent outside a desired glucose-level range. For such a quantification, we use an error metric.

SmartCGMS offers two filters to compute the metric. First one, Signal Error filter, accumulates all differences between measured(error-biased) and referenced signals/time series. Then, it uses a post-processing to compute the resulting metric as precisely as possible. This filter is useful for processing on devices with no memory nor computational constraints. For example, it is good when devising and testing metric, or when computing some statistics about the patient.

To accelerate computationally intensive tasks and/or to conform low-power device constraints, SmartCGMS also provides Fast Signal Error filter. While this filter provides less functionality and supports only the following metrics, it has minimalistic, constant memory requirements and trades execution speed for less precision as it uses linear interpolation only. For interpolation, Signal Error filter uses the IApproximator to provide more elaborate interpolation, e.g.; Akima spline.

Fast Signal Error supported metrics:

  • Average
  • Average plus Standard Deviation

The fast signal error filter does not use the metric entites, but rather reimplements the calculation in its own code. This concept was introduced to speed up the calculations when using commonly used metrics with a simple calculation.


  • Description (string) - a string description of the error values; this is displayed in GUI and written to the CSV file
  • Reference_Signal (GUID) - a GUID of a reference signal
  • Error_Signal (GUID) - a GUID of an error signal
  • Metric (GUID) - a GUID of a metric to calculate
  • Levels_Required (integer) - metric parameter - how many levels are required to calculate the metric value
  • Relative_Error (boolean) - metric parameter - use relative error instead of absolute
  • Squared_Diff (boolean) - metric parameter - use squared differences for metric calculation
  • Prefer_More_Levels (boolean) - metric parameter - prefer more levels over less, when calculating metric value

Error metric

  • Metric_Threshold (double) - metric parameter - a threshold for given metric; this is a specific parameter for every metric, may be ignored
  • Emit_Metric_As_Signal (boolean) - emit calculated metric value as a signal and send it through the chain
  • Emit_Last_Value_Only (boolean) - if the Emit_Metric_As_Signal is set to true, this causes the filter to emit just the last value of the metric upon segment end or shutdown
  • Output_CSV_file (string) - if set, the filter summarizes the errors into a CSV file; please note, that this option is active even during the parameters optimalization and may potentially slow down the solving process

Fast error metric

There are no specific configuration parameters for fast error metric filter

Supported interfaces

  • scgms::ISignal_Error_Inspection (both filters)

General function

Both filters shares a similar interface for metric calculation, but differs in a way they do it. The error metric filter favors calculation and structured approach, the fast error metric filter favors performance and constant memory requirements.

Error metric

The error metric filter instantiates a metric entity. When a pair of matching signals (reference and error) comes through the chain, it calls the Accumulate method of the metric object to accumulate the differences between the signals.

The filter can be configured to emit the metric value as a signal by the Emit_Metric_As_Signal parameter. If set, every metric value calculated will be send through the filter chain as a level device event with the signal_error::metric_signal_id signal ID. Optionally, sending just the last value might be requested using the Emit_Last_Value_Only parameter - if set to true, the metric value is send through the chain upon receiving a Time_Segment_End or Shut_Down device event. In the former case, just the single segment metric value is sent. The latter case finalizes all segments and sends their respective metric values through the chain as separate device events.

Fast error metric

The fast signal error metric filter on the other hand does not initialize a metric entity. It shares the metric configuration to reimplement parts of the calculation in its own code. The configured Metric GUID is used to select the internal reimplementation of the selected metric.

Additionally, this filter does not store all the differences, but compresses them in a single value, depending on the selected metric. For example, stream calculation of an average difference metric is perfectly possible without the knowledge of all prior differences.

This filter does not support all the implemented metrics, as stated above. It sacrifices the generalization in favor of performance and constant memory requirements.