Skip to content

Commit abf0a6a

Browse files
committed
Added check on number of samples for waveform metric
1 parent 173c2fa commit abf0a6a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

erdetect/core/metrics/metric_waveform.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def metric_waveform(sampling_rate, data, baseline):
7373
n_band, wn_band = signal.buttord([high_p, low_p], [high_s, low_s], Rp, Rs, True)
7474
bf_b, bf_a = signal.butter(n_band, wn_band, 'band', analog=False)
7575

76+
# band-pass can only be performed with enough samples, return nan elsewise
77+
if metric_data.shape[0] <= 3 * (max(len(bf_b), len(bf_a)) - 1):
78+
return np.nan
79+
7680
# Perform the band-passing
7781
# Note: custom padlen to match the way matlab does it (-1 is omitted in scipy)
7882
metric_data = signal.filtfilt(bf_b, bf_a, metric_data, padtype='odd', padlen=3 * (max(len(bf_b), len(bf_a)) - 1))

0 commit comments

Comments
 (0)