javascript - 如何在 Javascript 中将 RR (IBI) 数据转换为心率

标签 javascript heartrate

在做了一些研究之后,我决定在这里寻求建议,因为我不确定如何进行。

问题:

我有一组 RR(IBI)数据

示例:[679, 686, 650...]

如何将其转换为心率?

我的研究:

我的方法当然是有缺陷的:

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);
      }
    }

我将不胜感激任何有关查找位置的帮助或指示。

最佳答案

我认为它实际上更容易:

 const hearbeats = [];

 let beatCount = 0;
 let time = 0;
 for(const ibi of ibis){
   time += ibi;
   beatCount++;
   if(time > 60 * 1000){
     hearbeats.push(beatCount);
     beatCount = time = 0;
   }
 }

(免责声明:我不知道我在说什么)

关于javascript - 如何在 Javascript 中将 RR (IBI) 数据转换为心率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49177961/

相关文章:

javascript - .push 不是函数,使用 Javascript 和 localstorage

javascript - 将弹出窗口中的无序列表填充到主窗口中 - javascript

javascript - 如何使用另一个 JS 数组替换 JS 数组属性值

android - 是否可以在我的应用程序中从 Androidwatch 获取心率更新?

ios - 在 HealthKit 中查询 heartRateVariabilitySDNN?

javascript - 解释/解析来自蓝牙心率监测器(Cordova)的数据

javascript - 当我使用 ajax 加载/拉取内容时,如何将 CSS 编码为 "change"?

python - 无法通过蓝牙读取心率服务

swift - 在 Series 5 Watch 和 Watch OS6 上使用 `HKAnchoredObjectQuery` 返回心率值时出现问题

javascript - 如何将 JSON 对象字符串转换为 Javascript 数组