Matlab API: Extracting Muscle Info

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Cole Simpson
Posts: 6
Joined: Tue Nov 20, 2012 1:10 pm

Matlab API: Extracting Muscle Info

Post by Cole Simpson » Thu Nov 20, 2014 8:32 am

Hello everyone,

I am trying to extract muscle properties and moment arms from an OpenSim model across a dynamic task. I have prescribed a motion for the model using the example script 'prescribeMotionInModel.m', but I do not understand how to cycle through the states of the motion in order to extract the parameters at different time points. I have tried setting the coordinate values to the values in the prescribed function individually (shown below), but I believe that there should be a more efficient way to cycle through the prescribed motion.

Is there a way to directly specify a time during a prescribed motion in order to extract muscle parameters at that time?

Code: Select all

% Here is the code for my hack
for ii = 1:72
    for jj = 1:coords.getSize
        joint = model.updCoordinateSet().get( jj-1 );                  % Extract specific coordinate from model
        func = joint.get_prescribed_function;                           % Get prescribed function from coordinate
        temp(ii) = func.calcValue( Vector( 1, 0.4+1.2*(ii-1)/71 ));  % Calculate the prescribed value for a certain time point
        joint.setValue( states, temp( ii ), false );                        % Set the coordinate value to the one calculated for the specified time point
    end

    % extract relevant parameters
end

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

Re: Matlab API: Extracting Muscle Info

Post by jimmy d » Thu Nov 20, 2014 12:16 pm

Hi Cole,

I tried something similar awhile back and found it really tricky. I ended up using updCoord directly.

Here is some mess-around code for calculating force-length/force-velocity properties during a motion; https://github.com/jimmyDunne/stackJimm ... VfromMot.m

Let me know if that helps,
-james

User avatar
Cole Simpson
Posts: 6
Joined: Tue Nov 20, 2012 1:10 pm

Re: Matlab API: Extracting Muscle Info

Post by Cole Simpson » Thu Dec 04, 2014 6:36 am

Hey James,

Thanks for the response. It did help. However, I have encountered another problem. The Matlab API is returning 'NaN' for all muscle moment arm values about the MTP joint (OpenSim 2392 model with Chand John's walking data; the MTP joint angle is constant). The OpenSim GUI plot function returns values for all muscles around that joint using the same model and data. The API also returns values for all muscles at all other joints that appear to match those from the GUI. Do you know why the API fails to return values for muscle moment arms only about the MTP and if there is a way to circumvent this issue?

Thanks again,
Cole

POST REPLY