Heart Rate R-to R value

This is a discussion on Heart Rate R-to R value within the C Programming forums, part of the General Programming Boards category; Hi Y'all What I am trying to do is create a program to take to colums of data in a ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    8

    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. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    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. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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[50]; //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[0], and int bp[0], 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).
    Last edited by Adak; 11-16-2010 at 06:55 AM.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    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[300];  //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[50]; // these must be floats 
    	float b[50];
    	float max;
    	float width;
    	float threshold;
    	float blank;
    	float beattime;
    
    
    	strcpy(fn,argv[1]); // 1 means the first file not argv[2]
    	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. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    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. #7
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    I want it to tell me that beattime1=5, and beattime 2=12

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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. #9
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    I would look for the first value above the threshold which in this case would be 3

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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. #11
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    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. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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. #13
    Registered User
    Join Date
    Nov 2010
    Posts
    8
    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 subscribe to a feed

Similar Threads

  1. Need Help Fast Please
    By SupraMan in forum C Programming
    Replies: 4
    Last Post: 11-08-2010, 11:10 AM
  2. Please help me as fast as possible
    By Xbox999 in forum C Programming
    Replies: 5
    Last Post: 11-30-2009, 05:53 PM
  3. Simple Blackjack Program
    By saber1357 in forum C Programming
    Replies: 1
    Last Post: 03-28-2009, 03:19 PM
  4. Producing a "beeep!" as simply as possible
    By mutandis in forum C Programming
    Replies: 10
    Last Post: 12-13-2008, 12:30 AM
  5. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 11:24 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21