MIT-LCP / MIT-LCP/wfdb-python

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

未关闭
#515 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Jupyter Notebook
星标
853
派生
322
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 wfdb.wrsamp 调用的 calc_adc_params 开始,使用随附的 data.float32 文件和复现代码片段触发该故障。检查 chmin 和 chmax 如何针对 fmt 32 推导出来,并将它们与允许的范围进行比较。当复现过程在没有 IndexError 的情况下完成,同时值仍处于格式限制范围内时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。