MIT-LCP / MIT-LCP/wfdb-python

Error in wfdb_to_wav

Open
#410 2 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

Hi everyone,

this is my first time writing an issue as well as using wfdb so, excuse me in advance for the mistakes I'll surely make :)

I'm trying to obtain some .wav from the data stored in VOICED database with the following piece of code:

import wfdb.io.convert.wav
import os

path = 'my_path'
wfdb.io.convert.wav.wfdb_to_wav('voice001', pn_dir='voiced',
                                output_filename=os.path.join(path, 'aaab.wav'))

Thus, I obtain the following error:

Traceback (most recent call last):
File "path_of_my_script", line 18, in
wfdb.io.convert.wav.wfdb_to_wav('voice001', pn_dir='voiced',
File "C:[...]\AppData\Local\Programs\Python\Python310\lib\site-packages\wfdb\io\convert\wav.py", line 121, in wfdb_to_wav
np.left_shift(np.subtract(record.adc(), offset), shift)
File "C:[...]\AppData\Local\Programs\Python\Python310\lib\site-packages\wfdb\io_signal.py", line 578, in adc
nanlocs = np.isnan(self.p_signal)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

At first I thought that I was messing it up and went to the documentation page. I ended up realizing that if I try to run the example piece of code that appears for wfdb_to_wav:

wfdb_to_wav('100', pn_dir='pwave')

I obtain the same error as my code's. I did some research and some people has the same 'TypeError: ufunc 'isnan' not supported...' in other context, they managed to fix it using pandas instead of numpy, but it doesn't work for me. Any idea of why is this happening?

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 with the wfdb_to_wav entry point in wfdb/io/convert/wav.py around line 121, then inspect the adc method in wfdb/io/_signal.py around line 578. Reproduce the documented wfdb_to_wav('100', pn_dir='pwave') example and compare its input types with the failing path; done means the examples convert successfully without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.