如何检测(心电图)波的模式?

发布于 2024-08-20 00:59:45 字数 2170 浏览 10 评论 0原文

我正在尝试读取心电图图像并检测其中的每个主波(P 波、QRS 波群和 T 波)。我可以读取图像并获取向量(例如 (4.2; 4.4; 4.9; 4.7; ...))。我需要一种算法来遍历这个向量并检测每个波何时开始和结束。示例:

alt text

如果它们始终具有相同的大小,或者如果我知道心电图有多少个波,那就很容易了提前。给定波:

alt text

我提取矢量:

[0; 0; 20; 20; 20; 19; 18; 17; 17; 17; 17; 17; 16; 16; 16; 16; 16; 16; 16; 17; 17; 18; 19; 20; 21; 22; 23; 23; 23; 25; 25; 23; 22; 20; 19; 17; 16; 16; 14; 13; 14; 13; 13; 12; 12; 12; 12; 12; 11; 11; 10; 12; 16; 22; 31; 38; 45; 51; 47; 41; 33; 26; 21; 17; 17; 16; 16; 15; 16; 17; 17; 18; 18; 17; 18; 18; 18; 18; 18; 18; 18; 17; 17; 18; 19; 18; 18; 19; 19; 19; 19; 20; 20; 19; 20; 22; 24; 24; 25; 26; 27; 28; 29; 30; 31; 31; 31; 32; 32; 32; 31; 29; 28; 26; 24; 22; 20; 20; 19; 18; 18; 17; 17; 16; 16; 15; 15; 16; 15; 15; 15; 15; 15; 15; 15; 15; 15; 14; 15; 16; 16; 16; 16; 16; 16; 16; 16; 16; 15; 16; 15; 15; 15; 16; 16; 16; 16; 16; 16; 16; 16; 15; 16; 16; 16; 16; 16; 15; 15; 15; 15; 15; 16; 16; 17; 18; 18; 19; 19; 19; 20; 21; 22; 22; 22; 22; 21; 20; 18; 17; 17; 15; 15; 14; 14; 13; 13; 14; 13; 13; 13; 12; 12; 12; 12; 13; 18; 23; 30; 38; 47; 51; 44; 39; 31; 24; 18; 16; 15; 15; 15; 15; 15; 15; 16; 16; 16; 17; 16; 16; 17; 17; 16; 17; 17; 17; 17; 18; 18; 18; 18; 19; 19; 20; 20; 20; 20; 21; 22; 22; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 32; 33; 33; 33; 32; 30; 28; 26; 24; 23; 23; 22; 20; 19; 19; 18; 17; 17; 18; 17; 18; 18; 17; 18; 17; 18; 18; 17; 17; 17; 17; 16; 17; 17; 17; 18; 18; 17; 17; 18; 18; 18; 19; 18; 18; 17; 18; 18; 17; 17; 17; 17; 17; 18; 17; 17; 18; 17; 17; 17; 17; 17; 17; 17; 18; 17; 17; 18; 18; 18; 20; 20; 21; 21; 22; 23; 24; 23; 23; 21; 21; 20; 18; 18; 17; 16; 14; 13; 13; 13; 13; 13; 13; 13; 13; 13; 12; 12; 12; 16; 19; 28; 36; 47; 51; 46; 40; 32; 24; 20; 18; 16; 16; 16; 16; 15; 16; 16; 16; 17; 17; 17; 18; 17; 17; 18; 18; 18; 18; 19; 18; 18; 19; 20; 20; 20; 20; 20; 21; 21; 22; 22; 23; 25; 26; 27; 29; 29; 30; 31; 32; 33; 33; 33; 34; 35; 35; 35; 0; 0; 0; 0;]

我想检测,例如:

  • 中的 P 波[19 - 37]
  • [51 - 64] 中的 QRS 复合波。
  • ETC。

I'm trying to read an image from an electrocardiography and detect each one of the main waves in it (P wave, QRS complex and T wave). I can read the image and get a vector (like (4.2; 4.4; 4.9; 4.7; ...)). I need an algorithm that can walk through this vector and detect when each of these waves start and end. An example:

