after doing a some research I reached the point that I decided to ask here for advice as I am not sure how to proceeed.
The problem:
I have an array of RR (IBI) data
Example: [679, 686, 650...]
How can I convert this to heart rate?
My research:
- http://www.meddean.luc.edu/lumen/meded/medicine/skills/ekg/les1prnt.htm
- Vairous libs on github but none on JS or in a way I could port to JS -
My approach which of course is defective:
for (const ibiInMilliseconds of eventJSONObject.DeviceLog["R-R"].Data) {
ibiBuffer.push(ibiInMilliseconds);
const ibiBufferTotal = ibiBuffer.reduce((a, b) => a + b, 0);
// If adding the ibi to the start of the activity is greater or equal to 2.5 second then empty the buffer there
if ((lastDate.getTime() + ibiBufferTotal) >= lastDate.getTime() + 2500) {
const average = ibiBuffer.reduce((total, ibi) => {
return total + ibi;
}) / ibiBuffer.length;
const avg = 1000 * 60 / average;
// I save this avg to a 1s list but it's very error prone
ibiBuffer = [];
lastDate = new Date(lastDate.getTime() + ibiBufferTotal);
}
}
I would appreciate any kind of help or pointers as where to look.