NeuroKit icon indicating copy to clipboard operation
NeuroKit copied to clipboard

NumPy DeprecationWarning thrown in `neurokit2.signal.signal_filter._signal_filter_butterworth`

Open MarcBalle opened this issue 3 weeks ago • 3 comments

Describe the bug When running neurokit2.ecg_clean there is the following numpy deprecation warning: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

Debugging into it, I suspect that the error happens when calling scipy.signal.butter in neurokit2.signal.signal_filter._signal_filter_butterworth. The Wn argument in scipy.signal.butter should be a scalar when btype is lowpass or highpass, but in this case freqs is a list.

To Reproduce

  1. Install neurokit2==0.2.9, scipy==1.13.1, numpy==1.26.4
  2. Run neurokit2.ecg_clean(ecg_signal=np.random.rand(20), sampling_rate=300.0, method="neurokit") (I use a random sequence here, but it is enough to reproduce the error. It also happens with an actual ecg signal)

System Specifications

Running on Windows 10, python 3.9.18. Example:

import neurokit2 as nk
nk.ecg_clean(np.random.rand(20), sampling_rate=300.0, method="neurokit")

Warning: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

MarcBalle avatar Jun 11 '24 15:06 MarcBalle