I am working with a colleague on the scapulothoracic model (Seth et al., 2019) and we would like to automatize the computation of muscle moment arms (MMA) over time for several motion trials. We use the MATLAB API. To do that, we would like to wrote a for loop that set the model in the position indicated by the k line of an input IK file, then compute the MMA of the muscles of the model in that position, and continue the loop.
However, before starting the code, we checked the feasibility with the angular values of the first line of our IK file. We set manually the values, realize the position and then display the values of the same degrees of freedom for verification (like in the following code). Because of the AC constraint of the model, the displayed values for sternoclavicular and scapulothoracic joints are different from the values we entered (to ensure the contact between scapula and clavicle, some positions are not achievable by the model). But, these values are from an IK file, so the model should be able to achieve it.
Code: Select all
import org.opensim.modeling.*
%% Import plugin scapulothoracic joint
Model.LoadOpenSimLibrary('C:\OpenSim 4.1\plugins\ScapulothoracicJointPlugin40_WinX64');
%% setup files
model = Model('path\model.osim');
state = model.initSystem();
model.initSystem();
%% change joint values
model.getJointSet().get('sternoclavicular').get_coordinates(0).setValue(state, 0.1723);
model.getJointSet().get('sternoclavicular').get_coordinates(1).setValue(state, 0.1323);
model.getJointSet().get('scapulothoracic').get_coordinates(0).setValue(state, 0.6005);
model.getJointSet().get('scapulothoracic').get_coordinates(1).setValue(state, 0.0385);
model.getJointSet().get('scapulothoracic').get_coordinates(2).setValue(state, 0.3747);
model.getJointSet().get('scapulothoracic').get_coordinates(3).setValue(state, -0.0470);
model.getJointSet().get('GlenoHumeral').get_coordinates(0).setValue(state, 0.5133);
%% applied new position
model.realizePosition(state);
%% Verification
disp(model.getJointSet().get('sternoclavicular').get_coordinates(0).getValue(state));
disp(model.getJointSet().get('sternoclavicular').get_coordinates(1).getValue(state));
disp(model.getJointSet().get('scapulothoracic').get_coordinates(0).getValue(state));
disp(model.getJointSet().get('scapulothoracic').get_coordinates(1).getValue(state));
disp(model.getJointSet().get('scapulothoracic').get_coordinates(2).getValue(state));
disp(model.getJointSet().get('scapulothoracic').get_coordinates(3).getValue(state));
disp(model.getJointSet().get('GlenoHumeral').get_coordinates(0).getValue(state));
%% Verification - plot MMA
clav_prot = model.getJointSet().get('sternoclavicular').get_coordinates(0);
model.getMuscles().get('TrapeziusClavicle_S').computeMomentArm(state,clav_prot);
Code: Select all
model.getConstraintSet().get('AC').set_isEnforced(0);
Code: Select all
state = model.initSystem();
Did we make a mistake somewhere? Is there a way to fix this? Or should we change the method of computing MMA?
Many thanks in advance,
Best regards,
Alicia Blasi-Toccacceli