MIT-LCP / wfdb-python

Native Python WFDB package
MIT License
730 stars 298 forks source link

One malformed signal in mimic3 matched? #458

Open covertg opened 1 year ago

covertg commented 1 year ago

Hi,

I've been using wfdb-python to parse numerics from the mimic3 waveforms database at large. I've found just one file that appears to be unreadable by wfdb, from patient p086831. Here's a minimum example (pulling from the online database):

import wfdb
rec_id = "p086831-2130-12-29-18-28n"
# rec_path = "mimic3wdb/1.0/matched/p08/p086831/"
rec_path = "mimic3wdb-matched/1.0/p08/p086831/"
rec = wfdb.rdrecord(rec_id, pn_dir=rec_path)
ValueError                                Traceback (most recent call last)
Cell In[6], line 6
      4 # rec_path = "mimic3wdb/1.0/matched/p08/p086831/"
      5 rec_path = "mimic3wdb-matched/1.0/p08/p086831/"
----> 6 rec = wfdb.rdrecord(rec_id, pn_dir=rec_path)
...
File .../venv/lib/python3.11/site-packages/wfdb/io/_signal.py:2051, in _check_sig_dims(sig, read_len, n_sig, samps_per_frame)
   2049 for ch in range(n_sig):
   2050     if len(sig[ch]) != samps_per_frame[ch] * read_len:
-> 2051         raise ValueError("Samples were not loaded correctly")

ValueError: Samples were not loaded correctly

This also occurs when pulling the respective .hea and .dat files locally and using wfdb from there.

Perhaps this is an issue with the MIMIC file itself, but I wanted to start here, since I'm not sure how to tell. Might this be a MIMIC bug, or is this a wfdb issue?

Thanks in advance--