wfdb
wfdb copied to clipboard
gqrs issues
I'm refactoring Julien's python port of gqrs and hence am also looking through gqrs.c
.
I'm going to list bugs and things about it that could be cleaned up along the way.
- The
dt
variable, a filter time constant measured in sample numbers, is initialized and never changes.smdt
, which serves the same role for the smoothed filter, is initialized todt
and never changes. It may as well be replaced bydt
. - The
gqrs
function forstate == LEARNING
only runs up to sample number t =sps
(samples per second) + 2, rather thantf
as the function implies. I don't think it is intentional, given thattf_learn
was deliberately calculated to determine how much of the signal should be used for training. - Once again for the LEARNING state, it seems nothing is actually accomplished. The filter function
qf
is never called, hence the only thing that can possibly be executed is reducingpthr
to its minimum value. - WFDBINVALID samples are not treated differently. They are taken as regular samples.
- Line 570:
for (p = cpeak->next; p->time < t - rtmax; p = p->next) {
, why does the peak pointerp
start at the next peak? It seems the goal is to go through the circular buffer of peaks from the beginning to the current one. Why not just pointp
topeaks
to begin with? Also, why do we need both an array and linked list? - Line 587:
else if (p->amp < qthr) qthr--;
This line is within the if statement on line 572:if (p->amp > qthr) {
hence it cannot possibly be triggered. - The peak threshold
pthr
can only ever be decreased (line 641) but not increased. I don't know if this is intentional.