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

calc_adc_params can produce off-by-one problems, crashing wrsamp #515

Open
Ivorforce opened this issue Nov 5, 2024 · 0 comments
Open

calc_adc_params can produce off-by-one problems, crashing wrsamp #515

Ivorforce opened this issue Nov 5, 2024 · 0 comments

Comments

@Ivorforce
Copy link
Contributor

Ivorforce commented Nov 5, 2024

I have some data that crashes wrsamp because calc_adc_params produces values that don't fit the data (off by one):

chmin = -2147483648
chmax = 2147483648
IndexError: Channel 0 contain values outside allowed range [-2147483648, 2147483647] for fmt 32

As you can see, chmax is just above the dmax of 2147483647 for 32.

This is some data for reproduction:
data.float32.zip

You can try it with:

data = np.reshape(np.fromfile("data.float32", dtype=np.float32), [-1, 12])
wfdb.wrsamp(
    record_name="test",
    sig_name=[f"d{x}" for x in range(12)],
    units=["mv"] * 12,
    fs=500,
#    fmt=["16"] * 12,
    p_signal=data
)

Note how passing fmt=16 fixes the problem in this particular case, probably by chance because it happens to not trigger the bug.

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

1 participant