如何实现匹配过滤器

Mik*_*nio 2 matlab filter

我有一个模板。我通过对模板的傅立叶变换的共轭进行逆傅立叶变换来计算匹配滤波器的脉冲响应。我想使用 Matlab 中的“过滤器”命令对我可用的 EEG 通道之一执行匹配过滤操作。使用滤波器命令系数“b”是我的脉冲响应?此外,我想实现 Matlab 代码来对匹配滤波器的输出进行阈值检测以检测峰值。我该如何实现?

nis*_*pio 6

这是你的开始,

% A template is given
temp = randn(100,1);

% Create a matched filter based on the template
b = flipud(temp(:));

% For testing the matched filter, create a random signal which
% contains a match for the template at some time index
x = [randn(200,1); temp(:); randn(300,1)];
n = 1:length(x);

% Process the signal with the matched filter
y = filter(b,1,x);

% Set a detection threshold (exmaple used is 90% of template)
thresh = 0.9

% Compute normalizing factor
u = temp.'*temp;

% Find matches
matches = n(y>thresh*u);

% Plot the results
plot(n,y,'b', n(matches), y(matches), 'ro');

% Print the results to the console
display(matches);
Run Code Online (Sandbox Code Playgroud)

正如安德烈亚斯在他的回答中提到的那样,不需要傅立叶变换。如果您有一个时域模板,那么它的匹配过滤器只是它自身的时间反转版本(我使用 实现flipud)。随着您的进行,您会发现有许多细微差别需要解决。这段代码效果很好,因为我从头到尾都在控制之中,但是一旦您开始使用真实数据,事情就会变得更加复杂。例如,选择合适的阈值需要一些有关您将使用的数据的知识。

事实上,根据信号的性质等,峰值检测可能是一项非常重要的任务。在我的情况下,峰值检测很容易,因为我的信号与模板完全不相关,除了中间的点,并且我也确切地知道我期望看到的幅度。所有这些假设都是对我用来演示概念的问题的过度简化。