alt text

Would be easy if they always had the same size, or if I knew how many waves the ECG has in advance. Given the wave:

alt text

I extract the vector:

[0; 0; 20; 20; 20; 19; 18; 17; 17; 17; 17; 17; 16; 16; 16; 16; 16; 16; 16; 17; 17; 18; 19; 20; 21; 22; 23; 23; 23; 25; 25; 23; 22; 20; 19; 17; 16; 16; 14; 13; 14; 13; 13; 12; 12; 12; 12; 12; 11; 11; 10; 12; 16; 22; 31; 38; 45; 51; 47; 41; 33; 26; 21; 17; 17; 16; 16; 15; 16; 17; 17; 18; 18; 17; 18; 18; 18; 18; 18; 18; 18; 17; 17; 18; 19; 18; 18; 19; 19; 19; 19; 20; 20; 19; 20; 22; 24; 24; 25; 26; 27; 28; 29; 30; 31; 31; 31; 32; 32; 32; 31; 29; 28; 26; 24; 22; 20; 20; 19; 18; 18; 17; 17; 16; 16; 15; 15; 16; 15; 15; 15; 15; 15; 15; 15; 15; 15; 14; 15; 16; 16; 16; 16; 16; 16; 16; 16; 16; 15; 16; 15; 15; 15; 16; 16; 16; 16; 16; 16; 16; 16; 15; 16; 16; 16; 16; 16; 15; 15; 15; 15; 15; 16; 16; 17; 18; 18; 19; 19; 19; 20; 21; 22; 22; 22; 22; 21; 20; 18; 17; 17; 15; 15; 14; 14; 13; 13; 14; 13; 13; 13; 12; 12; 12; 12; 13; 18; 23; 30; 38; 47; 51; 44; 39; 31; 24; 18; 16; 15; 15; 15; 15; 15; 15; 16; 16; 16; 17; 16; 16; 17; 17; 16; 17; 17; 17; 17; 18; 18; 18; 18; 19; 19; 20; 20; 20; 20; 21; 22; 22; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 32; 33; 33; 33; 32; 30; 28; 26; 24; 23; 23; 22; 20; 19; 19; 18; 17; 17; 18; 17; 18; 18; 17; 18; 17; 18; 18; 17; 17; 17; 17; 16; 17; 17; 17; 18; 18; 17; 17; 18; 18; 18; 19; 18; 18; 17; 18; 18; 17; 17; 17; 17; 17; 18; 17; 17; 18; 17; 17; 17; 17; 17; 17; 17; 18; 17; 17; 18; 18; 18; 20; 20; 21; 21; 22; 23; 24; 23; 23; 21; 21; 20; 18; 18; 17; 16; 14; 13; 13; 13; 13; 13; 13; 13; 13; 13; 12; 12; 12; 16; 19; 28; 36; 47; 51; 46; 40; 32; 24; 20; 18; 16; 16; 16; 16; 15; 16; 16; 16; 17; 17; 17; 18; 17; 17; 18; 18; 18; 18; 19; 18; 18; 19; 20; 20; 20; 20; 20; 21; 21; 22; 22; 23; 25; 26; 27; 29; 29; 30; 31; 32; 33; 33; 33; 34; 35; 35; 35; 0; 0; 0; 0;]

I would like to detect, for example:

  • P wave in [19 - 37].
  • QRS complex in [51 - 64].
  • etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

初心未许 2024-08-27 00:59:45

要做的第一件事是查看已有的内容。事实上,这个具体问题已经得到了深入研究。以下是一些非常简单的方法的简要概述:链接

我也必须回应另一个答案。我的研究方向是信号处理和音乐信息检索。从表面上看,这个问题确实与起始检测类似,但问题上下文并不相同。这种类型的生物信号处理,即 P、QRS 和 T 相的检测,可以利用每个波形的特定时域特征知识。 MIR 中的起始检测实际上并非如此。 (至少不可靠。)

