Skip to content

Commit

Permalink
added onset-peak detection parameters (#47)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrícia Bota <patriciabota@robalo.lx.it.pt>
  • Loading branch information
PatriciaBota and Patrícia Bota committed May 8, 2024
1 parent 05122fb commit 81ca438
Showing 1 changed file with 14 additions and 3 deletions.
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

0 comments on commit 81ca438

Please sign in to comment.