Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'ExpRange' #687

Closed
Ahingsun opened this issue Jul 31, 2022 · 4 comments
Closed

KeyError: 'ExpRange' #687

Ahingsun opened this issue Jul 31, 2022 · 4 comments

Comments

@Ahingsun
Copy link

Question and context

Hi, I'm Inseon.

I tried to analyze my physio data acquired from BIOPAC MP160.

I'm now focusing on ECG data and HRV analysis, and Neurokit2 seems easy and reliable analysis tool. Thanks for your work!

I had the same issue with #593, and I corrected the issue by replacing '_hrv_dfa' as zara6697 suggested (#593)

After that, my code gave me the following error, which I can't find any issue opened/closed here.

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/neurokit2/bio/bio_analyze.py", line 124, in bio_analyze
ecg_analyzed = ecg_analyze(ecg_data, sampling_rate=sampling_rate, method=method)
File "/usr/local/lib/python3.8/dist-packages/neurokit2/ecg/ecg_analyze.py", line 127, in ecg_analyze
features = ecg_intervalrelated(data, sampling_rate=sampling_rate)
File "/usr/local/lib/python3.8/dist-packages/neurokit2/ecg/ecg_intervalrelated.py", line 63, in ecg_intervalrelated
intervals.update(_ecg_intervalrelated_hrv(data, sampling_rate))
File "/usr/local/lib/python3.8/dist-packages/neurokit2/ecg/ecg_intervalrelated.py", line 128, in _ecg_intervalrelated_hrv
results = hrv(rpeaks, sampling_rate=sampling_rate)
File "/usr/local/lib/python3.8/dist-packages/neurokit2/hrv/hrv.py", line 102, in hrv
out.append(hrv_nonlinear(peaks, sampling_rate=sampling_rate))
File "/usr/local/lib/python3.8/dist-packages/neurokit2/hrv/hrv_nonlinear.py", line 214, in hrv_nonlinear
out = _hrv_dfa(peaks, rri, out, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/neurokit2/hrv/hrv_nonlinear.py", line 437, in _hrv_dfa
out["DFA_alpha1_ExpRange"] = mdfa_alpha1["ExpRange"]
KeyError: 'ExpRange'

The error comes when I try

nk.bio_analyze(processed_data, sampling_rate=1000)
nk.ecg_intervalrelated(ecg_processed, sampling_rate=1000)
nk.hrv_nonlinear(ecg_processed, sampling_rate=1000) ,

however, the code nk.hrv_time and nk.hrv_frequency correctly provide the results.

Do you have any idea how to solve this issue? As I'm interested in the non-linear parameters, I really want to get the results.
I'm attaching my code and data files.

SMS_fNIRS.txt
neurokit2.txt

Thanks in advance.

Best regards,
Inseon

@welcome
Copy link

welcome bot commented Jul 31, 2022

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

@danibene
Copy link
Collaborator

danibene commented Aug 1, 2022

Hi @Ahingsun

Disclaimer: I'm not a maintainer of this package & not sure if I can help here

But I thought I'd try to reproduce your error, and I wasn't able to: https://gist.github.com/danibene/62702dd09eab59f842ede5b8f029e5d3

Is the example SMS_fNIRS.txt the same data that caused the error?

@Ahingsun
Copy link
Author

Ahingsun commented Aug 2, 2022

Hi @Ahingsun

Disclaimer: I'm not a maintainer of this package & not sure if I can help here

But I thought I'd try to reproduce your error, and I wasn't able to: https://gist.github.com/danibene/62702dd09eab59f842ede5b8f029e5d3

Is the example SMS_fNIRS.txt the same data that caused the error?

Hi Danibene!

Thanks for trying my code. yes, that's the data that caused the error.

I just replaced the hrv_nonlinear.py file with the original file (not changing '_hrv_dfa' part as suggested in #593), and now it works fine.

Thanks!

@Ahingsun Ahingsun closed this as completed Aug 2, 2022
@DominiqueMakowski
Copy link
Member

Thanks @danibene for your help, much appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants