MIT-LCP / MIT-LCP/physionet

wfdb "rxr" program possible error

Open
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
82
Forks
21
Avg merge
35m
Merged PRs (30d)
1

Description

We used MIT “201.atr” as reference and algorithm annotation file and doing “rxr” comparison.
The output result files for “Supraventricular Couplet /Run”(as attached):
201_rxr_L2.txt
(SVE run detection)
Record CTs CFN CTp CFP STs SFN STp SFP LTs LFN LTp LFP CSe C+P SSe S+P LSe L+P
201 21 0 21 0 3 0 3 0 3 1 3 1 100 100 100 100 75 75

You can find the “LSe” (Long Run Sensitivity) and “L+P”(Long Run Positive Predictivity)
results are 75% instead of 100%.

The problem comes from the annotation label sequence “ ‘{‘ , ‘V’ “ starting
from sample index 171815 in “201.atr”.

7:57.264 171815 + 0 0 0 (AFIB
7:57.453 171883 V 0 0 0

The corresponding routines in "rxr.c" as below:

 85 /* Perform a run-by-run comparison. */
 86 void rxr(stat, type)
 87 int stat, type;
 88 {
             …
250               case '{':
251                 if (type == 1) {
252                     run_length[a] = 6;
253                     run_start = annot[a].time - match_dt;
254                 }
255                 break;

When ‘{‘ met, the run length be set as 6 and run start time be set, too.

174               case 'V':
175               case 'F':
176                 if (type == 0) {
            …
181                 }
182                 else {  /* this beat ends an SVE run */
183                     run_length[b] = find_longest_run(b,run_start,run_end,type);
184                     if (verbose && run_length[0] != run_length[1])
185                         (void)printf("%d/%d(%ld-%ld)\n", run_length[0],
186                                run_length[1], run_start, run_end);
187                     s[stat][run_length[0]][run_length[1]]++;
188                     run_length[a] = 0;
189                 }

The next label “V” met, it means “this beat ends an SVE run”.
“find_longest_run(b,run_start,run_end,type);” be called
to find corresponding longest run in algorithm annotation file.
But the “run_end” time not be solved, it’s value is 168567 and
smaller than “run_start” 171761.

432 find_longest_run(a, t0, t1, type)
433 unsigned int a;
434 long t0, t1;
435 int type;       /* 0: find VE run; 1: find SVE run */
436 {
           …
447     while (annot[a].time < t0) {
448         if ((type == 0 && amap(annot[a], a) == '[') ||
449             (type == 1 && amap(annot[a], a) == '{')) {  /* VF (AF) begins */
          …
470         }
471         /* If the annotation file ends before t0, record that this has happened
472            and return 0. */
473         if (getann(a, &annot[a]) < 0) {
474             annot[a].time = -1L;
475             return (0);
476         }
477     }

In “find_longest_run(1, 171761, 168567, 1)”, the beginning while loop
would be escaped at algorithm sample index “171815, label “{“.

479     /* Now count consecutive (S)VEBs in the window. */
480     while (annot[a].time <= t1) {
        …
556     }
557     return (len > len0 ? len : len0);
558 }

The second while loop in “find_longest_run(1, 171761, 168567, 1)” won’t be
entered for “t1” (168567, run_end in void rxr(stat, type)) is smaller than 171815.
The return value of “find_longest_run(1, 171761, 168567, 1)” would be 0.

The reference run length is 6 and the algorithm run length is 0.
It makes the unmatched pair and causes the error.

Would you please help us to confirm the above symptom is really "rxr" program bug.
Thanks a lot.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rxr.c, especially rxr() and find_longest_run(), and reproduce the comparison using MIT 201.atr and the attached 201_rxr_L2.txt output. Trace how the '{' and 'V' annotations set run_start and run_end, then verify that the resulting LSe and L+P values correctly account for the reported run.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.