Skip to main content

computeInnerOptimization.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function computes the inner optimization as defined in the Joint
% Model Personalization module by preparing and running the IK algorithm
% and returning a model with the new values
%
% (Model, struct) -> (Model)
% Returns new model with inverse kinematic optimized marker positions


function error = computeInnerOptimization(values, functions, modelFile, ...
markerFileName, params)
persistent model;
if isempty(model)
model = Model(modelFile);
end
modelCopy = Model(model);
for i = 1:length(values)
functions{i}(values(i), modelCopy);
end
markersReference = makeJmpMarkerRef(modelCopy, markerFileName, params);
error = computeInnerOptimizationHeuristic(modelCopy, markersReference, ...
params);
markersReference = libpointer;
java.lang.System.gc();
end