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

added onset-peak detection parameters #47

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions biosppy/signals/eda.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .. import plotting, utils


def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True):
def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True, min_amplitude=0.1, size=0.9):
"""Process a raw EDA signal and extract relevant signal features using
default parameters.

Expand All @@ -41,6 +41,10 @@ def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True):
If provided, the plot will be saved to the specified file.
show : bool, optional
If True, show a summary plot.
min_amplitude : float, optional
Minimum threshold by which to exclude SCRs.
size : float, optional
Size of the filter applied to exluced SCRs.

Returns
-------
Expand Down Expand Up @@ -90,7 +94,7 @@ def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True):
# get SCR info
onsets, peaks, amplitudes, phasic_rate, rise_times, half_rec, six_rec = eda_events(signal=filtered,
sampling_rate=sampling_rate,
min_amplitude=0.1, size=0.9)
min_amplitude=min_amplitude, size=size)

# get time vectors
length = len(signal)
Expand Down Expand Up @@ -184,6 +188,10 @@ def eda_events(signal=None, sampling_rate=1000., method="emotiphai", **kwargs):

else:
raise TypeError("Please specify a supported method.")

# sanity check
if len(onsets) == 0:
raise ValueError("Could not find SCR pulses.")

# compute phasic rate
try:
Expand Down Expand Up @@ -674,7 +682,10 @@ def emotiphai_eda(signal=None, sampling_rate=1000., min_amplitude=0.1,
peaks += [zeros[z] + p]
onsets += [zeros[z]]
amps += [s[p] - s[0]]

# sanity check
if len(onsets) == 0:
raise ValueError("Could not find SCR pulses. Try to adjust min_amplitude or the filter size.")

# convert to array
onsets, peaks, amps = np.array(onsets), np.array(peaks), np.array(amps)

Expand Down