% This function is part of the NMSM Pipeline, see file for full license.
%
%
% (Array of number, Array of number, Array of number) -> (struct)
% changes optimization values into a struct for use in cost function
function values = makeMtpValuesAsStruct(secondaryValues, primaryValues, isIncluded)
valuesHelper.secondaryValues = secondaryValues;
valuesHelper.primaryValues = primaryValues;
valuesHelper.isIncluded = isIncluded;
values.electromechanicalDelays = findCorrectMtpValues(1, valuesHelper);
values.activationTimeConstants = findCorrectMtpValues(2, valuesHelper);
values.activationNonlinearityConstants = findCorrectMtpValues(3, valuesHelper);
values.emgScaleFactors = findCorrectMtpValues(4, valuesHelper);
values.optimalFiberLengthScaleFactors = findCorrectMtpValues(5, valuesHelper);
values.tendonSlackLengthScaleFactors = findCorrectMtpValues(6, valuesHelper);
values.synergyWeights = findCorrectMtpValues(7, valuesHelper);
end
function output = findCorrectMtpValues(index, valuesStruct)
if (valuesStruct.isIncluded(index))
[startIndex, endIndex] = findIsIncludedStartAndEndIndex( ...
valuesStruct.primaryValues, valuesStruct.isIncluded, index);
output = valuesStruct.secondaryValues(startIndex:endIndex);
else
output = valuesStruct.primaryValues{index};
end
end