NeuroKit icon indicating copy to clipboard operation
NeuroKit copied to clipboard

ECG peak detection robust to signal inversion

Open raphaelvallat opened this issue 2 years ago • 6 comments

Question and context

Hi here!

Great work on the package 👏 👏

I am analyzing a large database of ECG recordings (n=2000+) and I suspect that for some of those (but not all), the ECG data is inverted. I do not have the time to do a manual check of all the files. My question is therefore whether there is a preferred method that I should use in ecg_clean and ecg_peaks that will be robust to such polarity inversion. I have been using the default method ("neurokit") and it seems to be working quite well, but maybe there's a better alternative.

PS: I think this is related to https://github.com/neuropsychology/NeuroKit/issues/368.

Thanks for your help! Raphael

raphaelvallat avatar Oct 12 '21 01:10 raphaelvallat

Yo! I thought about this issue today and I am tempted to think that the best way of addressing that is to, rather than having a method of peak detection robust enough to inversions (at the probable cost of accuracy), would be to detect the inverted signals, re-invert them and then detect peaks normally.

Now the problem is how to detect possibly inverted ECG signals, as it doesn't seem super straightforward from basic descriptive features like SD, skewness or average (based on my quick checks). Maybe it could work with nk.ecg_quality(ecg, method="zhao2018") (https://github.com/neuropsychology/NeuroKit/blob/master/neurokit2/ecg/ecg_quality.py#L26), which might be sensitive to inverted signals?

But in general I think if you manage to find a few of these inverted signals manually, you could compare their characteristics with a normal signal, and try to find a way of detecting them in an automated fashion, so that you can re-revert them and fully benefit from advanced peak detections for normal signals

DominiqueMakowski avatar Oct 12 '21 14:10 DominiqueMakowski

@DominiqueMakowski! I agree that this is probably the best approach. I'll run some tests on my data. Thanks!

raphaelvallat avatar Oct 12 '21 18:10 raphaelvallat

This issue has been automatically marked as inactive because it has not had recent activity. It will eventually be closed if no further activity occurs.

stale[bot] avatar Apr 11 '22 01:04 stale[bot]

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Sep 20 '22 19:09 stale[bot]

Did you have any luck with that in the end?

DominiqueMakowski avatar Sep 21 '22 00:09 DominiqueMakowski

Nope, ended up working on other projects and never had the time to finish this. Feel free to close the issue!

raphaelvallat avatar Sep 21 '22 01:09 raphaelvallat

FYI @raphaelvallat, @danibene implemented a new ecg_invert() function that detects whether inversion is needed (and inverts it if need be). Closing this then :)

DominiqueMakowski avatar Oct 03 '22 14:10 DominiqueMakowski