2

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

问题

我有一组 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);
      }
    }

我将不胜感激任何类型的帮助或指示在哪里寻找。

4

3 回答 3

1

我认为它实际上更容易:

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

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

于 2018-03-08T16:42:20.137 回答
0

到目前为止,根据我从@jonas W 采用的内容,修复了时间和转换为 bpm(心率)

/**
   * Returns an Map of elapsed time and HR from RR data
   * @param rr
   * @param {number} sampleRateInSeconds
   * @return {number[]}
   */
  private static getHRFromRR(rr, sampleRateInSeconds?: number, smoothByAvg?: boolean): Map<number, number> {
    sampleRateInSeconds = sampleRateInSeconds || 10; // Use any second number
    const limit = sampleRateInSeconds * 1000;
    let totalTime = 0;
    let rrBuffer = [];
    return rr.reduce((hr, d) => {
      // add it to the buffer
      rrBuffer.push(d);
      // Increase total time
      totalTime += d;
      // Check if buffer is full
      const time = rrBuffer.reduce((a, b) => a + b, 0); // gets the sum of the buffer [300+600 etc]
      if (time >= limit) {
        if (smoothByAvg) {
          // @todo implement
        } else {
          hr.set(totalTime, rrBuffer.length * 60 / (time / 1000)); // convert to bpm
        }
        rrBuffer = [];
      }
      return hr;
    }, new Map());
  }
于 2018-03-08T22:26:11.027 回答
0

经过大量时间测试等正确答案是:

/** 
   * Converts the RR array to HR instantaneus (what user sees) 
   * @param rrData 
   * @return {any} 
   */ 
  public static convertRRtoHR(rrData): Map<number, number> { 
    let totalTime = 0; 
    return rrData.reduce((hrDataMap: Map<number, number>, rr) => { 
      totalTime += rr; 
      hrDataMap.set(totalTime, Math.round(60000 / rr)); 
      return hrDataMap; 
    }, new Map()); 
  } 
于 2018-03-11T12:54:29.887 回答