Configuration

Configuration

You can use the SDK with the default configuration or customize it to your needs.

You can visit the Web Playground at playground.shen.ai (opens in a new tab) to see all configuration options in context (you'll need an Web API key to access the playground).

Initializing the SDK without providing a custom configuration will use the default one - a one-minute strict-precision measurement displaying all metrics with full user interface. You can customize the behaviour and appearance of the SDK by providing a custom configuration object at initialization or by changing the configuration properties at runtime.

Measurement settings

OperatingMode

You can control the SDK behaviour by setting the Operating Mode:

  • Positioning: the SDK will track the user's face position and give feedback to the user to keep the face in a proper position for starting the measurement. This is the default mode after the SDK is initialized.
  • Measure: the SDK will start the measurement as soon as the face is in a proper position.
  • SystemOverloaded: the SDK cannot keep up with the computations, the measurement is stopped and few seconds of rest are required to start a new measurement. This is a read-only mode, you cannot set it yourself neither can you unset it when it is active.

Clicking on the START/STOP button in the embedded user interface will switch between Positioning and Measure modes. You can also switch between those modes programmatically or start the SDK in the Measure mode by providing a custom configuration object at initialization:

enum OperatingMode {
  positioning,
  measure,
  systemOverloaded
}
 
var mode = await ShenaiSdk.getOperatingMode();
 
ShenaiSdk.setOperatingMode(OperatingMode.measure);
ShenaiSdk.setOperatingMode(OperatingMode.positioning);


PrecisionMode

By default, the SDK will use the strict precision mode, which will only return results if the signal quality is high enough (the threshold is determined by tests on MX Labs' internal datasets with high-quality ECG-based Ground Truth). You may choose to use the relaxed precision mode, which will return results even if the signal quality is low.

  • Strict: the SDK will only return results if the signal quality is high enough. This is the default mode after the SDK is initialized.
  • Relaxed: the SDK will return results on a best-effort basis. The results obtained in this mode should not be relied upon and represent the best guess given the current conditions.

enum PrecisionMode {
  strict,
  relaxed,
}
 
var mode = await ShenaiSdk.getPrecisionMode();
 
ShenaiSdk.setPrecisionMode(PrecisionMode.strict);
ShenaiSdk.setPrecisionMode(PrecisionMode.relaxed);


MeasurementPreset

The following measurement presets are available:

  • OneMinuteHrHrvBr: a one-minute measurement that returns Heart Rate, Heart Rate Variability and Breathing Rate. This is the default preset after the SDK is initialized.
  • OneMinuteBetaMetrics: a one-minute measurement that includes metrics that are currently in beta - Blood Pressure and Cardiac Stress.
  • InfiniteHr: an infinite measurement that provides continuous Heart Rate without any end condition.
  • InfiniteMetrics: an infinite measurement that provides multiple continuous metrics without any end condition (currently available metrics are Heart Rate, Heart Rate Variability and Cardiac Stress) .

In addition, the following unvalidated presets are available which allow for shorter measurement times:

  • FourtyFiveSecondsUnvalidated: a 45 seconds measurement that includes all metrics
  • ThirtySecondsUnvalidated: a 30 seconds measurement that includes all metrics
⚠️

Please be aware that results from shorter measurement times have not been validated and might result in less accurate or less reliable metrics. This is particularly relevant for Heart Rate Variability (HRV) and Cardiac Stress computations. These metrics depend on the analysis of variations in inter-beat intervals, which requires capturing a sufficient number of heartbeats to provide a reliable picture of autonomic nervous system activity. Shorter measurements might not provide enough data, leading to potential misinterpretations. Additionally, the precision of Blood Pressure computations may also be affected by shorter measurement times. For meaningful and reliable computations of HRV, Cardiac Stress, and Blood Pressure, longer measurement times are strongly recommended.

enum MeasurementPreset {
  oneMinuteHrHrvBr,
  oneMinuteBetaMetrics,
  infiniteHr,
  infiniteMetrics,
  fourtyFiveSecondsUnvalidated,
  thirtySecondsUnvalidated,
  custom,
}
 
var preset = await ShenaiSdk.getMeasurementPreset();
 
ShenaiSdk.setMeasurementPreset(MeasurementPreset.oneMinuteHrHrvBr);
ShenaiSdk.setMeasurementPreset(MeasurementPreset.oneMinuteBetaMetrics);
ShenaiSdk.setMeasurementPreset(MeasurementPreset.infiniteHr);
ShenaiSdk.setMeasurementPreset(MeasurementPreset.infiniteMetrics);
ShenaiSdk.setMeasurementPreset(MeasurementPreset.fourtyFiveSecondsUnvalidated);
ShenaiSdk.setMeasurementPreset(MeasurementPreset.thirtySecondsUnvalidated);


Custom measurement configuration

If the default presets don't fit your needs, you can provide the SDK with a custom measurement configuration. The custom configuration makes it possible to determine which metrics should be displayed to the user in the embedded UI. It also allows you to set the measurement duration and period of the momentary metrics.

  • instantMetrics - a list of metrics that will be displayed to the user in the UI visible during the measurement
  • summaryMetrics - a list of metrics that will be displayed to the user in the summary UI visible after the measurement
  • durationSeconds - the duration of the measurement in seconds. The default value is 60 seconds. Accepted values are between 15 and 120 seconds.
  • infiniteMeasurement - if set to true, the measurement will continue indefinitely until the user stops it. Progress bar is not shown and displayed realtime metrics are limited to HR, HRV and Cardiac Stress. The default value is false.
  • realtimeHrPeriodSeconds - determines the period in time from which momentary heart rate is calculated. The default value is 10 seconds. Accepted values are between 4 and 60 seconds.
  • realtimeHrvPeriodSeconds (only applies in infinite mode) - determines the period in time from which momentary heart rate variability is calculated. The default value is 30 seconds. Accepted values are between 10 and 60 seconds.
  • realtimeCardiacStressPeriodSeconds (only applies in infinite mode) - determines the period in time from which momentary cardiac stress is calculated. The default value is 30 seconds. Accepted values are between 10 and 60 seconds.

class CustomMeasurementConfig {
  double? durationSeconds;
  bool? infiniteMeasurement;
  List<Metric>? instantMetrics;
  List<Metric>? summaryMetrics;
  double? realtimeHrPeriodSeconds;
  double? realtimeHrvPeriodSeconds;
  double? realtimeCardiacStressPeriodSeconds;
}
 
ShenaiSdk.setCustomMeasurementConfig(config);

💡

Note that if Blood Pressure is not included in either instant or summary metrics, the SDK will not compute it and it will not be available via the getMeasurementResults() method.


CameraMode

The SDK can be in one of the four camera modes:

  • Off: the camera is turned off.
  • FacingUser: the user-facing camera of the device is used (such as the front camera on a phone). This is the default mode after the SDK is initialized.
  • FacingEnvironment: the outside-facing camera of the device is used (such as the back camera on a phone).
  • DeviceId: one of the available cameras is used, selected by device ID (available only on Desktop Web).

enum CameraMode {
  off,
  facingUser,
  facingEnvironment,
}
 
var mode = await ShenaiSdk.getCameraMode();
 
ShenaiSdk.setCameraMode(CameraMode.off);
ShenaiSdk.setCameraMode(CameraMode.facingUser);
ShenaiSdk.setCameraMode(CameraMode.facingEnvironment);

Preview settings

You can customize the SDK's embedded UI to suit your use case with the settings below.

The easiest way to understand the settings and color themes is in the Web Playground at playground.shen.ai (opens in a new tab) (you'll need an Web API key to access the playground).

User Onboarding

User Onboarding offers a guided experience for users to understand and execute measurements effectively. Through a series of screens with clear graphics and instructions, users learn how the measurement process works and how to perform it accurately. This feature ensures a smooth introduction to the technology, enabling users to grasp its functionalities swiftly for precise measurements.

At SDK initialization, you can choose the preferred onboarding mode (onboardingMode in InitializationSettings). There are three options:

  • Hidden: user onboarding is never shown
  • ShowOnce: user onboarding is shown once for a user (this is the default option)
  • ShowAlways: user onboarding is shown on every initialization

enum OnboardingMode {
  hidden,
  showOnce,
  showAlways,
}

Translation

The SDK's embedded UI can be displayed in a different language instead of the default English. You can use the setLanguage method to change the language of the SDK's embedded UI. The language is set by providing a two-letter language code (ISO 639-1).

You can see the currently available languages in the Web Playground (opens in a new tab).

Note that some languages are machine-translated to test the feature. If you would like to add a new language or improve the existing translation, please contact us.

ShenaiSdk.setLanguage("es");

UI elements

You can customize the user feedback interface by changing the following settings:

  • ShowUserInterface controls whether the user feedback interface is shown. If set to false, the SDK will not display any interactive elements such as the START/STOP button or the results section.
  • ShowFacePositioningOverlay controls whether the face positioning overlay is shown. If set to false, the SDK will not display the overlay that guides the user to position their face correctly.
  • ShowVisualWarnings controls whether visual warnings are shown. If set to false, the SDK will not display any visual warnings such as the red bulb that indicates that the signal quality is low.
  • EnableCameraSwap controls whether the user can switch between the front and back camera. If set to false, the user will not be able to switch between the front and back camera.
  • ShowFaceMask controls whether the face mask visualization is shown. If set to false, the SDK will not display the 3d face mask visualization.
  • ShowBloodFlow controls whether the blood flow visualization is shown. If set to false, the SDK will not display the blood flow visualization as an overlay on the user's face.
  • EnableStartAfterSuccess controls whether the START button is available after a successful measurement. If set to false, the START button will not be available after a successful measurement until the SDK is reinitialized.

ShenaiSdk.setShowUserInterface(true);
ShenaiSdk.getShowUserInterface();
 
ShenaiSdk.setShowFacePositioningOverlay(true);
ShenaiSdk.getShowFacePositioningOverlay();
 
ShenaiSdk.setShowVisualWarnings(true);
ShenaiSdk.getShowVisualWarnings();
 
ShenaiSdk.setEnableCameraSwap(true);
ShenaiSdk.getEnableCameraSwap();
 
ShenaiSdk.setShowFaceMask(true);
ShenaiSdk.getShowFaceMask();
 
ShenaiSdk.setShowBloodFlow(true);
ShenaiSdk.getShowBloodFlow();
 
ShenaiSdk.setEnableStartAfterSuccess(true);
ShenaiSdk.getEnableStartAfterSuccess();

Color theme

The color theme of the SDK's embedded UI can be changed by specifying alternative colors:

  • themeColor - color of the START/STOP button text and the progress bar
  • textColor - color of the text in the results section
  • backgroundColor - color of the background of the results section and around the UI
  • tileColor - color of the tiles in the results section, the face positioning overlay, START/STOP button background, 'swap camera' button and 'info' button

class CustomColorTheme {
  String? themeColor;
  String? textColor;
  String? backgroundColor;
  String? tileColor;
}
 
ShenaiSdk.setCustomColorTheme(theme);

Developer settings

The following settings are intended to be used by developers and shouldn't be exposed to the end user.

Measurement recording

The SDK can record the measurement video and send it to MX Labs for analysis. This is useful for debugging failure cases and registering edge cases. The recording is not saved on the device and is only available to MX Labs.

Whenever recording mode is active, the SDK will display a red dot in the top right corner of the preview. For debugging, it's also possible to activate recording mode by tapping three times on the Heart Rate tile.

One minute of recorded video is approximately 200 MB in size (lossless compression is used).

Shenaisdk.setRecordingEnabled(true);
Shenaisdk.getRecordingEnabled();