Detecting patterns in waves

后端 未结 13 1766
栀梦
栀梦 2021-01-29 17:43

I\'m trying to read a image from a electrocardiography and detect each one of the main waves in it (P wave, QRS complex and T wave). Now I can read the image and get a vector li

相关标签:
13条回答
  • 2021-01-29 18:30

    This is a wonderful question! I have a few thoughts:

    Dynamic Time Warping could be an interesting tool here. You would establish "templates" for your three classes, and then using DTW could see the correlation between your template and "chunks" of the signal (break the signal up into, say, .5 second bits, ie. 0-.5 .1-.6 .2-.7...). I've worked with something similar for gait analysis with accelerometer data, it worked reasonably well.

    Another option is a combined signal processing/ machine learning algorithm. Break your signal into "chunks" again. Make "templates" again (you'll want a dozen or so for each class) take the FFT of each chunk/template and then use a Naïve Bayes Classifier (or another ML classifier, but NB should cut it) to classify for each of your three classes. I've also tried this on gait data, and was able to get upwards of 98% precision and recall with relatively complicated signals. Let me know how this works, it's a very exciting problem.

    0 讨论(0)
  • 2021-01-29 18:30

    I haven't read each other answer thoroughly but I have scanned them and I noticed that no one recommended looking at the Fourier Transform to segment these waves.

    To me it seems like a clear cut application of Harmonic analysis in mathematics. There may be several subtle points that I may be missing.

    The Discrete Fourier Transform coefficients give you the amplitude and phase of the different sinusoidal components that make up your discrete time signal, which is essentially what your problem states you want to find.

    I may be missing something here though ...

    0 讨论(0)
  • 2021-01-29 18:31

    Are those other two sharp peaks and valleys also qrs complexes?

    Off the top of my head, I think what you need to do is calculate the slope of this graph at each point. Then you also need to see how quickly the slope changes (2nd derivative???). If you have an abrupt change then you know you've hit some kind of sharp peak. Of course, you want to limit the detection of the change, so you might want to do something like "if the slope changes by X over time interval T", so that you don't pick up the tiny bumps in the graph.

    It's been a while since I did any math... and this seems like a math question ;) Oh, and I haven't done any sort of signal analysis either :).

    Just adding another point. You can also try signal-averaging I think. For example, averaging the last 3 or 4 data points. I think you can detect abrupt changes that way too.

    0 讨论(0)
  • 2021-01-29 18:34

    A piece of this puzzle is "onset detection" and a number of complex algorithms have been written to solve this problem. Here is more information on onsets.

    The next piece is a Hamming Distance. This algorithms allow you to make fuzzy comparisons, the input is 2 arrays and the output is an integer "distance" or difference between the 2 data sets. The smaller the number, the more alike the 2 are. This is very close to what you need, but its not exact. I went ahead and made some modifications to the Hamming Distance algorithm to calculate a new distance, it probably has a name but i don't know what it is. Basically it adds up the absolute distance between each element in the array and returns the total. Here is the code for it in python.

    import math
    
    def absolute_distance(a1, a2, length):
           total_distance=0
           for x in range(0,length):
                   total_distance+=math.fabs(a1[x]-a2[x])
           return total_distance
    
    print(absolute_distance([1,3,9,10],[1,3,8,11],4))
    

    This script outputs 2, which is the distance between these 2 arrays.

    Now for putting together these pieces. You could use Onset detection to find the beginning of all waves in the data set. You can then loop though these location comparing each wave with a sample P-Wave. If you hit a QRS Complex the distance is going to be the largest. If you hit another P-Wave the number isn't going to be zero, but its going to be much smaller. The distance between any P-Wave and any T-Wave is going to be pretty small, HOWEVER this isn't a problem if you make the following assumption:

    The distance between any p-wave and any other p-wave will be smaller than the distance between any p-wave and any t-wave.

    The series looks something like this: pQtpQtpQt... The p-wave and t-wave is right next to each other, but because this sequence is predictable it will be easier to read.

    On a side not, there is probably a calculus based solution to this problem. However in my mind curve fitting and integrals make this problem more of a mess. The distance function I wrote will find the area difference which is very similar subtracting the integral of both curves.

    It maybe possible to sacrifice the onset calculations in favor of iterating by 1 point at a time and thus performing O(n) distance calculations, where n is the number of points in the graph. If you had a list of all of these distance calculations and knew there where 50 pQt sequences then you would know the 50 shortest distances that do not overlap where all locations of p-waves. Bingo! how is that for simplicity? However the trade off is loss of efficiency due to an increased number of distance calculations.

    0 讨论(0)
  • 2021-01-29 18:34

    I'm no expert in this specific problem, but just off the top of my head from more general knowledge: Let's say you know the QRS complex (or one of the other features, but I'll use the QRS complex for this example) takes place in roughly some fixed time period of length L. I wonder if you could treat this as a classification problem as follows:

    1. Split your signal into overlapping windows of length L. Each window either does or doesn't have the full QRS complex in it.
    2. Fourier transform each window. Your features are the signal strength at each frequency.
    3. Train a decision tree, support vector machine, etc. on some hand-annotated data.
    0 讨论(0)
  • 2021-01-29 18:34

    First, the various components of the standard electrocardiogram wave can be missing from any given plot. Such a plot is generally abnormal and usually indicates some sort of problem, but you can't be promised that they're there.

    Secondly, recognizing them is as much art as science, especially in the cases where something is going wrong.

    My approach might be to try to train a neural network to identify the components. You would give it the previous 30 seconds of data, normalized so the lowest point was at 0 and the highest point at 1.0 and it would have 11 outputs. The outputs that weren't abnormality ratings would be a weighting for the last 10 seconds. A 0.0 would be -10 seconds from present, and a 1.0 would mean now. The outputs would be:

    1. Where the most recent P wave started
    2. Where the most recent P wave ended
    3. Abnormality rating of most recent P wave with one extreme being 'absent'.
    4. Where the most recent QRS complex started
    5. Where the Q portion of the most recent QRS complex turned into the R portion.
    6. Where the R portion of the most recent QRS complex turned into the S portion.
    7. Where the most recent QRS complex ended.
    8. Abnormality rating of most recent QRS complex with one extreme being 'absent'.
    9. Where the most recent T wave started.
    10. Where the most recent T wave ended.
    11. Abnormality rating of most recent T wave with one extreme being 'absent'.

    I might double check this with some of the other kinds of analysis people suggested, or use those other kinds of analysis along with the output of the neural network to give you your answer.

    Of course, this detailed description of the neural network shouldn't be taken as prescriptive. I'm sure that I didn't necessarily pick the most optimal outputs for example, I just sort of tossed some ideas about what they might be.

    0 讨论(0)
提交回复
热议问题