Skip to main content

calcResidualMuscleActivationCost.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% (Array of number, struct) -> (Array of number)
% returns the cost for all rounds of the Muscle Tendon optimization


function cost = calcResidualMuscleActivationCost(synxModeledValues, ...
modeledValues, experimentalData, costTerm)
errorCenter = valueOrAlternate(costTerm, "errorCenter", 0);
maximumAllowableError = valueOrAlternate(costTerm, "maxAllowableError", 0.3);
cost = calcDeviationCostTerm(...
synxModeledValues.muscleActivations(:, setdiff(1 : ...
size(synxModeledValues.muscleActivations, 2), ...
[experimentalData.synergyExtrapolation.missingEmgChannelGroups{:}]), :) - ...
modeledValues.muscleActivations(:, setdiff(1 : ...
size(synxModeledValues.muscleActivations, 2), ...
[experimentalData.synergyExtrapolation.missingEmgChannelGroups{:}]), :), ...
errorCenter, maximumAllowableError);
end