PGomes92 / pyhrv

Python toolbox for Heart Rate Variability
BSD 3-Clause "New" or "Revised" License
264 stars 77 forks source link

KeyError: "Unknown key: 'ar_order'." #7

Closed mehdifirouz closed 4 years ago

mehdifirouz commented 5 years ago

Thanks for your great work. I got the following error, running results = pyhrv.hrv(nni=nni_base) on Python3.7

Would you please help me.


KeyError Traceback (most recent call last)

in ----> 1 results = pyhrv.hrv(nni=nni_base) ~/venv/lib/python3.7/site-packages/pyhrv/hrv.py in hrv(nni, rpeaks, signal, sampling_rate, interval, plot_ecg, plot_tachogram, show, fbands, kwargs_ecg_plot, kwargs_tachogram, kwargs_time, kwargs_nonlinear, kwargs_welch, kwargs_lomb, kwargs_ar) 284 # COMPUTE FREQUENCY DOMAIN RESULTS (kwargs are verified by the frequency_domain() function) 285 f_results = fd.frequency_domain(nni=nn, fbands=fbands, kwargs_welch=kwargs_welch, kwargs_lomb=kwargs_lomb, --> 286 kwargs_ar=kwargs_ar, show=False) 287 288 # COMPUTE NONLINEAR PARAMETERS ~/venv/lib/python3.7/site-packages/pyhrv/frequency_domain.py in frequency_domain(nni, rpeaks, signal, sampling_rate, fbands, show, show_param, legend, kwargs_welch, kwargs_lomb, kwargs_ar) 1125 else: 1126 # Compute Autoregressive PSD with default values -> 1127 ar_results = ar_psd(nn, show=False, fbands=fbands, legend=legend, show_param=show_param) 1128 1129 # If plots should be shown (show all plots at once) ~/venv/lib/python3.7/site-packages/pyhrv/frequency_domain.py in ar_psd(nni, rpeaks, fbands, nfft, order, show, show_param, legend, mode) 497 498 # Plot PSD --> 499 figure = _plot_psd('ar', frequencies, powers, freq_i, params, show, show_param, legend) 500 figure = utils.ReturnTuple((figure, ), ('ar_plot', )) 501 ~/venv/lib/python3.7/site-packages/pyhrv/frequency_domain.py in _plot_psd(method, freq, power, freq_indices, parameters, show, show_param, legend) 904 ax.set_title("PSD - Welch's Method") 905 elif method == 'ar': --> 906 ax.set_title("PSD - Autoregressive (Order %i)" % parameters['ar_order']) 907 elif method == 'lomb': 908 ax.set_title("PSD - Lomb-Scargle Periodogram") ~/venv/lib/python3.7/site-packages/biosppy/utils.py in __getitem__(self, key) 405 if isinstance(key, six.string_types): 406 if key not in self._names: --> 407 raise KeyError("Unknown key: %r." % key) 408 409 key = self._names.index(key) KeyError: "Unknown key: 'ar_order'."
PGomes92 commented 5 years ago

Thanks for submitting the issue! I already fixed this malfunction and it will be available int he next pyHRV available which I am planning to release over the next couple of days.

tgterra commented 5 years ago

Hello Pedro, thank you for your work! When do you plan to release this new fix?

PGomes92 commented 5 years ago

Hi Thiago, thanks for the positive feedback, I am glad to hear that pyHRV has left a good impression!

Unfortunately, I am a bit behind my planned scheduled update for pyHRV but I am trying to get the new update with a lot of new features and bug fixes (incl. this one) over the next week.

phiradd commented 5 years ago

Hi Pedro!

first of all thank you for your great work. Unfortunately I have been getting the same error as in this issue. Can you please tell me when you will be able to fix this?

Thanks again Philipp

kra5h commented 4 years ago

For those who interested in a quick and dirty fix: replace the line 906 of frequency_domain.py with something like: ax.set_title("PSD - Autoregressive (DIRTY FIX)")

PGomes92 commented 4 years ago

Closed with update v.0.4.0