两个信号之间的相似性:寻找简单的方法 [英] Similarity between two signals: looking for simple measure

查看:1239
本文介绍了两个信号之间的相似性:寻找简单的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在A组中有20个信号(时程),在B组中有20个信号.我想找到一种度量来表明A组与B组不同.例如,我为每个组中的信号运行了xcorr团体.但是现在我需要以某种方式比较它们.我试图获取每个xcorr对的最大幅度,这是对最大相似度的一种度量.然后,我比较了两组之间的所有这些值,但没有差异.我还可以做些什么?我也可以比较频谱,但是我又一次不知道要使用哪个频率段. 任何建议/参考都将受到高度赞赏!

每组中大约有20个信号.这些是我的样品.我不知道a-prirori有什么区别.在这里,我为每个组带来了9个采样信号,以及它们对信号子集(组1与组1,组2,组2与组2,组1与组2)的自相关和互相关.我看不出明显的区别.我也不明白您打算如何比较互相关,我应该走哪个峰?所有信号均被去趋势化和z评分.

在此处输入图片说明

解决方案

好吧,这可能太简单了,答案也太复杂了,但也许值得.

为了比较信号,我们确实必须建立一些比较标准.这可能是很多事情.如果我们想要看起来看起来相似的信号,我们将进行时域分析.如果我们谈论的是听起来相似的音频信号,则我们关心的是频率或时频分析.如果假定信号代表噪声,则信号方差应该是一个很好的措施.通常,我们可能希望将各种措施结合起来使用.我们可以使用加权索引来做到这一点.

首先让我们确定一下我们拥有的东西:有两组信号:A组和B组.我们想要某种度量,以显示A组与B组不同.信号被去趋势.

我们在A中接收信号a,在B中接收信号b.我们可以比较的事物列表:

  • 时域相似(静态):就地相加并求和.

  • 时域相似(带有shift *):对每个信号进行fft运算, 相乘,然后进行ifft. (我相信这等同于matlab的xcorr.)

  • 频域相似性(静态**):对每个信号进行fft运算, 乘以和.

  • 频域相似性(带有shift *):将二者相乘 信号并采取英尺.这将显示信号是否共享相似的信号 光谱形状.

  • 能量(或功率,如果长度不同)的相似性:将两者平方 信号并对其求和(并除以信号长度获得功率). (自从 信号被去趋势,这应该是信号方差.)然后 减去并取绝对值来测量信号方差 相似性.

*(带偏移)-您可以选择对整个相关矢量求和以测量总体一般相关,可以选择仅对相关矢量中超过某个阈值的值求和(就像您期望回波一样)一个信号),或者只是从相关矢量中取最大值(其中其索引是第二个信号的偏移,从而导致与第一个信号的最大相关).同样,如果达到最大相关所需的移位量很重要(即,只有在只有相对较小的移位才能达到最大相关点的情况下信号才相似),则可以合并索引位移的度量. /p>

**(频域相似性)-例如,如果您只关心更高频率的结构(fs/4及更高频率),则可能希望屏蔽不关心的部分频谱,您可以这样做:

mask = zeros(1,n); mask(n/4):
freq_static = mean(fft(a) .* fft(b) .* mask);

此外,我们可能想要实现如下的循环相关:

function c = circular_xcorr(a,b)
c = xcorr(a,b);
mid = length(c) / 2;
c = c(1:mid) + c(mid+1:end);
end

最后,我们选择重要或相关的特征,并创建一个加权索引.示例:

n = 100;
a = rand(1,n); b = rand(1,n);
time_corr_thresh = .8 * n; freq_corr_thresh = .6 * n;
time_static = max(a .* b);
time_shifted = circular_xcorr(a,b);    time_shifted = sum(time_shifted(time_shifted > time_corr_thresh));
freq_static = max(fft(a) .* fft(b));
freq_shifted = fft(a .* b);     freq_shifted = sum(freq_shifted(freq_shifted > freq_corr_thresh));
w1 = 0; w2 = 1; w2 = .7; w3 = 0;
index = w1 * time_static + w1 * time_shifted + w2 * freq_static + w3 * freq_shifted;

