Muscle Origin and Insertion Coordinate Transformation

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Michael Asmussen
Posts: 67
Joined: Mon Jul 11, 2016 7:46 am

Re: Muscle Origin and Insertion Coordinate Transformation

Post by Michael Asmussen » Tue Jun 20, 2017 1:59 pm

Thanks for the help Tom!

If I understand correctly, there isn't a method to easily extract specific muscles, for example muscles that produce a plantarflexion moment, with a built in OpenSim function using Matlab. I thought there may have been a method to index the muscles in the navigator panel in the OpenSim GUI that are under the heading "R_ankle_pf", but it seems that this must be done with another method of solving the moment arm first and then indexing muscles that have a non-zero moment arm. Is that correct?

I am having trouble with determining the muscle moment arm and the muscle-tendon length. I have pasted my Matlab script below. Does anyone know how to resolve my issue?

%Set up model
import org.opensim.modeling.*
model = Model('C:\OpenSim 3.3\Models\Gait2392_Simbody\gait2392_simbody.osim');
state = model.initSystem();

%Define the coordinate sets of interest and define the states
ankle = model.getCoordinateSet().get('ankle_angle_r');
subtalar = model.getCoordinateSet().get('subtalar_angle_r');
ankle.setValue(state,10*pi/180);

%Define the muscles
MuscleName=cell(1,model.getMuscles().getSize());
for i=0:model.getMuscles().getSize()-1
MuscleName{i+1}=char(model.getMuscles().get(i).getName());
end

%Define the muscle of interest
muscle=model.getMuscles().get(MuscleName{35})

%Define the muscle geometry path
musclegeopath=model.getMuscles().get(MuscleName{35}).getGeometryPath();

% Determines the moment arm
MA=MomentArmSolver(state,ankle,musclegeopath);

% Determines the muscle length
ML=MuscleAnalysis.getMuscleTendonLengthStorage(state)



Matlab error


muscle =

tib_post_r

No constructor 'org.opensim.modeling.MomentArmSolver' with matching signature found.

Error in MomentArmTest (line 27)
MA=MomentArmSolver(state,ankle,musclegeopath);

ML=MuscleAnalysis.getMuscleTendonLengthStorage(state)
No method 'getMuscleTendonLengthStorage' with matching signature found for class
'org.opensim.modeling.MuscleAnalysis'.

Thank you,

Mike

User avatar
Thomas Uchida
Posts: 1786
Joined: Wed May 16, 2012 11:40 am

Re: Muscle Origin and Insertion Coordinate Transformation

Post by Thomas Uchida » Wed Jun 21, 2017 3:10 am

The error "No constructor 'org.opensim.modeling.MomentArmSolver' with matching signature found." indicates that you are calling the MomentArmSolver constructor with incorrect arguments. See the doxygen for MomentArmSolver here: https://simtk.org/api_docs/opensim/api_ ... olver.html. The constructor (https://simtk.org/api_docs/opensim/api_ ... aa1ef6e925) takes the Model as an argument; the solve() method (https://simtk.org/api_docs/opensim/api_ ... 7423820822) takes references to the State, Coordinate, and GeometryPath.

User avatar
Michael Asmussen
Posts: 67
Joined: Mon Jul 11, 2016 7:46 am

Re: Muscle Origin and Insertion Coordinate Transformation

Post by Michael Asmussen » Wed Jun 21, 2017 9:54 am

Thanks Tom!

I was able to get the moment arm value with the following lines added to the original script:

Code: Select all

MA2=MomentArmSolver(model);
MA2value=MA2.solve(state, ankle, musclegeopath)
I am still having issues with determining muscle length. Currently, I have used the following script:

Code: Select all

import org.opensim.modeling.*
model = Model('C:\OpenSim 3.3\Models\Gait2392_Simbody\gait2392_simbody.osim');
state = model.initSystem();

