Sourcecode
#include <stdlib.h>
#include <ra.h>
int main(int argc, char *argv[])
{
ra_handle ra;
meas_handle meas;
eval_handle eval;
prop_handle prop_rri, prop_qrs_pos;
evset_handle evset;
long l, num_events;
double *rri = NULL;
double *qrs_pos = NULL;
/* 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 event-properties for RR-intervals and position of
QRS-complex */
prop_rri = ra_prop_get_by_name(eval, "rri");
if (prop_rri == NULL)
{
printf("no event-property 'rri' in evaluation\n");
return -1;
}
prop_qrs_pos = ra_prop_get_by_name(eval, "qrs-pos");
if (prop_qrs_pos == NULL)
{
printf("no event-property 'qrs-pos' in evaluation\n");
return -1;
}
/* get values for all RR-intervals and QRS-complexes */
evset = ra_evset_get_by_prop(prop_rri);
/* number of events are the same for rri and qrs-pos, because
both belongs to the same event-set ('heartbeat') */
num_events = ra_evset_get_num_events(evset);
rri = malloc(sizeof(double) * num_events);
qrs_pos = malloc(sizeof(double) * num_events);
for (l = 0; l < num_events; l++)
{
rri[l] = ra_ev_get_value(prop_rri, l);
qrs_pos[l] = ra_ev_get_value(prop_qrs_pos, l);
}
/* now do something with the RR-intervals and QRS-complex
positions */
/* clean up */
if (rri)
free(rri);
if (qrs_pos)
free(rri);
ra_meas_close(meas);
ra_lib_close(ra);
return 0;
} /* main() */
|