neuropsychology / NeuroKit

NeuroKit2: The Python Toolbox for Neurophysiological Signal Processing
https://neuropsychology.github.io/NeuroKit
MIT License
1.52k stars 404 forks source link

welch() got an unexpected keyword argument 'average' #918

Open akxscience opened 11 months ago

akxscience commented 11 months ago

Hi,

Using following code to generate sample ECG data and compute HRV metrics but running into below issue. Any help is much appreciated.

Generate 15 seconds of ECG signal (recorded at 250 samples/second)

ecg = nk.ecg_simulate(duration=15, sampling_rate=250, heart_rate=70)

Find peaks

peaks, info = nk.ecg_peaks(ecg, sampling_rate=250)

Compute HRV indices

nk.hrv(peaks, sampling_rate=250, show=True)


TypeError Traceback (most recent call last)

in 3 4 # Compute HRV indices ----> 5 nk.hrv(peaks, sampling_rate=250, show=True) ~\Anaconda3\lib\site-packages\neurokit2\hrv\hrv.py in hrv(peaks, sampling_rate, show, **kwargs) 104 # Gather indices 105 out.append(hrv_time(peaks, sampling_rate=sampling_rate)) --> 106 out.append(hrv_frequency(peaks, sampling_rate=sampling_rate)) 107 out.append(hrv_nonlinear(peaks, sampling_rate=sampling_rate)) 108 ~\Anaconda3\lib\site-packages\neurokit2\hrv\hrv_frequency.py in hrv_frequency(peaks, sampling_rate, ulf, vlf, lf, hf, vhf, psd_method, show, silent, normalize, order_criteria, interpolation_rate, **kwargs) 194 order_criteria=order_criteria, 195 t=t, --> 196 **kwargs 197 ) 198 ~\Anaconda3\lib\site-packages\neurokit2\signal\signal_power.py in signal_power(signal, frequency_band, sampling_rate, continuous, show, normalize, **kwargs) 98 show=show, 99 normalize=normalize, --> 100 **kwargs, 101 ) 102 else: ~\Anaconda3\lib\site-packages\neurokit2\signal\signal_power.py in _signal_power_instant(signal, frequency_band, sampling_rate, show, normalize, order_criteria, **kwargs) 137 normalize=normalize, 138 order_criteria=order_criteria, --> 139 **kwargs, 140 ) 141 ~\Anaconda3\lib\site-packages\neurokit2\signal\signal_psd.py in signal_psd(signal, sampling_rate, method, show, normalize, min_frequency, max_frequency, window, window_type, order, order_criteria, order_corrected, silent, t, **kwargs) 186 if method.lower() in ["welch"]: 187 frequency, power = _signal_psd_welch( --> 188 signal, sampling_rate=sampling_rate, nperseg=nperseg, window_type=window_type, **kwargs, 189 ) 190 ~\Anaconda3\lib\site-packages\neurokit2\signal\signal_psd.py in _signal_psd_welch(signal, sampling_rate, nperseg, window_type, **kwargs) 279 nperseg=nperseg, 280 window=window_type, --> 281 **kwargs, 282 ) 283 **TypeError: welch() got an unexpected keyword argument 'average'**
welcome[bot] commented 11 months ago

Hi 👋 Thanks for reaching out and opening your first issue here! We'll try to come back to you as soon as possible. ❤️ kenobi

DominiqueMakowski commented 11 months ago

Hi, it works for me. Yo umight want to update to the latest version NeuroKit and scipy

stale[bot] commented 6 months ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.