Chi*_*tri 6 bluetooth heartbeat ios
我正在开发一个应用程序,其中我必须读取一分钟的心跳并从中计算心率变异性。
为了读取心跳,我使用带子(极地)
为了计算 HRV,我浏览了以下链接,但没有任何帮助:
请提供我可以从 HR 中获取 HRV(RMSSD) 的公式,获取 HR 的持续时间为一分钟。
任何帮助,将不胜感激..
编辑:
我通过以下代码获得了 RR 值:
- (void) updateWithHRMData:(NSData *)datas {
const uint8_t *reportData = [datas bytes];
uint16_t bpm = 0;
uint16_t bpm2 = 0;
if ((reportData[0] & 0x04) == 0)
{
NSLog(@"%@", @"Data are not present");
}
else
{
bpm = CFSwapInt16LittleToHost(*(uint16_t *)(&reportData[2]));
bpm2 = CFSwapInt16LittleToHost(*(uint16_t *)(&reportData[4]));
if (bpm != 0 || bpm2 != 0) {
NSLog(@"%u", bpm);
if (bpm2 != 0) {
NSLog(@"%u", bpm2);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我得到的 RR 值如下:666,636,645 .... 等,但是当我使用HRV +应用程序并通过电子邮件导出 RR 值时,它会显示 0.785,0.734,0.724 等值。如果我用我的 RR 值进行计算以下公式:
均方根平均偏差 =
它给了我完全错误的结果。
请帮忙。
编辑:
//==================RR
if ((reportData[0] & 0x04) == 0)
{
NSLog(@"%@", @"Data are not present");
}
else
{
uint16_t rr2 = CFSwapInt16LittleToHost(*(uint16_t *)(&reportData[2]));
RR = CFSwapInt16LittleToHost(*(uint16_t *)(&reportData[4]));
//sometimes two values of RR may found so there are two RR: RR and rr2 which added in array and all calculation goes after one minute
if (rr2 > 0 || RR > 0) {
NSLog(@"RR2 %u", rr2);
if (rr2>0) {
[RRArray addObject:[NSNumber numberWithInt:rr2]];
}
if (RR != 0) {
NSLog(@"RR %u", RR);
[RRArray addObject:[NSNumber numberWithInt:RR]];
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
您需要执行第一篇链接文章第 2.2.1 节中描述的统计计算。
您无法根据心率计算 HRV - 您需要使用 RR 间隔。
您需要检查传感器返回的数据,看看是否设置了标志字节的第 4 位 - 这表明存在 RR 数据。然后,您可以将 RR 数据读入数组,将 16 位样本数据转换为NSNumbers 。您可以改编教程中的代码,将 16 位心跳值转换为 int。
一旦您收集了足够的样本(我不确定 1 分钟的样本在统计上是否有效,但我不是统计学家),您就可以进行分析。
THB 将是阵列中 RR 间隔的数量
MRR 或 I(BAR) 您可以计算如下 -
float rrTotal=0;
for (int i=1;i<[rrIntervals count]; i++) {
rrTotal+=[[rrIntervals objectAtIndex:i] intValue];
}
float mrr = rrTotal/([rrIntervals count]-1);
Run Code Online (Sandbox Code Playgroud)
SDNN(即您的 HRV)计算如下 -
float sdnnTotal = 0;
for (int i=1;i<[rrIntervals count]; i++) {
sdnTotal+=pow( [[rrIntervals objectAtIndex:i] intValue] - mrr,2) ;
}
float sdnn = sqrt(sdnTotal/([rrIntervals count]-1));
Run Code Online (Sandbox Code Playgroud)
当您向数组添加更多数据时,您可以继续重新计算 HRV。
| 归档时间: |
|
| 查看次数: |
11257 次 |
| 最近记录: |