2424from .. import plotting , utils
2525
2626
27- def eda (signal = None , sampling_rate = 1000. , units = None , path = None , show = True ):
27+ def eda (signal = None , sampling_rate = 1000. , units = None , path = None , show = True , min_amplitude = 0.1 , size = 0.9 ):
2828 """Process a raw EDA signal and extract relevant signal features using
2929 default parameters.
3030
@@ -41,6 +41,10 @@ def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True):
4141 If provided, the plot will be saved to the specified file.
4242 show : bool, optional
4343 If True, show a summary plot.
44+ min_amplitude : float, optional
45+ Minimum threshold by which to exclude SCRs.
46+ size : float, optional
47+ Size of the filter applied to exluced SCRs.
4448
4549 Returns
4650 -------
@@ -90,7 +94,7 @@ def eda(signal=None, sampling_rate=1000., units=None, path=None, show=True):
9094 # get SCR info
9195 onsets , peaks , amplitudes , phasic_rate , rise_times , half_rec , six_rec = eda_events (signal = filtered ,
9296 sampling_rate = sampling_rate ,
93- min_amplitude = 0.1 , size = 0.9 )
97+ min_amplitude = min_amplitude , size = size )
9498
9599 # get time vectors
96100 length = len (signal )
@@ -184,6 +188,10 @@ def eda_events(signal=None, sampling_rate=1000., method="emotiphai", **kwargs):
184188
185189 else :
186190 raise TypeError ("Please specify a supported method." )
191+
192+ # sanity check
193+ if len (onsets ) == 0 :
194+ raise ValueError ("Could not find SCR pulses." )
187195
188196 # compute phasic rate
189197 try :
@@ -674,7 +682,10 @@ def emotiphai_eda(signal=None, sampling_rate=1000., min_amplitude=0.1,
674682 peaks += [zeros [z ] + p ]
675683 onsets += [zeros [z ]]
676684 amps += [s [p ] - s [0 ]]
677-
685+ # sanity check
686+ if len (onsets ) == 0 :
687+ raise ValueError ("Could not find SCR pulses. Try to adjust min_amplitude or the filter size." )
688+
678689 # convert to array
679690 onsets , peaks , amps = np .array (onsets ), np .array (peaks ), np .array (amps )
680691
0 commit comments