I am working on application in which I have to read heart beat till one minute and calculate heart rate variability from it.
for reading heart beat I am using strap(Polar)
Heart beat reading code I have used from link
for calculating HRV I gone through following links but nothing helps:
Please provide formula from which i can get HRV(RMSSD) from HR and duration to get HR is one minute.
Any help would be appreciated..
EDIT:
I have got RR value with following code:
- (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);
}
}
}
}
My Question is I am getting RR values like:666,636,645 .... etc
but when I use HRV +
application and export RR values via email it shows values like 0.785,0.734,0.724 etc.. and if I do calculation with RR values of mine with following formula:
RMSSD =
It gives me completely wrong result.
Please help.
EDIT:
//==================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]];
}
}
}
}
NSLog(@"%@",datas)
- I need to see the raw data of the value from the sensor. I suspect your decoding code is incorrect. You need to check bit 3 to see if energy expended is present and there may be multiple RR values per packet. Also from reading the paper it seems that SSDN is HRV, not RMSSD. Also note that RR values are in 1/1024ths of a second in the data packet. – Crummy