callibri_ecg 1.0.3 copy "callibri_ecg: ^1.0.3" to clipboard
callibri_ecg: ^1.0.3 copied to clipboard

Flutter wrapper for CallibriECG library

Mathematical library for working with ECG data from the Callibri sensor. #

The main functionality is the calculation of cardio-interval lengths, heart rate and Stress Index (SI).

During the first 10 seconds, the algorithm is trained if it is not found in the signal. 5 RR intervals, the training is repeated. In the future, work with the library takes place iteratively (adding new data, calculating indicators).

Initialization #

Determine the basic parameters #

  1. Raw signal sampling frequency. Integer type. The allowed values are 250 or 1000.
  2. Data processing window size. Integer type. Valid values of sampling_rate / 4 or sampling_rate / 2.
  3. Number of windows to calculate SI. Integer type. Allowable values [20...50].
  4. The averaging parameter of the IN calculation. Default value is 6.
  5. Network frequency. Integer type. Default value is 50Hz. Available values 50Hz or 60Hz.

Creating a library instance #

Firstly you need to determine lybrary parameters and then put them to library. Tne next step is initialize the filters. In the current version the filters are built-in and clearly defined: Butterworth 2nd order BandPass 5_15 Hz.

You can initialize averaging for SI calculation. It is optional value.

// 1. Raw signal sampling frequency
int samplingRate = 250;
// 2. Data processing window size
int dataWindow = samplingRate / 2;
// 3. Number of windows to calculate SI
int nwinsForPressureIndex = 30;

final math = CallibriEcgMath(samplingRate, dataWindow, nWinsForPressureIndex);

// optional
// 4. The averaging parameter of the IN calculation. Default value is 6.
int pressureIndexAverage = 6;
math.setPressureAverage(pressureIndexAverage);

// optional
// 5. Your network frequency: 50Hz or 60Hz
math.setNetworkFrequency(NetworkFrequency.hz50);

Initializing a data array for transfer to the library: #

The size of the transmitted array has to be of a certain length:

  • 25 values for a signal frequency of 250 Hz
  • 100 values for a signal frequency of 1000 Hz
final rawData = List<double>.generate(25, (i) => i);
// or
final rawData = List<double>.generate(100, (i) => i);

Optional functions (not necessary for the library to work) #

Check for initial signal corruption. This method should be used if you want to detect and notify of a distorted signal explicitly.

if (math.isInitialSignalCorrupted){
    // Signal corrupted!!!
}

Work with the library #

  1. Adding and process data:
math.pushAndProcess(samples)
  1. Getting the results:
if(math.isRRDetected){
  // check for a new peak in the signal
  // RR-interval length
  double rr = math.rr;
  // last RP index
  int rpIdx = math.lastRPeakIndex;
  // HR     
  double hr = math.hr;
  // SI
  double pi = math.pressureIndex;
  // Moda
  double moda = math.moda;
  // Amplitude of mode
  double amplModa = math.amplitudeModa;
  // Variation range
  double variationDist = math.variationDistance;
  math.checkRR();
}

Finishing work with the library: #

math.dispose();