Detect main part of a signal

32 views (last 30 days)
Julio
Julio on 4 Nov 2024 at 15:17
Commented: Star Strider on 7 Nov 2024 at 13:28
Hi, I would like to receive some help about one question:
Need to know how to detect the real signal in an EMG file (as image 1).
Till now, I know how to find the absolute center with this code:
[F, C]=size(D.data);
center=(F-mod(F,2))/2;
x=x(center-1500:center+1500,:);
and then I search results on both sides of that middle point, but as you can see, it doesn't return symetric values (image 2).
How can I add something to that code to detect the interesting area?
Thanks, regards

Accepted Answer

Star Strider
Star Strider on 4 Nov 2024 at 16:14
I usually use the envelope function, usually using the 'peak' option, and then test for the first instance of those (ususlly the upper envelope) exceds a ceertain threshold.
To illustrate —
Fs = 1E+3;
L = 60;
t = linspace(0, Fs*L, Fs*L+1).'/Fs;
EMG = randn(size(t))/10;
N = numel(t((t>=15 & t<=45)));
EMG(t>=15 & t<=45) = randn(N,1);
figure
plot(t, EMG)
grid
xlabel('Time')
ylabel('Amplitude')
title('Original')
[eu,ed] = envelope(EMG, 50, 'peak');
thrshld = max(eu(t>0 & t<5));
sigstart = find(eu >= thrshld*1.5, 1, 'first');
sigend = find(eu >= thrshld*1.5, 1, 'last');
figure
plot(t, EMG, DisplayName="Signal")
hold on
plot(t, eu, '-r', DisplayName="Upper Envelope")
hold off
grid
xline(t([sigstart sigend]), '--k', LineWidth=2, DisplayName="Signal Borders")
xlabel('Time')
ylabel('Amplitude')
title('Original With upper Envelope & Signal Borders')
legend('Location','best')
.
  2 Comments
Julio
Julio on 7 Nov 2024 at 13:17
Moved: Star Strider on 7 Nov 2024 at 13:27

Thank you!

Star Strider
Star Strider on 7 Nov 2024 at 13:28
As always, my pleasure!

Sign in to comment.

More Answers (0)

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!