一种适用于 QRS 检测(但不一定适用于音符开始检测)的方法是动态时间扭曲。当时域特性保持不变时,DTW 可以很好地工作。以下是一篇简短的 IEEE 论文,它使用 DTW 来解决此问题:链接

这是一篇很好的 IEEE 杂志文章,比较了许多方法:链接。您将看到已经尝试了许多常见的信号处理模型。浏览一下这篇论文,然后尝试一篇你能基本理解的文章。

编辑:浏览这些文章后,基于小波的方法对我来说似乎是最直观的。 DTW 也能很好地工作,并且存在 DTW 模块,但小波方法对我来说似乎最好。其他人通过利用信号的导数来回答。我的第一个链接检查了 1990 年之前的方法,但我怀疑它们不如更现代的方法那么强大。

编辑:当我有机会时,我会尝试给出一个简单的解决方案,但我认为小波适合这里的原因是因为它们在参数化各种形状时非常有用,而不管 >时间或幅度缩放。换句话说,如果您有一个具有相同重复时间形状但时间尺度和幅度不同的信号,小波分析仍然可以将这些形状识别为相似(粗略地说)。另请注意,我将滤波器组归入这一类别。类似的事情。

The first thing that I would do is see what is already out there. Indeed, this specific problem has already been heavily researched. Here is a brief overview of some really simple methods: link.

I must respond to another answer, as well. I do research in signal processing and music information retrieval. On the surface, this problem does appear similar to onset detection, but the problem context is not the same. This type of biological signal processing, i.e., detection of the P, QRS, and T phases, can exploit knowledge of specific time-domain characteristics of each of these waveforms. Onset detection in MIR doesn't, really. (Not reliably, at least.)

One approach that would work well for QRS detection (but not necessarily for note onset detection) is dynamic time warping. When time-domain characteristics remain invariant, DTW can work remarkably well. Here is a short IEEE paper that uses DTW for this problem: link.

This is a nice IEEE magazine article that compares many methods: link. You'll see that many common signal processing models have been tried. Skim the paper, and try one that you understand at a basic level.

EDIT: After browsing these articles, a wavelet-based approach seems most intuitive to me. DTW will work well, too, and there exist DTW modules out there, but the wavelet approach seems best to me. Someone else answered by exploiting derivatives of the signal. My first link examines methods from before 1990 that do that, but I suspect that they are not as robust as more modern methods.

EDIT: I'll try to give a simple solution when I get the chance, but the reason why I think wavelets are suited here are because they are useful at parameterizing a wide variety of shapes regardless of time or amplitude scaling. In other words, if you have a signal with the same repeated temporal shape but at varying time scales and amplitudes, wavelet analysis can still recognize these shapes as being similar (roughly speaking). Also note that I am sort of lumping filter banks into this category. Similar things.

星星的轨迹 2024-08-27 00:59:45

这个难题的一部分是“起始检测"和许多复杂的算法已经被编写来解决这个问题。以下是有关起始的更多信息。

下一部分是汉明距离。该算法允许您进行模糊比较,输入是 2 个数组,输出是整数“距离”或 2 个数据集之间的差异。数字越小,两者越相似。这非常接近您的需要,但并不准确。我继续对汉明距离算法进行了一些修改以计算新的距离,它可能有一个名称,但我不知道它是什么。基本上,它将数组中每个元素之间的绝对距离相加并返回总数。这是它的 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))

该脚本输出 2,这是这 2 个数组之间的距离。

现在将这些部分组合在一起。您可以使用起始点检测来查找数据集中所有波的起始点。然后,您可以循环遍历这些位置,将每个波与样本 P 波进行比较。如果您达到 QRS 波群,则距离将是最大的。如果你击中另一个纵波,数字不会为零,但会小得多。任何 P 波和任何 T 波之间的距离都将非常小,但是,如果您做出以下假设,则这不是问题:

任何 p 波和任何其他 p 波之间的距离将小于任何 p 波和任何 t 波之间的距离。

