MIT-LCP / MIT-LCP/wfdb-python

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

Open
#521 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
853
Forks
322
PR merge metrics
No merged PRs in 30d

Description

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.

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 by reproducing the wrsamp call with the reported input range and inspect how values are scaled for fmt 16 before the range check. The payload does not name source files or tests; done means the described data can be written without producing values outside the allowed fmt 16 range, with regression coverage for the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.