PIA-Group / BioSPPy

Biosignal Processing in Python
Other
573 stars 274 forks source link

UnboundLocalError: local variable 'twopeaks' referenced before assignment #28

Closed vykintasmak closed 7 years ago

vykintasmak commented 7 years ago

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

capcarr commented 7 years ago

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

vykintasmak commented 7 years ago

https://drive.google.com/file/d/0ByGHkMleqQD-c0s5RG9aWUJuTnc/view?usp=sharing And it's header file: https://drive.google.com/file/d/0ByGHkMleqQD-aXJxVGotLVl5R0U/view?usp=sharing

I use scipy.io.loadmat to read samples

capcarr commented 7 years ago

@vykintasmak Thanks, I'll check it out.

capcarr commented 7 years ago

@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.

vykintasmak commented 7 years ago

@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

capcarr commented 7 years ago

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.