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 6 seconds the algorithm is learning, if no 5 RR-intervals are found in the signal
5 RR-intervals are not found, the training is repeated. Further work with the library is iterative (adding new data, calculating indicators).
Initialization
Determine the basic parameters
- Raw signal sampling frequency. Integer type. The allowed values are 250 or 1000.
- Data processing window size. Integer type. Valid values of sampling_rate / 4 or sampling_rate / 2.
- Number of windows to calculate SI. Integer type. Allowable values [20...50].
- The averaging parameter of the IN calculation. Default value is 6.
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.
ReactNative (JavaScript)
let sampling_rate = 250;
let data_window = sampling_rate / 2;
let nwins_for_pressure_index = 30;
let math = new EcgMath(sampling_rate, data_window, nwins_for_pressure_index)
let pressureIndexAverage = 6;
math.setPressureAverage(pressureIndexAverage);
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
ReactNative (JavaScript)
var samples: number[] = new Array(25)
var samples: number[] = new Array(100)
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.
ReactNative (JavaScript)
if(math.isInitialSignalCorrupted){
}
Work with the library
ReactNative (JavaScript)
math.pushData(samples)
ReactNative (JavaScript)
if(math.isRRdetected){
console.log(math.RR)
console.log(math.HR)
console.log(math.PressureIndex)
console.log(math.Moda)
console.log(math.AmplModa)
console.log(math.VariationDist)
math.setRRchecked()
}
Finishing work with the library:
ReactNative (JavaScript)
math.clearData()
math.free()