PIA-Group/BioSPPy

UnboundLocalError: local variable 'twopeaks' referenced before assignment

vykintasmak opened this issue · 6 comments

Hi,
I get this for like 1% files from my DB, not entirely sure how to fix it myself:

File "/usr/local/lib/python2.7/dist-packages/biosppy/signals/ecg.py", line 1157, in hamilton_segmenter
posdiv = abs(twopeaks[0][0] - twopeaks[1][0])
UnboundLocalError: local variable 'twopeaks' referenced before assignment

Hi @vykintasmak
Could you please send, if possible, one of the files where the error happens?

@vykintasmak
Thanks, I'll check it out.

@vykintasmak
I was not able to reproduce the error you reported.
Could you please check the version of biosppy that you're using, making sure to run the most recent version.

@capcarr
I resolved it but not sure if that should be a valid solution:
If i filter the signal before hamilton_segmenter - then it works fine. If i use hamilton_segmenter on raw signal - I get this error.

As I see, using ecg.ecg(samples) filters the signal before using segmenter, but the segmenter itself cannot be used separately without filtering.

Again, not sure if it's a problem, very sorry if I'm wasting your time

Indeed, I was able to reproduce the error without filtering.
I think I'm able to fix the problem, I'll push the changes in a moment.
If the problem persists, feel free to reopen the issue.