# Thread: Heart Rate R-to R value

1. ## Heart Rate R-to R value

Hi Y'all
What I am trying to do is create a program to take to colums of data in a in.txt file, the first colum being time and the second being the height of the graph of bllod pressure. So far I have identified the following steps that I need to do

First I need to identify a threshold so that it does not have to search through every number
Once the number is above that threshold I need to search for ____width of time
Next I need to find the local max
Now I need to associate the local max with the time value
Now I need to go back and move on to another search of the data
(here I could create a loop I think storing the data of max as a diffrent max1, max 2)
Outside of the looop I need another one to

Take time of max1-max2 .
Now find 60/difference1...= HR
Print out heart rates

I am having issues making this happen, any info or clues to the right track would be helpful!

So far I can only find the max within data and can't find only a threshold or move over to the next curve. 2. A general description - and Welcome to the forum, BioMedC - but you're raising my blood pressure, here.  To make a program, you need really detailed info about whatever the task is you want the program to do. You don't need to deal with the details when you actually start coding up the design of the program, (you want to put most of them off at first), but you need to have that insightful knowledge of the task.

Can you show us an example of the input you would be using? And what the output you want, would be?

Is there an equation you can or will be using? Maybe a look up table, or ...??

After the input, I'm not following how you will compute the output you want, and where you want it to go. 3. The input will be like this

0 56
0.10 68
0.15 79
0.26 144
0.46 68
and so on continuing up and down like a blood pressure graph, it looks like a heart beat

there is no equation given, I have to create a nested while loop using a threshold and a time 4. Keep up with this thread, especially with KBriggs post - he seems to know a something about this. Check out his link to Wikipedia's entry, of course.

Threshold and Blank Algorithm

Heart rate graph? I seem to vaguely recall something about PQRS&T elements of that. (After all these decades, that's impressive, imo)

As a layman looking at this, I'd read about 50 rows of data into an array, and find the highest number in bp reading which also had at least 3 other readings within say, 10% of it. That would serve as the sample, to find the threshold.

IOW, the highest reading, but rejecting an erroneous "flyer" bp number, if present. The 10% figure may need tweaking, (that number should eventually settle to become your threshold), but some % or bp number needs to be chosen. Now use that to process your array of data, and continue reading the rest of the file, and process that data, as well.

Two ways to do that:

1) Use one array of a struct:
Code:
```struct data {
float time1;  //time is a reserved C word, so don't use that
int bp;
}

//then in

int main() {
struct data dat; //creates array of 50 data structs

which can be accessed via the dot operator: dat[i].time1, dat[i].bp```
or use "parallel" arrays, one float, and one integer, and use the index of the array, to keep the data relationship:

float time1, and int bp, were read from the same row of data.

After you have sampled the data to establish your threshold, you don't need to use the array. Just continue reading the file (a while loop is probably the most convenient way to do that). 5. okay this is what i have so far but it keeps giving me the wrong value
insert
Code:
```#include<stdio.h>
#include <string.h>

FILE *fp;   //*=multiplication, in this case special variable called pointer
char fn;  //a character array

int main(int argc, char *argv[])
{
int i; //this is a counter
int n; // this is the number of points THESE MUST BE INTEGERS, data

float a; // these must be floats
float b;
float max;
float width;
float threshold;
float blank;
float beattime;

strcpy(fn,argv); // 1 means the first file not argv
fp = fopen(fn,"r"); // r means open readab
i = 0;
threshold = 2 ;
blank = 1;

while(b[i] < threshold) {

i++ ;

}```
beattime = a[i];

printf("The fdimum is %f\n", beattime); // print to terminal

//then do it again

fclose(fp); // close the file

return 0;
} 6. 1 0
2 1
3 2
4 3
5 4
6 3
7 2
8 1
9 0
10 1
11 2
12 3
13 4
14 3
15 2
16 1
17 0

for this data 7. I want it to tell me that beattime1=5, and beattime 2=12 8. I know there's a lot of "stuff" in a program, but I'd suggest putting all the details aside until AFTER you get the logic down.

For instance, given the data you posted, how would YOU find that beattime1 and beattime equal 5 and 12, respectively? 9. I would look for the first value above the threshold which in this case would be 3 10. Is the threshold then, the value one notch lower than the highest number in the data?

What about beattime2, the 12? How did you find that number from the data? 11. I set the threshold at 3 so each time the data breaks from below the threshold to above it needs to record that number. Then from this i can calculate r to r 12. You didn't answer my questions. You told me HOW you use the threshold value. I want to know:

1) How did you determine the threshold value, from that data? Is it the next to the highest number, in the second column of the data?

If you want to get this program done, you need to follow the bouncing ball, a bit more closely. I should not need to ask you questions about these basics, and then have to repeat them. 13. I am sorry, please don't be rude though.."should not need to ask you questions about these basics, and then have to repeat them." ...... I finished the program in a nested while loop and it works so thank you for trying Popular pages Recent additions algorithm, c programming, heart rate, threshold, while loop 