How do I cut the signal into several parts?

10 visualizaciones (últimos 30 días)
Sh Sh
Sh Sh el 21 de Oct. de 2021
Editada: Image Analyst el 22 de Oct. de 2021
Welcome
I have 16-channel sEMG signals. I want to take the signal from each channel, which consists of a set of movements, including A rest movement is followed by a movement, then a rest movement, followed by the same movement, a second attempt, and so on until you complete 6 repetitions of one movement between each repetition and the last rest. I know the number of samples for each movement, so how can I remove the rests between iterations of the EMG signal, which represents zeros samples, and only get the repeats, each iteration alone

Respuesta aceptada

Jon
Jon el 21 de Oct. de 2021
Editada: Jon el 21 de Oct. de 2021
You can use logical indexing. So if you wanted to remove the portion of a signal x where it equaled zero you could do something like this
idl = x==0
xnew = x(idl)
or more compactly
xnew = x(x==0)
This just removes the zero portions. If you want individual vectors for each non-zero piece it would take a little more work
Here is a way to do it. It seems like there is probably a more elegant solution but I think this approach will work. Note it assumes that the only time the signal is exactly zero is when at rest. It also assumes that the data starts with movement.
% define an example vector with rest portions where value is zero
x = [1 2 3 4 0 0 0 5 6 9 0 0 2 3 8 0 0 4 9 5];
% get logical indices for non-rest portions
isMotion = x~=0;
% find transitions from rest to movement .. .these will have a value of 1 and -1
% respectively
jmp = diff([0 isMotion 0]); % pad with zeros to ensure transition at begin and end
% find beginning and end of movement segments
iStart = find(jmp == 1);
iEnd = find(jmp == -1)-1;
% assign segments to structure
% (can't put them in an array unless we know all motions have same length)
numSeg = numel(iStart);
xseg(numSeg).x = 0; % preallocate
for k = 1:numel(iStart)
xseg(k).x = x(iStart(k):iEnd(k));
end

Más respuestas (1)

Image Analyst
Image Analyst el 22 de Oct. de 2021
Editada: Image Analyst el 22 de Oct. de 2021
Please post the graph along with annotations about where you want to do things to the signal.
Did you try thresholding?
quietIndexes = y < someValue; % for example someValue could be 0 or 0.001 or whatever.
Then you can use bwlabel() to label quiet stretches or high signal stretches, take 6 of them using ismember(), and get their lengths with regionprops() (if you want).
labeledSignal = bwlabel(~quietIndexes);
first6 = ismember(labeledSignal, 1:6);
props = regionprops(first6, 'Area');
allLengths = [props.Area];
% Remove quiet parts so all signals run together
output = y(first6);

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by