Skip to content

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

Open
@nickfong

Description

@nickfong

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.

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