该序列看起来像这样: pQtpQtpQt... p 波和 t 波彼此相邻,但是因为这个序列可以预见的是,它会更容易阅读。

另一方面,这个问题可能有一个基于微积分的解决方案。然而在我看来,曲线拟合和积分使这个问题变得更加混乱。我编写的距离函数将找到面积差,这与减去两条曲线的积分非常相似。

也许可以牺牲起始计算,转而一次迭代 1 个点,从而执行 O(n) 距离计算,其中 n 是图中的点数。如果您有所有这些距离计算的列表,并且知道其中有 50 个 pQt 序列,那么您就会知道 p 波所有位置不重叠的 50 个最短距离。 宾果游戏!这样简单吗?然而,代价是由于距离计算数量的增加而导致效率损失。

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.

百变从容 2024-08-27 00:59:45

您可以使用交叉相关。获取每个模式的模型样本并将它们与信号相关联。您将得到相关性较高的峰值。我希望用这种提取 qrs 和 t 波的技术能得到好的结果。之后,您可以通过查找 qrs 之前的相关信号峰值来提取 p 波。

互相关是一种非常容易实现的算法。基本上:

x is array with your signal of length Lx
y is an array containing a sample of the signal you want to recognize of length Ly
r is the resulting correlation

for (i=0; i<Lx - Ly; i++){
  r[i] = 0;
  for (j=0; j<Ly ; j++){
    r[i] += x[i+j]*y[j];
  }
}

并寻找 r 中的峰值(例如,超过阈值的值)

You can use cross-correlation. Take a model sample of each pattern and correlate them with the signal. You will get peaks where the correlation is high. I would expect good results with this technique extracting qrs and t waves. After that, you can extract p waves by looking for peaks on the correlation signal that are before qrs.

Cross-correlation is a pretty easy to implement algorithm. Basically:

x is array with your signal of length Lx
y is an array containing a sample of the signal you want to recognize of length Ly
r is the resulting correlation

for (i=0; i<Lx - Ly; i++){
  r[i] = 0;
  for (j=0; j<Ly ; j++){
    r[i] += x[i+j]*y[j];
  }
}

And look for peaks in r (values over a threshold, for instance)

握住你手 2024-08-27 00:59:45

我要做的第一件事就是简化数据。

不要分析绝对数据,而是分析从一个数据点到下一个数据点的变化量。

这是一个快速的单行代码,它将采用 ; 分隔的数据作为输入,并输出该数据的增量。

perl -0x3b -ple'( $last, $_ ) = ( $_, $_-$last )' < test.in > test.out

根据您提供的数据运行它,这是输出:

0;0;20;0;0;-1;-1;-1;0;0;0;0;-1;0;0;0;0;0;0;1;0;1 ;1;1;1;1;1;0;0;2;0;-2;-1;-2;-1;-2;-1;0;-2;-1;1;-1; 0;-1;0;0;0;
0;-1;0;-1;2;4;6;9;7;7;6;-4;-6;-8;-7;-5;-4;0;-1;0;- 1;1;1;0;1;0;-1;1;0;0;0;0;0;0;-1;0;1;1;-1;0;1;0;0;0 ;1;0;-1;1;
2;2;0;1;1;1;1;1;1;1;0;0;1;0;0;-1;-2;-1;-2;-2;-2;-2 ;0;-1;-1;0;-1;0;-1;0;-1;0;1;-1;0;0;0;0;0;0;0;0;-1; 1;1;0;0;0;
0;0;0;0;0;-1;1;-1;0;0;1;0;0;0;0;0;0;0;-1;1;0;0;0;0 ;-1;0;0;0;0;1;0;1;1;0;1;0;0;1;1;1;0;0;0;-1;-1;-2;- 1;0;-2;0;
-1;0;-1;0;1;-1;0;0;-1;0;0;0;1;5;5;7;8;9;4;-7;-5;-8 ;-7;-6;-2;-1;0;0;0;0;0;1;0;0;1;-1;0;1;0;-1;1;0;0;0 ;1;0;0;0;
1;0;1;0;0;0;1;1;0;2;1;1;1;1;1;1;1;1;1;-1;1;0;0;-1; -2;-2;-2;-2;-1;0;-1;-2;-1;0;-1;-1;0;1;-1;1;0;-1;1; -1;1;0;-1;
0;0;0;-1;1;0;0;1;0;-1;0;1;0;0;1;-1;0;-1;1;0;-1;0;0 ;0;0;1;-1;0;1;-1;0;0;0;0;0;0;1;-1;0;1;0;0;2;0;1;0; 1;1;1;-1;
0;-2;0;-1;-2;0;-1;-1;-2;-1;0;0;0;0;0;0;0;0;-1;0;0; 4;3;9;8;11;4;-5;-6;-8;-8;-4;-2;-2;0;0;0;-1;1;0;0;1; 0;0;1;-1;
0;1;0;0;0;1;-1;0;1;1;0;0;0;0;1;0;1;0;1;2;1;1;2;0;1 ;1;1;1;0;0;1;1;0;0;-35;0;0;0;

