Skip to content

ann2rr filters intervals by length instead of by time in the record #617

Closed

Description

@tompollard

The ann2rr docstring describes start_time and stop_time as "the time to start the intervals" and "the time to stop the intervals", in seconds. But they're compared with the length of each interval, not with its position in the record:

time_interval = rr_interval / ann.fs
if start_time is not None:
    time_interval = time_interval[(time_interval > start_time).astype(bool)]
if stop_time is not None:
    time_interval = time_interval[(time_interval < stop_time).astype(bool)]

For example, with record 100 (360 Hz):

from wfdb import processing

len(processing.ann2rr("sample-data/100", "atr"))                  # 2274
processing.ann2rr("sample-data/100", "atr", start_time=0.9)       # 30 intervals, all longer than 0.9 s
processing.ann2rr("sample-data/100", "atr", stop_time=0.5)        # 2 intervals, both shorter than 0.5 s

So start_time=0.9 drops every interval shorter than 0.9 s, rather than the intervals before 0.9 s into the record.

The WFDB ann2rr program's -f and -t options select annotations by time in the record. ann2rr should probably do the same: keep the intervals that end between start_time and stop_time, measuring the first interval from start_time, as ann2rr -f does.

This is separate from #584, which changes which annotations are used but leaves this filtering unchanged.

Activity

  1. added 2 commits that reference this issue on Nov 2, 2026
    78e64a4
    cdfc64a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions