paulvangentcom / heartrate_analysis_python

Python Heart Rate Analysis Package, for both PPG and ECG signals
MIT License
935 stars 322 forks source link

process_segment_wise not working since update #25

Closed FrancoisCosta closed 5 years ago

FrancoisCosta commented 5 years ago

Hi Paul,

I seem to be having some serious problems with the process_segment_wise since the latest update...

dataset: 01-05-19_00-25-52.txt

I have a dataset of which I'm using the first 500000 readings. My sampling speed is 1000Hz so that should correspond to the following segments when running:

working_data_segment, measures_segment = hp.process_segmentwise(data, sample_rate=1000.0, segment_width = 300, segment_overlap = 0.9)

Expected results: [(0, 300000),(30000, 330000),(60000, 360000),(90000, 390000),(12000, 420000),(150000, 450000),(180000, 480000),(210000, 500000)

However - it produces the following segments:

[(0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (0, 300000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (29999, 330000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (59999, 360000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (89999, 390000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999, 420000), (119999,420000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (149999, 450000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (179999, 480000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000), (209999, 500000)]

It worked well before the latest update, not sure what's going wrong now. I tested it on another dataset and got similar results

paulvangentcom commented 5 years ago

hm that shouldn't happen indeed. Let me have a look

paulvangentcom commented 5 years ago

Seems I was a bit sloppy with an indentation, thanks for catching the error. It works as expected now. Don't forget to pull the latest version (1.1.7a contains this fix)

What happened is that for each dictionary key an additional index range was appended, rather than just for each segment.

FrancoisCosta commented 5 years ago

Hi Paul,

This seems to be a problem again for me unfortunately.

paulvangentcom commented 5 years ago

Make sure you get the latest version from the github, uninstall the old one first just to be sure:

pip uninstall heartpy

then

python setup.py install from the cloned folder from git.

Using what's on github + your file above I cannot reproduce the error:

issue25_2

the behaviour seems as intended.