上面的文本中插入了原本不存在于输出中的换行符。


完成此操作后,找到 qrs 复合体就很简单了。

perl -F';' -ane'@F = map { abs($_) > 2 and $_ } @F; print join ";", @F'< test.out

;;20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;4;6;9;7;7;6;-4;-6;-8;-7;-5;-4;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;5;5;7;8;9;4;-7;-5;-8;-7;-6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;4;3;9;8;11;4;-5;-6;-8;-8;-4;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-35 ;;;

20-35 数据点源自以 0 开头和结尾的原始数据。

要找到其他数据点,您将不得不依赖模式匹配。


如果观察第一个 p 波,您可以清楚地看到一个模式。

0;0;0;0;0;0;1;0;1;1;1;1;1;1;0;0;2;0;-2;-1;-2;-1;-2;-1;0;-2;-1;1;-1;0;-1;0;0;0;0;
#           \________ up _______/   \________ down _________/

但要看到第二个 p 波的模式并不那么容易。这是因为第二个 p 波进一步展开。

0;0;0;1;0;1;1;0;1;0;0;1;1;1;0;0;0;-1;-1;-2;-1;0;-2;0;-1;0;-1;0;1;-1;0;0;-1;0;0;0;
#     \________ up _______/       \________________ down ________________/

第三个 p 波比其他两个 p 波更不稳定。

0;0;0;0;0;1;-1;0;1;0;0;2;0;1;0;1;1;1;-1;0;-2;0;-1;-2;0;-1;-1;-2;-1;0;0;0;0;0;
#                \_______ up ______/  \__________ down __________/

您会以与 p 波类似的方式找到 t 波。主要区别在于它们发生的时间。


这应该足以帮助您入门。

这两个单线仅供示例,不建议日常使用。

The first thing I would do is simplify the data.

Instead of analyzing absolute data, analyze the amount of change from one data point to the next.

Here is a quick one liner that will take ; separated data as input, and output the delta of that data.

perl -0x3b -ple'( $last, $_ ) = ( $_, $_-$last )' < test.in > test.out

Running it on the data you provided, this is the output:

