Thanks to all that responded to my queries. It has been a while since I posted to Biomch-L and the response was quite overwhelming. I had more than 30 responses within 24 hours to sending the query. Given the specifics of my situation (I am helping out another lab that would like to continue to collect more data with PhaseSpace and have ongoing software to analyze it), I have decided to concentrate on two options for now:
BodyMech, a Matlab open source package
http://www.bodymech.nl/
and
KineMat, a Matlab toolbox
http://isbweb.org/software/movanal/kinemat/index.html
The text of most of the replies are pasted below. I did not include some duplicate postings.
take care,
df
Dan Ferris, Ph.D.
Associate Professor
Division of Kinesiology
Department of Biomedical Engineering
Department of Physical Medicine and Rehabilitation
University of Michigan
http://www-personal.umich.edu/~ferrisdp/
currently on sabbatical at:
Institute for Neural Computation
UC San Diego
(858) 534-9662
ferrisdp@umich.edu
MaxMate is a fairly straight forward excel based program that does just
what you're looking for.
http://www.innovision-systems.com/Products-MaxMATE.aspx
http://isbweb.org/software/movanal/kinemat/index.html
http://www.bodymech.nl/ - free matlab program/code that might give you what you need+ good documentation.
You may have received better responses from your BIOMCH-L query, but I do have a code that I developed during graduate school. I used it to determine the 3 clinical translations and 3 clinical rotations (described by grood-suntay, JBME 1983) for a lab experiment I conducted as the TA. The input I used was from imaging software that computed the time-dependent Cartesian dimensions of markers rigidly attached to the femur and tibia of a bovine knee. Kinematic blocks with 3 markers were attached to both the femur and tibia. A coordinate system was embedded in the femur and tibia (via digitizer) and the rotations/translations were computed between the embedded systems. A photo of the setup can be seen in one of our publications (Lujan et al. JBME, 2007).
In the biomechanics class I TA'd, the students had to answer questions on the code, therefore in the main program I'm sending you (gsuntay_solution.m), there are lots of comments and questions. The other .m files are subfunctions. If you want to run the program, I provided a zip file with all the programs and input from a class experiment where I flexed a bovine knee. Just put all the zipped files in the same folder, open gsuntay_ta.m and hit "run".
I think the code you are seeking is dependent on exactly how many markers
you have and where they are placed - these things affect how the vectors of
the local reference frames are defined. There is a relatively easy method
for these calculations described by Vaughan et al. in, "Dynamics of Human
Gait," which can be freely downloaded from the link below (see Appendix B,
pp. 94-96 for joint angles). If you don't find code that you can just plug
in, the Vaughan et al. book might be a helpful reference for writing some
code yourself.
http://www.kiboho.co.za/GaitCD/gaitbook.htm
have a look at the International Shoulder Group site
(www.internationalshouldergroup.org). There should be software
available for the calculation of local coordinate systems. Otherwise,
I do have .m files that will do the job. I will get in touch with the
ISG webmaster to make sure that they become available through that site.
Visual 3D is a nice tool to calculate joint kinematics from raw
tracked data.
Is Christoph Reinschmit's (sp??) code still posted to the ISB web site?
We've used that in the past... I needs some fiddling to work with specific situations (different marker sets, etc.) but it otherwise seems to work pretty well.
That sounds like it was an electromagnetic system. Correct? Do you know what make/model? Each manufacturer can spit out different info. Or perhaps you already know exactly what info is in the files? I'm guessing it would be x,y,z components of the vector that points to the local frame from the global. The rotations are probably a sequence of angles but we need to know the axes of rotation and the order of rotations. Some systems spit out rotation matrices directly. With this information you can determine the position and orientation of each marker relative to the global ref. frame.
Also, one must assume the markers were rigidly fixed to each segment. You then need to know what was the position and orientation of the marker's fixed location relative to the local axes of the segment. So, if you know where the segment was relative to the marker, and you know where the marker was in the global, then you know where the segment was in the global.
If I'm saying things you already knew, I apologize. But, I'm afraid that if you have nothing more than some output data files, it not be sufficient information.
I just wrote this little script to check the output of another
simulation. Input are skin marker coordinates (markers only on lower
limbs), and output are joint angles for hip, knee and ankle as well as
the rotation matrices between anatomical coordinate systems (which you
probably don't need).
Reading other people's code is often quite difficult, but maybe it helps.
I am a grad student at the University of Pittsburgh and I am pretty familiar with calculating joint angles using Matlab. This is the method I employ:
Step 1. Calculate anatomical coordinate systems with the long axis of the segment aligned with the y-axis. For the lower leg I would align the y axis from the Ankle joint center to the Knee joint center. For the upper leg I would align the y axis from the knee joint center to the hip joint center. Then I would use other markers to calculate two more vectors. Using the vector cross porducts, gives three direction vectors. These three vectors {x, y, z} make up the rotation matrix from global coordinates to the anatomical coordinate system.
Step 2: Determine the joint angle using Euler decomposition. Determine the rotation matrix between the two joint segments (i.e, thigh with respect to shank). From this rotation matrix decompose the angles to determine the included joint angle.
If you need more help just let me know and I should be able to send you some code.
That is an unusual data format, looks more like animation data.
If you know the exact meaning of the rotation parameters in your data, you can transform those into rotation matrices, calculate R1*inv(R2) to get orientation of one bone relative to the other, and then decompose that into standard Grood-Suntay joint angles (the Rxyzsolve etc. functions in Kinemat).
The ISB website has scripts and functions based on the SVD function in matlab and the Joint Coordinate System style of Euler rotations. Although I think these days you need to be a member to access them. I did download them before this happend so if you would like them I can forward them next week when I return to work.
Absolute angles can be calculated with the built in functions atan or atan2, and relative angles can be calculated by the cosine law or similiar which is acos[(a^2+b^2-c^2)/2ab] in matlab. 'a and b' are lengths of lines joining proximal and distal joints to the joint of interest, 'c' is the length of a line between the proximal and distal joints.
when calculating angles from 2D marker co-ordinates, I did the following, which may help you:
1. calculate segment lengths using marker co-ordinates for two adjacent segments
2. use these as vector lengths
3. take the arc-cosine of the dot product of these two vectors to give you joint angle - you can output this as either degrees or radians.
there's a fair amount of literature available on how to calculate angle using dot product
please have a look at our open source software project Bodymech
www.bodymech.nl
It has been a while since the last update.
There is no of the shelf full body model,
(we're working on that as well)
but you can configure it to your own needs
if you're a member of ISB all the code can be downloaded after logging into the website (www.isbweb.org). You just need to acknowledge the source when using any of this code.
if you want I have a code only for upper arm but it dipens on
where do you want to put markers.
Also you can find this explanation in my paper about carrying angle
evaluation of the elbow joint. This work is published in J Shoulder
and Elbow Joint Surgery
Matlab is an excellent tool for calculating joint angles from marker cartesian coordinates. I have been working with this software and I really like it. What exactly do you need?
If the data you have include yaw, tilt and roll for each marker
relative to a fixed origin, and each marker is fixed to a segment, are
these values not equivalent to the segment angles? I'm not terribly
familiar with active marker system, but it would seem the marker data
already has the data you are looking for.
I've written matlab code in the past for calculating joint angles, so I might be able to help you out with your application.
You need three markers per segment to calculate 3D angles. Sometimes
with less than three you can calculate missing markers based on
markers on adjacent segments. With one marker per segment I don't see
any way of doing this. You may be able to calculate 2D angles with
this data set. To do this the markers would need to be set up at
joint centers like what would typically done in a 2D system. If the
markers are just arbitrarily placed on each segment, this will not be
possible. To calculate the 2D angles you would just need to project
the coordinates of the markers onto the plane that the subjects are
walking in. This is trivial if the direction the subjects are
walking is coincident with one of the axes of the global coordinate
system. i.e. if the subjects are walking in the x direction and y is
vertical just ignore the z direction. If they are not coincident i.e.
they are walking partly in x partly in z, then you need to define the
plane and project the coordinates into that plane.
One thought. I'm not familiar with the phase space system. I have
used the optotrak system.
At times we used a single marker carrier per segment but each marker
carrier had four markers. If each of your "markers" is actually three
or more markers, then you can calculate 3D kinematics. You need
landmark digitization data to transform the data to anatomically
relevant coordinate systems. If this is the case, I do have some code
that uses the kinmat toolbox that others have mentioned. My code is
quite customized (and probably not very readable but might provide
a useful framework. In a nutshell you use soder.m to calculate
transformation matrices between markers at different timepoints, use
the digitization data to transform markers to anatomical coordinate
systems, multiply the transfomation matrices together then use
something like rxyzsolv.m to calculate euler angles.
My 'Joint angles vs. orientation angles' webpage
(http://kwon3d.com/theory/euler/jangle.html ) explains how to compute the
joint angle from the relative orientation angle of a distal segment to the
proximal.
In your case, you will have to obtain the orientation matrices of the
segments from the yaw, tilt, and roll angles provided by Phasespace and
compute the relative orientation matrices of the segments to their
respective proximal segments first.
Let me know if you cannot find a a good solution. I may be able to come up
with a spreadsheet-based program. Does Phasespace provide 3x3 orientation
matrix of the sensor? it will be a lot easier to use than the angles.
My 'Joint angles vs. orientation angles' webpage
(http://kwon3d.com/theory/euler/jangle.html ) explains how to compute the
joint angle from the relative orientation angle of a distal segment to the
proximal.
In your case, you will have to obtain the orientation matrices of the
segments from the yaw, tilt, and roll angles provided by Phasespace and
compute the relative orientation matrices of the segments to their
respective proximal segments first.
Let me know if you cannot find a a good solution. I may be able to come up
with a spreadsheet-based program. Does Phasespace provide 3x3 orientation
matrix of the sensor? it will be a lot easier to use than the angles.
you can try to use Scilab environment (http://www.scilab.org
). It is similar to commercial software Matlab,
but it is for free! You can import your data and then use some kinematic
transformations to get what you want. There are many books published on
this topic. You can use for this purpose method of a "transformation
matrices" described by Craig (CRAIG, J.J. /Introduction to Robotics
Mechanics and Control/. Second Edition, 1989. Addison Wesley Longman)
The International Shoulder Group has some code on their website to do
this. The code will not give you the joint angles in the ISB standards
(Wu, et al, 2002, Wu, et al, 2005); instead, it gives you the joint
angles in a coordinate system that is rotated by 90 about the Y-axis.
There are also other differences (shoulder joint's origin is defined
differently between the two).
In our lab we have been using some custom written MATLAB code to get the
shoulder and elbow joint angles (as defined in the ISB papers cited
above).
______
______________________________________________
BodyMech, a Matlab open source package
http://www.bodymech.nl/
and
KineMat, a Matlab toolbox
http://isbweb.org/software/movanal/kinemat/index.html
The text of most of the replies are pasted below. I did not include some duplicate postings.
take care,
df
Dan Ferris, Ph.D.
Associate Professor
Division of Kinesiology
Department of Biomedical Engineering
Department of Physical Medicine and Rehabilitation
University of Michigan
http://www-personal.umich.edu/~ferrisdp/
currently on sabbatical at:
Institute for Neural Computation
UC San Diego
(858) 534-9662
ferrisdp@umich.edu
MaxMate is a fairly straight forward excel based program that does just
what you're looking for.
http://www.innovision-systems.com/Products-MaxMATE.aspx
http://isbweb.org/software/movanal/kinemat/index.html
http://www.bodymech.nl/ - free matlab program/code that might give you what you need+ good documentation.
You may have received better responses from your BIOMCH-L query, but I do have a code that I developed during graduate school. I used it to determine the 3 clinical translations and 3 clinical rotations (described by grood-suntay, JBME 1983) for a lab experiment I conducted as the TA. The input I used was from imaging software that computed the time-dependent Cartesian dimensions of markers rigidly attached to the femur and tibia of a bovine knee. Kinematic blocks with 3 markers were attached to both the femur and tibia. A coordinate system was embedded in the femur and tibia (via digitizer) and the rotations/translations were computed between the embedded systems. A photo of the setup can be seen in one of our publications (Lujan et al. JBME, 2007).
In the biomechanics class I TA'd, the students had to answer questions on the code, therefore in the main program I'm sending you (gsuntay_solution.m), there are lots of comments and questions. The other .m files are subfunctions. If you want to run the program, I provided a zip file with all the programs and input from a class experiment where I flexed a bovine knee. Just put all the zipped files in the same folder, open gsuntay_ta.m and hit "run".
I think the code you are seeking is dependent on exactly how many markers
you have and where they are placed - these things affect how the vectors of
the local reference frames are defined. There is a relatively easy method
for these calculations described by Vaughan et al. in, "Dynamics of Human
Gait," which can be freely downloaded from the link below (see Appendix B,
pp. 94-96 for joint angles). If you don't find code that you can just plug
in, the Vaughan et al. book might be a helpful reference for writing some
code yourself.
http://www.kiboho.co.za/GaitCD/gaitbook.htm
have a look at the International Shoulder Group site
(www.internationalshouldergroup.org). There should be software
available for the calculation of local coordinate systems. Otherwise,
I do have .m files that will do the job. I will get in touch with the
ISG webmaster to make sure that they become available through that site.
Visual 3D is a nice tool to calculate joint kinematics from raw
tracked data.
Is Christoph Reinschmit's (sp??) code still posted to the ISB web site?
We've used that in the past... I needs some fiddling to work with specific situations (different marker sets, etc.) but it otherwise seems to work pretty well.
That sounds like it was an electromagnetic system. Correct? Do you know what make/model? Each manufacturer can spit out different info. Or perhaps you already know exactly what info is in the files? I'm guessing it would be x,y,z components of the vector that points to the local frame from the global. The rotations are probably a sequence of angles but we need to know the axes of rotation and the order of rotations. Some systems spit out rotation matrices directly. With this information you can determine the position and orientation of each marker relative to the global ref. frame.
Also, one must assume the markers were rigidly fixed to each segment. You then need to know what was the position and orientation of the marker's fixed location relative to the local axes of the segment. So, if you know where the segment was relative to the marker, and you know where the marker was in the global, then you know where the segment was in the global.
If I'm saying things you already knew, I apologize. But, I'm afraid that if you have nothing more than some output data files, it not be sufficient information.
I just wrote this little script to check the output of another
simulation. Input are skin marker coordinates (markers only on lower
limbs), and output are joint angles for hip, knee and ankle as well as
the rotation matrices between anatomical coordinate systems (which you
probably don't need).
Reading other people's code is often quite difficult, but maybe it helps.
I am a grad student at the University of Pittsburgh and I am pretty familiar with calculating joint angles using Matlab. This is the method I employ:
Step 1. Calculate anatomical coordinate systems with the long axis of the segment aligned with the y-axis. For the lower leg I would align the y axis from the Ankle joint center to the Knee joint center. For the upper leg I would align the y axis from the knee joint center to the hip joint center. Then I would use other markers to calculate two more vectors. Using the vector cross porducts, gives three direction vectors. These three vectors {x, y, z} make up the rotation matrix from global coordinates to the anatomical coordinate system.
Step 2: Determine the joint angle using Euler decomposition. Determine the rotation matrix between the two joint segments (i.e, thigh with respect to shank). From this rotation matrix decompose the angles to determine the included joint angle.
If you need more help just let me know and I should be able to send you some code.
That is an unusual data format, looks more like animation data.
If you know the exact meaning of the rotation parameters in your data, you can transform those into rotation matrices, calculate R1*inv(R2) to get orientation of one bone relative to the other, and then decompose that into standard Grood-Suntay joint angles (the Rxyzsolve etc. functions in Kinemat).
The ISB website has scripts and functions based on the SVD function in matlab and the Joint Coordinate System style of Euler rotations. Although I think these days you need to be a member to access them. I did download them before this happend so if you would like them I can forward them next week when I return to work.
Absolute angles can be calculated with the built in functions atan or atan2, and relative angles can be calculated by the cosine law or similiar which is acos[(a^2+b^2-c^2)/2ab] in matlab. 'a and b' are lengths of lines joining proximal and distal joints to the joint of interest, 'c' is the length of a line between the proximal and distal joints.
when calculating angles from 2D marker co-ordinates, I did the following, which may help you:
1. calculate segment lengths using marker co-ordinates for two adjacent segments
2. use these as vector lengths
3. take the arc-cosine of the dot product of these two vectors to give you joint angle - you can output this as either degrees or radians.
there's a fair amount of literature available on how to calculate angle using dot product
please have a look at our open source software project Bodymech
www.bodymech.nl
It has been a while since the last update.
There is no of the shelf full body model,
(we're working on that as well)
but you can configure it to your own needs
if you're a member of ISB all the code can be downloaded after logging into the website (www.isbweb.org). You just need to acknowledge the source when using any of this code.
if you want I have a code only for upper arm but it dipens on
where do you want to put markers.
Also you can find this explanation in my paper about carrying angle
evaluation of the elbow joint. This work is published in J Shoulder
and Elbow Joint Surgery
Matlab is an excellent tool for calculating joint angles from marker cartesian coordinates. I have been working with this software and I really like it. What exactly do you need?
If the data you have include yaw, tilt and roll for each marker
relative to a fixed origin, and each marker is fixed to a segment, are
these values not equivalent to the segment angles? I'm not terribly
familiar with active marker system, but it would seem the marker data
already has the data you are looking for.
I've written matlab code in the past for calculating joint angles, so I might be able to help you out with your application.
You need three markers per segment to calculate 3D angles. Sometimes
with less than three you can calculate missing markers based on
markers on adjacent segments. With one marker per segment I don't see
any way of doing this. You may be able to calculate 2D angles with
this data set. To do this the markers would need to be set up at
joint centers like what would typically done in a 2D system. If the
markers are just arbitrarily placed on each segment, this will not be
possible. To calculate the 2D angles you would just need to project
the coordinates of the markers onto the plane that the subjects are
walking in. This is trivial if the direction the subjects are
walking is coincident with one of the axes of the global coordinate
system. i.e. if the subjects are walking in the x direction and y is
vertical just ignore the z direction. If they are not coincident i.e.
they are walking partly in x partly in z, then you need to define the
plane and project the coordinates into that plane.
One thought. I'm not familiar with the phase space system. I have
used the optotrak system.
At times we used a single marker carrier per segment but each marker
carrier had four markers. If each of your "markers" is actually three
or more markers, then you can calculate 3D kinematics. You need
landmark digitization data to transform the data to anatomically
relevant coordinate systems. If this is the case, I do have some code
that uses the kinmat toolbox that others have mentioned. My code is
quite customized (and probably not very readable but might provide
a useful framework. In a nutshell you use soder.m to calculate
transformation matrices between markers at different timepoints, use
the digitization data to transform markers to anatomical coordinate
systems, multiply the transfomation matrices together then use
something like rxyzsolv.m to calculate euler angles.
My 'Joint angles vs. orientation angles' webpage
(http://kwon3d.com/theory/euler/jangle.html ) explains how to compute the
joint angle from the relative orientation angle of a distal segment to the
proximal.
In your case, you will have to obtain the orientation matrices of the
segments from the yaw, tilt, and roll angles provided by Phasespace and
compute the relative orientation matrices of the segments to their
respective proximal segments first.
Let me know if you cannot find a a good solution. I may be able to come up
with a spreadsheet-based program. Does Phasespace provide 3x3 orientation
matrix of the sensor? it will be a lot easier to use than the angles.
My 'Joint angles vs. orientation angles' webpage
(http://kwon3d.com/theory/euler/jangle.html ) explains how to compute the
joint angle from the relative orientation angle of a distal segment to the
proximal.
In your case, you will have to obtain the orientation matrices of the
segments from the yaw, tilt, and roll angles provided by Phasespace and
compute the relative orientation matrices of the segments to their
respective proximal segments first.
Let me know if you cannot find a a good solution. I may be able to come up
with a spreadsheet-based program. Does Phasespace provide 3x3 orientation
matrix of the sensor? it will be a lot easier to use than the angles.
you can try to use Scilab environment (http://www.scilab.org
). It is similar to commercial software Matlab,
but it is for free! You can import your data and then use some kinematic
transformations to get what you want. There are many books published on
this topic. You can use for this purpose method of a "transformation
matrices" described by Craig (CRAIG, J.J. /Introduction to Robotics
Mechanics and Control/. Second Edition, 1989. Addison Wesley Longman)
The International Shoulder Group has some code on their website to do
this. The code will not give you the joint angles in the ISB standards
(Wu, et al, 2002, Wu, et al, 2005); instead, it gives you the joint
angles in a coordinate system that is rotated by 90 about the Y-axis.
There are also other differences (shoulder joint's origin is defined
differently between the two).
In our lab we have been using some custom written MATLAB code to get the
shoulder and elbow joint angles (as defined in the ISB papers cited
above).
______
______________________________________________