Hello,
I am running an experiment where subjects are completing a 3d reach task with a tool while I am tracking the tool tip position. As a result, I have a matrix of (x,y,z) coordinates (@ 20Hz) captured from a tool tracking device of the reach between two stationary targets. While the distances between the targets is fixed (4.5cm), the reference frame of the tracking devise is not fixed (as it is a portable device). Subsequently, the tracked target positions are relative across all subjects.
I have applied the following code to generate a scatter of the centered and rotated data (XYZ):
xyz0=mean(XYZ);
A=bsxfun(@minus,XYZ,xyz0); %center the data
[U,S,V]=svd(A,0);
A_rot = A*V; %V(:,1) is the direction of most variance
A_final = bsxfun(@minus,A_rot,[min(A_rot(:,1)) 0 0]);
scatter3(A_final(:,1),A_final(:,2),A_final(:,3));
I would like to
  1. Locate the centroid of each target
  2. determine the vector distance between the target centroids
  3. determine the time taken to move fro target 1 to target 2
Is cluster analysis required to determine the cluster centroids? If so, may someone suggest a good reference? If I use the mean of each cluster, how can I determine the time taken to move from target 1 to target 2? I assume that I must find the data point that is closest to the target 1 centroid and count the number of frames between that point and the point nearest target 2's centroid?
Any advice and/or references would be greatly appreciated. Many thanks!

댓글 수: 1

ChrisH
ChrisH 2017년 9월 15일
Alternatively, a simple way of finding the positions of the two targets may be to find the two positions where the tool tip lingers for a period of time. i.e if the tool tip is within a specific range for more than x-frames than that position is a target.
Any suggestions?

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2017년 9월 15일

0 개 추천

Assuming they start and end at the target, why not just take the mean (x,y,z) of the first 20 points and the last 20 points?

댓글 수: 9

ChrisH
ChrisH 2017년 9월 15일
Great idea thanks. For data that represents multiple repetitive reaches between the same two targets, would you have an idea how I may index the frequency between each consecutive reaches?
i.e determine the position of the start (mean first 20 points) and end target (mean last 20 points), then determine the number of times a reach was made between the targets (within a positional threshold).
Thanks again!
Sort by x and then take the first and last n points:
n = 20; % Whatever
[sorted_x, sortOrder] = sort(x, 'ascend');
sorted_y = y(sortOrder);
leftHandPointsX = sorted_x(1:n);
leftHandPointsY = sorted_y(1:n);
rightHandPointsX = sorted_x(end-n+1:end);
rightHandPointsY = sorted_y(end-n+1:end);
Now let's call x1 the rightmost x value of the left cluster of points, and x2 the leftmost coordinate of the right cluster. So now you want to know the number of times x has a value in the range between x1 and x2, right? In other words, how many times does the coordinate cross from the left side to the right side or from the right side to the left side. So you can make a logical vector of where x is in the in-between zone:
% Define range to look in:
x1 = leftHandPointsX(end);
x2 = rightHandPointsX(1);
% Get logical vector of whether x is in that range
% Use original x, NOT sorted_x!
inRange = x > x1 & x < x2; % Use &, not &&!
% Now you need to know how many times it's in that range
% so if you have the Image Processing Toolbox, simply use bwlabel:
[labeledGroups, numtimesInRegion] = bwlabel(inRange);
numtimesInRegion will be the number of times the tool traversed from one side to the other side. You can also count the number of times going in each direction but it's a few more lines of code. Hopefully you don't need that but if you do, attach your data.
ChrisH
ChrisH 2017년 9월 18일
편집: ChrisH 2017년 9월 18일
I have run your code, which, on a 4 reach data set (XYZ attached as .mat) returns numtimesInRegion = 8 which is expected for two targets.
Is there a way of determining the time taken to complete a reach given a data frequency of 20Hz? Is it correct to assume that labeledGroups gives a count of the number of data frames the tool tip is in each target region?
For example; labeledGroups = 1,1,1,1,0,0,2,2,2,2,2
Hence (@ 20Hz) the tooltip is at region1 for 0.2s, at region2 for 0.25s and between regions for 0.1s?
Thanks again!
ChrisH
ChrisH 2017년 9월 18일
"You can also count the number of times going in each direction but it's a few more lines of code. Hopefully you don't need that but if you do, attach your data."
I think that this is what I need to do given 3D data.
Image Analyst
Image Analyst 2017년 9월 18일
OK. I'll wait for it, if you're still interested.
ChrisH
ChrisH 2017년 9월 19일
Data attached (same data from the previous comment). Thanks!
Image Analyst
Image Analyst 2017년 9월 19일
It looks like there is some jitter in the data, like it went into the range for just a sample or two and then back out. You might have to work on "debouncing" the data somehow. Anyway, what I've done so far is attached.
ChrisH
ChrisH 2017년 9월 20일
Thank you very much! Yeah, the position sensor does not calibrate the tool tip properly it seems, I am working on fixing this.
I cant seem to fix the variability in the tool tip calibration using the software that comes with the position sensor. Are you able to assist me with figuring out how to extrapolate tool tip position from the rigid body marker coordinates? There are four markers fixed on the rigid body that are tracked simultaneously. The first frame of data looks like the following (in mm):
Tx Ty Tz
A 97.352 -120.289 -958.28
B 109.696 -144.125 -945.219
C 155.972 -118.524 -929.248
D 125.658 -101.497 -949.232
From this, I would like to track the tool tip which is 30cm from marker C (see image of tool with rigid body attached), along a vector between marker A and C. I know that I cannot simply extrapolate the vector A-C as the rotational relationship between markers A-D will not be preserved.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2017년 9월 15일

댓글:

2017년 9월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by