TUM-Logo

libRASCH

 

Home
 

General

About libRASCH/News
Design
Screen shots
Sample programs (with source code)
License
 

Download

libRASCH
Tools
 

Documentation

User
Developer
 

Resources

Mailing list
Supported Formats
Plugins
Status
Links
 
Contact
About this site
 
Last updated
Tue Mar 27 23:03:48 2007

C-Version of process

Sourcecode

#include <stdio.h>
#include <ra.h>

int main(int argc, char *argv[])
{
    ra_handle ra;
    struct ra_info *inf;
    meas_handle meas;
    eval_handle eval;
    plugin_handle pl;
    struct proc_info *pi;

    /* initialize libRASCH */
    ra = ra_lib_init();
    if (ra == NULL)
    {
        printf("error initializing libRASCH\n");
        return -1;
    }

    /* open measurement */
    meas = ra_meas_open(ra, argv[1], 0);
    if (meas == NULL)
    {
        printf("can't open measurement %s\n", argv[1]);
        return -1;
    }

    /* get default evaluation */
    eval = ra_eval_get_def(meas);
    if (eval == NULL)
    {
        printf("no evaluation in measurement %s\n", argv[1]);
        return -1;
    }

    /* get plugin-handle for hrv-plugin */
    pl = ra_plugin_get_by_name(ra, "hrv", 0);
    if (pl == NULL)
    {
        printf("can't find plugin 'hrv'\n");
        return -1;
    }

    /* calculate hrv-values using the hrv-plugin */
    pi = (struct proc_info *)ra_proc_get(pl);
    pi->mh = meas;
    pi->rh = ra_rec_get_first(meas, 0);
    pi->eh = eval;
    if (ra_proc_do(pi) == 0)
    {
        long num_results, l;
        value_handle vh;

        /* get number of results */
        vh = ra_value_malloc();
        if (ra_info_get(pl, RA_INFO_PL_NUM_RESULTS_L, vh) != 0)
        {
            printf("no results\n");
            return -1;
        }
        num_results = ra_value_get_long(vh);

        for (l = 0; l < num_results; l++)
        {
            char out[200], t[100];

            /* set number of result in which we are interested */
            ra_value_set_number(vh, l);

            /* test if result is a default value (some
               non-default results are arrays which we skip in
               this example) */
            ra_info_get(pl, RA_INFO_PL_RES_DEFAULT_L, vh);
            if (ra_value_get_long(vh) == 0)
                continue;

            out[0] = '\0';
            if (ra_info_get(pl, RA_INFO_PL_RES_NAME_C, vh) == 0)
            {
                strcpy(t, ra_value_get_string(vh));
                strcat(out, t);
            }
            if (ra_info_get(pl, RA_INFO_PL_RES_DESC_C, vh) == 0)
            {
                sprintf(t, " (%s)", ra_value_get_string(vh));
                strcat(out, t);
            }
            if (ra_proc_get_result(pi, vh) == 0)
            {
                sprintf(t, ": %lf", ra_value_get_double(vh));
                strcat(out, t);
            }

            printf("%s\n", out);
        }

        ra_value_free(vh);
    }

    /* close */
    ra_proc_free(pi);
    ra_meas_close(meas);
    ra_lib_close(ra);

    return 0;
}                               /* main() */

Output of the example

SDNN (standard deviation of normal-to-normal intervals):
30.876196
HRVI (HRV-Index): 4.800000
SDANN (standard deviation of averaged normal-to-normal
intervals): nan
rmssd (root mean of squared sucsessive differences): 33.839537
pNN50 (): 7.142857
TP (total power): 482.603096
ULF (ultra low frequency power): 0.000000
VLF (very low frequency power of short-term recordings):
32.889150
LF (low frequency power): 157.213726
LF_NORM (normalised low frequency power): 34.958606
HF (high freuqency power): 292.500220
HF_NORM (normalised high frequency power): 65.041394
LF_HF_RATIO (LF/HF ratio): 0.537482
POWER_LAW (power law behavior): 0.000000