Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use int64 instead of int for ann2rr #454

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Use int64 instead of int for ann2rr #454

merged 1 commit into from
Jun 16, 2023

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented May 25, 2023

This fixes issue #453 by using 64-bit integers on all platforms. (64-bit integers are way overkill for storing RR intervals, but I think it's wise to keep it simple and use 64-bit integers for all types of sample intervals.)

This is a pretty simple fix, but looking at the code I also notice there are a couple of significant issues with this function:

  • Unlike the ann2rr program, this function only considers the timestamps of the input annotations - it doesn't check whether they're QRS annotations or some other type of annotations (e.g. NOTE or RHYTHM).

  • Like the ann2rr program, this function includes the interval between the first annotation and the start of the record.

As a result, when you look at Lucas's example in the docstring:

    >>> wfdb.ann2rr('sample-data/100', 'atr', as_array=False)
    >>> 18
    >>> 59
    >>> ...
    >>> 250
    >>> 257

the first two "RR intervals" listed here are bogus and misleading: the first is the interval between the start of the record and the first RHYTHM annotation, and the second is the interval between the RHYTHM annotation and the first NORMAL annotation.

All that is by way of saying, I'd like to add a test case for this function but I think it's kind of broken to begin with and probably its behavior should be better nailed down first.

The alias 'np.int' has been removed from recent versions of numpy, and
there is no particular reason to want to use it here (as an array data
type, 'int' refers to a particular platform-dependent type, which is
not at all the same thing as an ordinary Python integer.)

Use int64 here for inter-platform consistency and to keep it simple.
@tompollard
Copy link
Member

Looks good to me, thanks Benjamin.

@tompollard tompollard merged commit 00c4ea0 into main Jun 16, 2023
@tompollard tompollard deleted the ann2rr-int64 branch June 16, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants