Skip to main content

getModelOrOsimxInputs.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% () -> ()
%


function inputs = getModelOrOsimxInputs(inputs)
if ~isa(inputs.model, 'org.opensim.modeling.Model')
model = Model(inputs.model);
end
inputs.optimalFiberLength = [];
inputs.tendonSlackLength = [];
inputs.pennationAngle = [];
inputs.maxIsometricForce = [];
for i = 1 : inputs.numMuscles
if isfield(inputs.osimx, "muscles") && ...
isfield(inputs.osimx.muscles, inputs.muscleNames(i))
if ~isfield(inputs.osimx.muscles.(inputs.muscleNames(i)), ...
"optimalFiberLength")
inputs.optimalFiberLength(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getOptimalFiberLength();
else
inputs.optimalFiberLength(end+1) = inputs.osimx.muscles. ...
(inputs.muscleNames(i)).optimalFiberLength;
end
if ~isfield(inputs.osimx.muscles.(inputs.muscleNames(i)), ...
"tendonSlackLength")
inputs.tendonSlackLength(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getTendonSlackLength();
else
inputs.tendonSlackLength(end+1) = inputs.osimx.muscles. ...
(inputs.muscleNames(i)).tendonSlackLength;
end
if ~isfield(inputs.osimx.muscles.(inputs.muscleNames(i)), ...
"maxIsometricForce")
inputs.maxIsometricForce(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getMaxIsometricForce();
else
inputs.maxIsometricForce(end+1) = inputs.osimx.muscles. ...
(inputs.muscleNames(i)).maxIsometricForce;
end
else
inputs.optimalFiberLength(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getOptimalFiberLength();
inputs.tendonSlackLength(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getTendonSlackLength();
inputs.maxIsometricForce(end+1) = model.getForceSet(). ...
getMuscles().get(i-1).getMaxIsometricForce();
end
inputs.pennationAngle(end+1) = model.getForceSet(). ...
getMuscles().get(i-1). ...
getPennationAngleAtOptimalFiberLength();
end
end