0;0;20;0;0;-1;-1;-1;0;0;0;0;-1;0;0;0;0;0;0;1;0;1;1;1;1;1;1;0;0;2;0;-2;-1;-2;-1;-2;-1;0;-2;-1;1;-1;0;-1;0;0;0;
0;-1;0;-1;2;4;6;9;7;7;6;-4;-6;-8;-7;-5;-4;0;-1;0;-1;1;1;0;1;0;-1;1;0;0;0;0;0;0;-1;0;1;1;-1;0;1;0;0;0;1;0;-1;1;
2;2;0;1;1;1;1;1;1;1;0;0;1;0;0;-1;-2;-1;-2;-2;-2;-2;0;-1;-1;0;-1;0;-1;0;-1;0;1;-1;0;0;0;0;0;0;0;0;-1;1;1;0;0;0;
0;0;0;0;0;-1;1;-1;0;0;1;0;0;0;0;0;0;0;-1;1;0;0;0;0;-1;0;0;0;0;1;0;1;1;0;1;0;0;1;1;1;0;0;0;-1;-1;-2;-1;0;-2;0;
-1;0;-1;0;1;-1;0;0;-1;0;0;0;1;5;5;7;8;9;4;-7;-5;-8;-7;-6;-2;-1;0;0;0;0;0;1;0;0;1;-1;0;1;0;-1;1;0;0;0;1;0;0;0;
1;0;1;0;0;0;1;1;0;2;1;1;1;1;1;1;1;1;1;-1;1;0;0;-1;-2;-2;-2;-2;-1;0;-1;-2;-1;0;-1;-1;0;1;-1;1;0;-1;1;-1;1;0;-1;
0;0;0;-1;1;0;0;1;0;-1;0;1;0;0;1;-1;0;-1;1;0;-1;0;0;0;0;1;-1;0;1;-1;0;0;0;0;0;0;1;-1;0;1;0;0;2;0;1;0;1;1;1;-1;
0;-2;0;-1;-2;0;-1;-1;-2;-1;0;0;0;0;0;0;0;0;-1;0;0;4;3;9;8;11;4;-5;-6;-8;-8;-4;-2;-2;0;0;0;-1;1;0;0;1;0;0;1;-1;
0;1;0;0;0;1;-1;0;1;1;0;0;0;0;1;0;1;0;1;2;1;1;2;0;1;1;1;1;0;0;1;1;0;0;-35;0;0;0;

There are new-lines inserted in the above text not originally present in the output.


After you have done that it is trivial to find the qrs complex.

perl -F';' -ane'@F = map { abs($_) > 2 and $_ } @F; print join ";", @F'< test.out

;;20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;6;9;7;7;6;-4;-6;-8;-7;-5;-4;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5;5;7;8;9;4;-7;-5;-8;-7;-6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;3;9;8;11;4;-5;-6;-8;-8;-4;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-35;;;

The 20 and -35 data points result from the original data starting and ending with 0.

To find the other data points you will have to rely on pattern matching.


If you look at the first p wave, you can clearly see a pattern.

0;0;0;0;0;0;1;0;1;1;1;1;1;1;0;0;2;0;-2;-1;-2;-1;-2;-1;0;-2;-1;1;-1;0;-1;0;0;0;0;
#           \________ up _______/   \________ down _________/

It isn't as easy to see the pattern on the second p wave though. This is because the second one is spread out further

0;0;0;1;0;1;1;0;1;0;0;1;1;1;0;0;0;-1;-1;-2;-1;0;-2;0;-1;0;-1;0;1;-1;0;0;-1;0;0;0;
#     \________ up _______/       \________________ down ________________/

The third p wave is a little more erratic than the other two.

0;0;0;0;0;1;-1;0;1;0;0;2;0;1;0;1;1;1;-1;0;-2;0;-1;-2;0;-1;-1;-2;-1;0;0;0;0;0;
#                \_______ up ______/  \__________ down __________/

You would find the t waves in a similar manner to the p waves. The main difference is when they occur.


This should be enough information to get you started.

The two one-liners are for example only, not recommended for daily use.

梦太阳 2024-08-27 00:59:45

另外两个尖锐的峰谷也是qrs复合体吗?

在我的脑海中,我认为你需要做的是计算该图在每个点的斜率。然后您还需要查看斜率变化的速度(二阶导数???)。如果你发生了突然的变化,那么你就知道你已经达到了某种尖锐的顶峰。当然,您希望限制对变化的检测,因此您可能需要执行类似“如果斜率在时间间隔 T 内变化 X”之类的操作,这样您就不会在图表中发现微小的凸起。

我已经有一段时间没有做过任何数学了……这似乎是一个数学问题;)哦,我也没有做过任何类型的信号分析:)。

