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

wrsamp: IndexError: Channel 0 contains values outside the allowed range [-32768, 32767] for fmt 16 #521

Open
nickfong opened this issue Dec 17, 2024 · 4 comments

Comments

@nickfong
Copy link

We're encountering an issue when trying to write data to WFDB files using the wrsamp function. Specifically, we’re seeing an error that prevents us from writing the files correctly. When attempting to call wrsamp to save our data, we receive the following error message:

IndexError: Channel 0 contains values outside the allowed range [-32768, 32767] for fmt 16.

To investigate the issue further, we modified the WFDB source code to provide additional debugging information. The csv file we’re attempting to convert to wfdb has values ranging between:

Minimum: -90.113269
Maximum: 622.269327

But this is being scaled to -32767 and 32772 after calling wrsamp, so the max value allowed in fmt 16 is being exceeded.

We are using package versions:

Please see a screenshot below depicting the error we get using:
wfdb==4.1.2
pandas==2.2.3
numpy==2.1.2
image001

We have a minimal reproducible sample that we sent to Ben Moody and Tom Pollard.

@tompollard
Copy link
Member

@nickfong are you able to share example data to reproduce the error? (and if possible the code from the example above, as text rather than image).

@nickfong
Copy link
Author

Hey @tompollard, Tyler Law shared the reproducible code sample and data with you on 2024-12-04; it's the same thread that you responded to yesterday suggesting we open a GH issue 😃

Let me know if you want me to send to you again via email. We'd like to avoid posting the data here publicly.

@tompollard
Copy link
Member

@nickfong the only attachment to the email is the screenshot that you've shared above, but I do now notice a message saying:

UCSF IT’s email security system has detected and removed a potentially harmful attachment from this email.

Please could you share here instead?
 

@briangow
Copy link
Collaborator

@nickfong , thanks for privately sharing the CSV of data that allows for reproducing this problem. I haven't looked into it in detail but when I ran your code + data in a new environment I was able to reproduce the error. When I went to my wfdb-python environment I could not reproduce the error with the same code + data. We don't currently support numpy versions > 2 . This seemed like the obvious difference in setups, so I confirmed that with numpy==1.26.1 in both environments that the error does not occur. I haven't dug much further but this may be related to: #493 . We are actively working on support for numpy > 2 : #511 .

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

No branches or pull requests

3 participants