Algorithm to get each intervals estimated length on an ECG - Python


Algorithm to get each intervals estimated length on an ECG - Python



If I have something like this:



enter image description here



That's a graphical representations of an ECG exam.



But they could be super different, like this one:



enter image description here



And so, to find each Peaks, like R, T, etc, I created the intervals where they could be found. But with every exam those change, and my question is how do I make an algorythm that'll work with any non corrupted ecg graph.



This is what I got:


qInterval = averageOfRInterval * 250 / 926 # Multiplied numbers are default for each interval and 926 is the
sInterval = averageOfRInterval * 250 / 926 # correspondent to 100% of the Interval.
tInterval = averageOfRInterval * 300 / 926
pInterval = averageOfRInterval * 400 / 926



It'll work for some graphs, but not all.



Is that another way? Or is my algorythm correct but just needs a little adjusting?




1 Answer
1



If you only want to detect the peaks you can use peakutils module of python. Here is the documentation - https://media.readthedocs.org/pdf/peakutils/latest/peakutils.pdf


peakutils



Like peakutils.peak.indexes(y, thres=0.3, min_dist=1, thres_abs=False) will give you the index of peaks with peak amplitude higher than threshold 0.3 and the minimum distance between them will be 1.


peakutils.peak.indexes(y, thres=0.3, min_dist=1, thres_abs=False)



You can also use plotly for visualizing the peak. Here are some examples - https://plot.ly/python/peak-finding/


plotly





The thing is that I want to detect each Peaks sperately, like r peak, q peak, t peak etc
– Duarte Arribas
Jun 29 at 9:19





Do you need the peak value? peak.indexes() will give you the peak values in a list.
– Azizul Haq Ananto
Jun 29 at 10:34


peak.indexes()





I need the value and the position too. But the thing is I want to identify whether It is an R Peak, a q Peak, a T peak, etc, so I can work with them.
– Duarte Arribas
Jun 29 at 10:39





Oh, that's an ECG signal and you want specific peaks. I can suggest you a research paper - researchgate.net/publication/… . In most cases these kinds of situations need a good amount of research to find out the pattern, there is no fixed solution for these. You can use machine learning techniques for these kinds of peak detection.
– Azizul Haq Ananto
Jun 29 at 10:51





I wanted an algorythm like the one that I made, that would calculate the peaks on all the graphs.
– Duarte Arribas
Jun 29 at 11:00






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV