When using the basic_scr() method of the EDA library I faced an uncaught ValueError for some of my signals. The error message is the following:
a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li)])
File "/usr/local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2320, in amax out=out, **kwargs)
File "/usr/local/lib/python3.6/site-packages/numpy/core/_methods.py", line 26, in _amax return umr_maximum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation maximum which has no identity
I tracked down the error to line 167 that contains
a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li)])
More precisely the error occurs when signal[i1[i]:i3[i]] has a length of zero (which occurred a couple of times in almost half of my datasets). I figured this error is thrown when np.max() is called on an empty list. A possible solution would be to replace this line with the following:
a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li) if len(signal[i1[i]:i3[i]]) > 0])
While analyzing this issue I recognized that the above list comprehension is supposed to yield the amplitudes of the peaks. But what it actually does is to yield the maximum value of the original signal in the given interval. This could be solved by yielding the difference between min and max value in the given interval. To combine both of my proposals the following line might be used:
a = np.array([np.max(signal[i1[i]:i3[i]]) - np.min(signal[i1[i]:i3[i]]) for i in range(li) if len(signal[i1[i]:i3[i]]) > 0])
When using the basic_scr() method of the EDA library I faced an uncaught ValueError for some of my signals. The error message is the following:
I tracked down the error to line 167 that contains
a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li)])
More precisely the error occurs when
signal[i1[i]:i3[i]]
has a length of zero (which occurred a couple of times in almost half of my datasets). I figured this error is thrown when np.max() is called on an empty list. A possible solution would be to replace this line with the following:a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li) if len(signal[i1[i]:i3[i]]) > 0])
While analyzing this issue I recognized that the above list comprehension is supposed to yield the amplitudes of the peaks. But what it actually does is to yield the maximum value of the original signal in the given interval. This could be solved by yielding the difference between min and max value in the given interval. To combine both of my proposals the following line might be used:
a = np.array([np.max(signal[i1[i]:i3[i]]) - np.min(signal[i1[i]:i3[i]]) for i in range(li) if len(signal[i1[i]:i3[i]]) > 0])