只是补充一点。我想你也可以尝试信号平均。例如,对最后 3 或 4 个数据点求平均值。我认为您也可以通过这种方式检测突然的变化。

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.

随遇而安 2024-08-27 00:59:45

我不是这个特定问题的专家,但只是从更一般的知识中得出的结论:假设您知道 QRS 复合体(或其他功能之一,但在本例中我将使用 QRS 复合体)大约发生在长度为 L 的某个固定时间段内。我想知道您是否可以将其视为分类问题,如下所示:

  1. 将信号分割为长度为 L 的重叠窗口。每个窗口要么具有或不具有完整的 QRS 复合体它。
  2. 对每个窗口进行傅立叶变换。您的特征是每个频率的信号强度。
  3. 在一些手工注释的数据上训练决策树、支持向量机等。

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.
和我恋爱吧 2024-08-27 00:59:45

一种很可能产生良好结果的方法是曲线拟合:

  • 将连续波划分为间隔(可能最好将间隔边界设置在 qrs 复合体尖峰之间的中间位置)。一次仅考虑一个间隔。
  • 定义一个模型函数,可用于近似心电图曲线的所有可能变化。这并不像乍看起来那么困难。
    模型函数可以构建为三个函数的总和,参数为每个波的原点(t_)、幅度(a_)和宽度(w_)。

    <块引用>
    <前><代码> f_model(t) = a_p * f_p ((t-t_p )/w_p) +
    a_qrs * f_qrs((t-t_qrs)/w_qrs) +
    a_t * f_t ((t-t_t )/w_t)

    函数f_p(t)f_qrs(t)f_t(t)是一些可用于建模的简单函数三个波中的每一个。

  • 使用拟合算法(例如 Levenberg-Marquardt-Algorithm http:// /en.wikipedia.org/wiki/Levenberg%E2%80%93Marquardt_algorithm)确定每个区间的数据集的拟合参数a_p,t_p,w_p,a_qrs,t_qrs,w_qrs,a_t,t_t,w_t。

    参数 t_p、t_qrs 和 t_p 是您感兴趣的参数。

One approach that will very likely yield good results is curve fitting:

  • Divide the continuous wave into intervals (probably it's best to have the interval borders about half way between the sharp peaks of the qrs complexes). Only consider a single interval at a time.
  • Define a model function that can be used to approximate all possible variations of electrocardiographic curves. This is not as difficult as it seems first.
    The model function can be constructed as a sum of three functions with parameters for the origin (t_), amplitude (a_) and width (w_) of each wave.

       f_model(t) = a_p   *  f_p  ((t-t_p  )/w_p) + 
                    a_qrs *  f_qrs((t-t_qrs)/w_qrs) +
                    a_t   *  f_t  ((t-t_t  )/w_t)
    

    The functions f_p(t), f_qrs(t), f_t(t) are some simple function that can be uses to model each of the three waves.

  • Use a fitting algorithm (e.g. the Levenberg-Marquardt-Algorithm http://en.wikipedia.org/wiki/Levenberg%E2%80%93Marquardt_algorithm) to determine the fitting parameters a_p, t_p, w_p, a_qrs, t_qrs, w_qrs, a_t, t_t, w_t for the dataset of each intervall.

    The parameters t_p, t_qrs and t_p are the ones you are interested in.

恬淡成诗 2024-08-27 00:59:45

这是一个很棒的问题!我有一些想法:

动态时间扭曲可能是一个有趣的工具。您将为三个类建立“模板”,然后使用 DTW 可以看到模板和信号“块”之间的相关性(将信号分解为 0.5 秒位,即 0-.5 。 1-.6 .2-.7...)。我已经使用类似的方法对加速度计数据进行步态分析,效果相当好。

另一种选择是组合信号处理/机器学习算法。再次将您的信号分成“块”。再次制作“模板”(每个课程需要十几个左右),采用 FFT 每个块/模板,然后使用 朴素贝叶斯分类器(或另一个 ML 分类器,但是注意:应该删掉它)以对您的三个类别中的每个类别进行分类。我还在步态数据上进行了尝试,对于相对复杂的信号,能够获得高达 98% 的精确度和召回率。让我知道这是如何工作的,这是一个非常令人兴奋的问题。

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.

抚笙 2024-08-27 00:59:45

小波变换”可能是相关关键字。我曾经参加过一个演讲,有人使用这种技术来检测嘈杂心电图中的不同心跳阶段。

就我有限的理解而言,它有点像傅立叶变换,但使用(缩放)副本(在您的情况下是心跳形状的)脉冲。

"Wavelet transform" may be a relevant keyword. I've once attended a presentation by someone who used this technique to detect different heartbeat phases in a noisy ecg.

As far as my limited understanding goes, it's somewhat like a Fourier transform, but using (scaled) copies of a, in your case heartbeat-shaped, pulse.

夏末 2024-08-27 00:59:45

首先,任何给定的绘图中都可能缺少标准心电图波的各个组成部分。这样的情节通常是不正常的,通常表明存在某种问题,但你不能保证它们确实存在。

其次,识别它们既是一门艺术,也是一门科学,尤其是在出现问题的情况下。

我的方法可能是尝试训练神经网络来识别组件。您可以给它前 30 秒的数据,进行标准化,因此最低点为 0,最高点为 1.0,它将有 11 个输出。非异常评级的输出将是最后 10 秒的权重。 0.0 表示距现在 -10 秒,1.0 表示现在。输出将为:

  1. 最近 P 波开始的位置
  2. 最近 P 波结束的位置
  3. 最近 P 波的异常评级,其中一个极端“不存在”。
  4. 最近的 QRS 复合波开始的位置
  5. 最近的 QRS 复合波的 Q 部分变成 R 部分的位置。
  6. 最近 QRS 波群的 R 部分变成了 S 部分。
  7. 最近 QRS 波群结束的位置。
  8. 最近 QRS 波群的异常评级,其中一个极端是“不存在”。
  9. 最近的 T 波开始的地方。
  10. 最近的 T 波结束的地方。
  11. 最近 T 波的异常评级,其中一个极端为“不存在”。

我可能会仔细检查人们建议的其他一些类型的分析,或者使用这些其他类型的分析以及神经网络的输出来给你答案。

当然,这种对神经网络的详细描述不应被视为规定性的。我确信我不一定会选择最佳的输出,例如,我只是提出了一些关于它们可能是什么的想法。

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.

南风起 2024-08-27 00:59:45

小波已被证明是在此类数据中定位峰值的最佳工具,其中峰值“不同大小” - 小波的缩放特性使其成为此类多尺度峰值检测的理想工具。这看起来像一个非平稳信号,因此使用 DFT 并不是一些人建议的正确工具,但如果这是一个探索性项目,您可以考虑使用信号的频谱(基本上使用自相关的 FFT 进行估计) )

这里是一篇很棒的论文,回顾了几个峰值检测方法 - 这将是一个很好的起点。

——保罗

Wavelets have been shown to be the best tool for locating peaks in this type of data where the peaks are "different sizes" - the scaling properties of wavelets make it an ideal tool for this type of multi-scale peak detection. This looks like a non-stationary signal so using a DFT would not be the right tool as some have suggested, but if this is an exploratory project you could look at using the spectrum of the signal (estimated using essentially the FFT of the autocorrelation of the signal.)

Here is a great paper reviewing several peak detection methods - this would be a good place to start.

-Paul

放赐 2024-08-27 00:59:45

我还没有彻底阅读对方的答案,但我扫描了它们,我注意到没有人建议查看傅里叶变换来分割这些波。

对我来说,这似乎是调和分析在数学中的明确应用。我可能遗漏了几个微妙的点。

离散傅里叶变换系数为您提供构成您的不同正弦分量的幅度和相位离散时间信号,这本质上就是您想要找到的问题状态。

不过我可能在这里遗漏了一些东西......

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文