Help with finding the index corresponding to change in the matrix

9 views (last 30 days)
Hello everyone! I am working on project where motion data is collected. The subject begins in a still position for a few seconds and then begins to do a movement or exersise. I've attached a picture of one trial with an arrow pointing to the time that I would like to find the index of. So far I've tried finding the mean and std dev of the signal and then processing the data with a FOR loop to find the outliers. This doesn't really work, especially if the data is noisy or the exercise involves a lot of movement. I also thought that using 'diff' to find the change between each index would be helpful but it mostly just amplified the noise. I was also thinking of using a median filter to smooth the data which will likely help, but I'm still not sure how to find the point when the subject begins to move.
  2 Comments
dpb
dpb on 5 Jun 2016
That's a pretty non-quiescent "still position"; how about modifying the data collection to add a trigger signal?
Image Analyst
Image Analyst on 5 Jun 2016
You have to give us some rule. For example one rule might be "after a period of time of at least 2 where the signal is completely above 5, find the point at the top of the signal where it falls below 5."
Another rule could be "find a monotonic drop in signal of at least 4, then find the top of that dropping signal."
We don't know what rule you'd like.

Sign in to comment.

Answers (2)

John BG
John BG on 6 Jun 2016
max
perhaps you want to try the following:
1.- your signal
clearvars
A=imread('graph1-2.jpg');
2.- turn it into binary map
A(find(A>125))=255; A(find(A<=125))=0; % basic image clean-up, converting to binary map
A(:,:,2)=and(A(:,:,2),A(:,:,3));A(:,:,3)=[];
A=and(A(:,:,1),A(:,:,2));
A=logical(~A); %figure(2);imshow(A)
figure(1);imshow(A)
3.- thin line to 1 pixel only
[sz1A sz2A]=size(A);
B=A;
L0=zeros(sz1A,1);
y=[]
for k=1:1:sz2A
L=B(:,k)';
px=find(L==1);
if length(px>1)
px=min(px);
y=[y px]; % build signal
L1=L0;
L1(px)=1;
B(:,k)=L1;
end;
end
figure(2);imshow(B)
4.- find position of the sharpest drop
y=abs(y-255);
figure(3);plot(y);
yd=diff(y);
figure(4);plot(yd);
% the last sample of yd is just y zeroing at the end of the sequence
yd(end)=[];
yd(yd>0)=0
yd2=-yd;
figure(5);plot(yd2);
the sharpest drop that you want to locate takes place around the sharpest peak of yd2
find(yd2==max(yd2))
=
238.00
If you find this answer of any help solving your question,
please click on the thumbs-up vote link, or mark it as accepted answer
thanks in advance
John

Jan
Jan on 25 Feb 2017
The problem is not trivial. Note that the steeped drop appears in the last frame:
This means, that you search for a reliable indentification of a steep (not steepest) and tall descent after the first plateau. This tool must contain some heuristics and without more information this is hard to guess. E.g. the frequency spectrum of the noise matters and typical accelerations or signal patterns.

Community Treasure Hunt

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

Start Hunting!