我正在进行申请,我必须阅读心跳至一分钟,并从中计算心率变异性。
阅读心跳我正在使用表带(Polar)
Heart beat reading code I have used from link
用于计算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);
}
}
}
}
我的问题是我得到的RR值如:666,636,645 ....等
但是当我使用HRV +
应用程序并通过电子邮件导出RR值时,它显示的值如0.785,0.734,0.724等。如果我使用以下公式计算我的RR值:
RMSSD =
这给了我完全错误的结果。
请帮忙。
修改
//==================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]];
}
}
}
}
答案 0 :(得分:2)
您需要执行第一个链接文章的第2.2.1节中描述的统计计算。
您无法根据心率计算HRV - 您需要使用RR间隔。
您需要检查传感器返回的数据,以查看是否设置了标志字节的第4位 - 这表示存在RR数据。然后,您可以将RR数据读入数组,将16位样本数据转换为NSNumber
s。您可以调整将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);
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));
在向阵列添加更多数据时,您可以不断重新计算HRV。