%Define the coordinate sets of interest and define the states
ankle = model.getCoordinateSet().get('ankle_angle_r');
subtalar = model.getCoordinateSet().get('subtalar_angle_r');
ankle.setValue(state,15*pi/180);
subtalar.setValue(state,10*pi/180);

%Define the muscles
MuscleName=cell(1,model.getMuscles().getSize());
for i=0:model.getMuscles().getSize()-1
MuscleName{i+1}=char(model.getMuscles().get(i).getName());
end

%Try to get muscle length
MuscleAn=MuscleAnalysis(model)
test=MuscleAn.getMuscleTendonLengthStorage()
The script creates a storage file named "test". I was wondering what I should modify in this script to extract the length of all the muscles in the model? Can this be done through the storage file? On a more general note, how do I determine the contents of an object within Matlab that is created via OpenSim. For example, how could I determine the content of a "1x1 Storage" or a "1x1 MuscleAnalysis" and how to index it within Matlab?

Any help would be much appreciated!

Thank you,

Mike

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Muscle Origin and Insertion Coordinate Transformation

Post by jimmy d » Wed Jun 21, 2017 12:01 pm

You can ask the muscle for its length (see below). You can use the Doxygen documentation to figure out the methods on each class. The doxygen documentation for Muscle is here. You will see from the inheritance diagram (expand tab at the top of the screen) that muscle is a subclass of PathActuator. PathActuator has a method getLength. There is also some example code here that may be helpful (I haven't looked at it for awhile so can't guarantee it works out of the box).

Code: Select all

%Define the muscles
MuscleName=cell(1,model.getMuscles().getSize());
for i=0:model.getMuscles().getSize()-1
MuscleName{i+1}=char(model.getMuscles().get(i).getName());
end

%Get muscle length
m = model.getMuscles().get(0)
m.getLength(s)
m.getFiberLength(s)

User avatar
Michael Asmussen
Posts: 67
Joined: Mon Jul 11, 2016 7:46 am

Re: Muscle Origin and Insertion Coordinate Transformation

Post by Michael Asmussen » Wed Jun 21, 2017 2:54 pm

Thanks James! I just had to substitute how I named the model state in my code to get the result I wanted. Below is my working script:

Code: Select all

import org.opensim.modeling.*
model = Model('C:\OpenSim 3.3\Models\Gait2392_Simbody\gait2392_simbody.osim');
state = model.initSystem();

%Define the coordinate sets of interest and define the states
ankle = model.getCoordinateSet().get('ankle_angle_r');
subtalar = model.getCoordinateSet().get('subtalar_angle_r');
ankle.setValue(state,0*pi/180);
subtalar.setValue(state,0*pi/180);

%Define the muscles
MuscleName=cell(1,model.getMuscles().getSize());
for i=0:model.getMuscles().getSize()-1
MuscleName{i+1}=char(model.getMuscles().get(i).getName());
end


%Get muscle length
m = model.getMuscles().get(34)
m.getLength(state)
m.getFiberLength(state)
On another note, it seems that the command "getLength" is not in the Doxygen documentation under Muscle, but it is for PathActuator (as you mentioned). Can Muscle class do any of the PathActuator class methods? Does that apply to any class that belongs to a base class?

Thanks!

Mike

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Muscle Origin and Insertion Coordinate Transformation

Post by jimmy d » Thu Jun 22, 2017 1:15 pm

On another note, it seems that the command "getLength" is not in the Doxygen documentation under Muscle, but it is for PathActuator (as you mentioned). Can Muscle class do any of the PathActuator class methods? Does that apply to any class that belongs to a base class?
For the the most part, yes. That is how Object Oriented programming works. There is some info on our wiki page you should read;
http://simtk-confluence.stanford.edu:80 ... Background

There is also information on the wiki on how inline commands to see what methods are available on a class;
http://simtk-confluence.stanford.edu:80 ... ypegetting

Not all methods are available in Matlab, mainly because of differences between Matlab and C++.

POST REPLY