How to cut segment of EMG signal to start at a specific point?

3 次查看(过去 30 天)
So I have a signal that has 22392 frames. However, the signal is NaN until around the 17000th frame. Before smoothing and rectifying the data, I want to truncate the data so I am only processing the frames from 17000th onwards. Is there a way to do so? This is my code so far:
%process data
lowpass=500;
highpass=30;
highpassglute=20;
smoothlowpass=2;
window=0.5; %seconds
window_frames=window*Fs;
kernel=gausswin(window_frames);
normkernel=kernel./sum(kernel);
[B,A]=butter(4,[highpass/(Fs/2),lowpass/(Fs/2)]);
[C,D]=butter(4,[highpassglute/(Fs/2),lowpass/(Fs/2)]);
%Block
for i=1:3
Processed.Block(i).Rlong=conv(abs(filtfilt(B,A,Block(i).Rlong)),normkernel,'same');
Processed.Block(i).Llong=conv(abs(filtfilt(B,A,Block(i).Llong)),normkernel,'same');
Processed.Block(i).Rrectus=conv(abs(filtfilt(B,A,Block(i).Rrectus)),normkernel,'same');
Processed.Block(i).Lrectus=conv(abs(filtfilt(B,A,Block(i).Lrectus)),normkernel,'same');
Processed.Block(i).Rgmed=conv(abs(filtfilt(C,D,Block(i).Rgmed)),normkernel,'same');
Processed.Block(i).Lgmed=conv(abs(filtfilt(C,D,Block(i).Lgmed)),normkernel,'same');
Processed.Block(i).Reo=conv(abs(filtfilt(B,A,Block(i).Reo)),normkernel,'same');
Processed.Block(i).Leo=conv(abs(filtfilt(B,A,Block(i).Leo)),normkernel,'same');
end
Right now I am getting the following errors, which I assume is from the NaN frames in the beginning.
Error using filtfilt
Expected input to be finite.
Error in filtfilt>efiltfilt (line 114)
validateattributes(x,{'double'},{'finite','nonempty'},'filtfilt');
Error in filtfilt (line 89)
y=efiltfilt(b,a,x);
Thank you in advance!

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by