-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
[Fix] EDA peak detection and sympathetic activity #783
[Fix] EDA peak detection and sympathetic activity #783
Conversation
Codecov ReportBase: 53.28% // Head: 53.77% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev #783 +/- ##
==========================================
+ Coverage 53.28% 53.77% +0.49%
==========================================
Files 293 293
Lines 13276 13295 +19
==========================================
+ Hits 7074 7150 +76
+ Misses 6202 6145 -57
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Thanks :) It seems like it throws an error when a short signal is passed. Should we try to adjust nperseg or the overlap so that it doesn't fail in that case? If not,skip when shorter than some minimal length? import neurokit2 as nk
eda = nk.data('bio_resting_8min_100hz')['EDA']
indexes_posada = nk.eda_sympathetic(eda[0:2000], sampling_rate=100, method='posada', show=True)
|
The algorithm is proposed for data that is more than |
Seems like there is bug in the nabian method that makes the docstring examples fail:
|
Could you tell me which example failed? It looks like assert all([i in features_df.columns.values for i in columns]) in test_eda_intervalrelated() is failed columns: ['SCR_Peaks_N', 'SCR_Peaks_Amplitude_Mean', 'Label'] |
Changing max to nanmax seemed to have fixed the issue 🤷♂️ I've also taken the liberty of adding you as a contributor, do let me know if it's okay |
Actually this still does fail: import neurokit2 as nk
# Get phasic component
eda_signal = nk.eda_simulate(duration=30, scr_number=5, drift=0.1, noise=0, sampling_rate=100)
eda_cleaned = nk.eda_clean(eda_signal, sampling_rate=100)
eda = nk.eda_phasic(eda_cleaned, sampling_rate=100)
eda_phasic = eda["EDA_Phasic"].values
_, nabian2018 = nk.eda_peaks(eda_phasic, sampling_rate=100, method="nabian2018") Reason is that the windows are empty ( |
The problem happens because a negative crossing happens before the first positive crossing. In this case, delete the first negative crossing would work. |
Could you add that or show me how to add? EDIT: oops I missed that you made a commit already |
All good it seems, let me know if it's good to merge :) |
I agree to merge. |
Thanks a lot for diving into these functions, much appreciated |
Description
This PR aims at fix the issue mentioned at #778, #780 and #779
Proposed Changes
if the user chooses to 'posada' to calculate Sympathetic Nervous System Index, EDA signal will be resampled at 400Hz. A low-pass filter is also added according to original paper.
eda_findpeaks()
using methods proposed in nabian2018 is reviewed and improved. Differentiation has been added before smoothing. Skin conductance response criteria have been revised based on the original paper.In the eda.find_peaks sub-module, _eda_findpeaks_vanhalem2020 has been revised. The algorithm is changed based on the orginal paper.
We specified a peak when a consistent increase of 0.5 seconds would follow a consistent decrease of 0.5 seconds.
However, if eda signals ends before the peak recovers, the offset will not be detected.
Checklist
Here are some things to check before creating the PR. If you encounter any issues, do let us know :)