我们为每对信号计算索引.

我希望信号表征的轮廓对您有所帮助.如有任何不清楚之处,请发表评论.

I have 20 signals (time-courses) in group A and 20 signals in group B. I want to find a measure to show that group A is different from group B. For example, I ran xcorr for the signals within each group. But now I need to compare them somehow. I tried to take a maximal amplitude of each xcorr pair, which is sort a measure of maximal similarity. Then I compared all these values between two groups, but there was no difference. What else can I do? I can also compare frequency spectrum, but then I again do not know what frequency bin to take. Any suggestions / references are highly appreciated!

I have about 20 signals in each group. Those are my samples. I do not know a-prirori what might be the difference. Here I bring the 9 sample signals for each group, their auto-correlation and cross-correlation for a subset of signals (group 1 vs. group 1, group 2 vs. group 2, group 1 vs. group 2). I do not see any evident difference. I also do not understand how you propose to compare cross-correlations, what peaks should I take? All the signals were detrended and z-scored.

enter image description here

解决方案

Well, this may be too simplistic of an answer, and too complex of a measure, but maybe its worth something.

In order to compare signals, we really have to establish some criterion by which we compare them. This could be so many things. If we want signals that look visually similar, we perform time domain analysis. If we are talking about audio signals that sound similar, we care about frequency or time-frequency analysis. If the signals are supposed to represent noise, then signal variance should be a good measure. In general we may want to use a combination of all sorts of measures. We can do this with a weighted index.

First let's establish what we have: there are two sets of signals: set A and set B. We want some measure that shows set A is different from set B. The signals are detrended.

We take signal a in A and signal b in B. The list of things we can compare:

  • Similarity in time domain (static): Multiply in place and sum.

  • Similarity in time domain (with shift*): Take fft of each signal, multiply, and ifft. (I believe this equivalent to matlab's xcorr.)

  • Similarity in frequency domain (static**): Take fft of each signal, multiply, and sum.

  • Similarity in frequency domain (with shift*): Multiply the two signals and take fft. This will show if the signals share similar spectral shapes.

  • Similarity in energy (or power if different lengths): Square the two signals and sum each (and divide by signal length for power). (Since the signals were detrended, this should be signal variance.) Then subtract and take absolute value for a measure of signal variance similarity.

* (with shift) -- You could choose to sum over the entire correlation vector to measure total general correlation, you could choose to sum only values in the correlation vector that surpass a certain threshold value (as if you expect echoes of one signal in the other), or just take the maximum value from the correlation vector (where its index is the shift in the second signal that results in maximal correlation with the first signal). Also, if the amount of shift that it takes to reach maximal correlation is important (i.e. if signals are similar only if it takes relatively small shift to reach the point of maximal correlation), then you can incorporate a measure of the index displacement.

** (frequency domain similarity) -- You may want to mask part of the spectrum that you're not concerned with, for instance, if you only care about the more high frequency structures (fs/4 and up), you could do:

mask = zeros(1,n); mask(n/4):
freq_static = mean(fft(a) .* fft(b) .* mask);

Also, we may want to implement a circular correlation like so:

function c = circular_xcorr(a,b)
c = xcorr(a,b);
mid = length(c) / 2;
c = c(1:mid) + c(mid+1:end);
end

Finally, we choose the characteristics that are important or relevant, and create a weighted index. Example:

n = 100;
a = rand(1,n); b = rand(1,n);
time_corr_thresh = .8 * n; freq_corr_thresh = .6 * n;
time_static = max(a .* b);
time_shifted = circular_xcorr(a,b);    time_shifted = sum(time_shifted(time_shifted > time_corr_thresh));
freq_static = max(fft(a) .* fft(b));
freq_shifted = fft(a .* b);     freq_shifted = sum(freq_shifted(freq_shifted > freq_corr_thresh));
w1 = 0; w2 = 1; w2 = .7; w3 = 0;
index = w1 * time_static + w1 * time_shifted + w2 * freq_static + w3 * freq_shifted;

We compute this index for each pair of signals.

I hope that this outline of signal characterization helps. Comment if anything is unclear.

这篇关于两个信号之间的相似性:寻找简单的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