Skip to content

Commit

Permalink
Excitation cost allowable error and error center from xml
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerTWilliams committed Jun 14, 2023
1 parent 89844ce commit 5cac387
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@

function cost = calcMuscleExcitationPenaltyCost(modeledValues, ...
experimentalData, costTerm)
errorCenter = valueOrAlternate(costTerm, "errorCenter", 0.5);
maximumAllowableError = valueOrAlternate(costTerm, "maxAllowableError", 0.25);
muscleExcitationsConstraint = modeledValues.muscleExcitationsNoTDelay(: , ...
setdiff(1 : size(modeledValues.muscleExcitationsNoTDelay, 2), ...
[experimentalData.synergyExtrapolation.missingEmgChannelGroups{:}]), ...
experimentalData.numPaddingFrames + 1 : ...
size(modeledValues.muscleExcitationsNoTDelay, 3) - ...
experimentalData.numPaddingFrames);
cost = 120 * (muscleExcitationsConstraint - 0.5) .^ 8;
cost = 30 / maximumAllowableError * (muscleExcitationsConstraint - errorCenter) .^ 8;
cost(isnan(cost))=0;
cost = sum([sqrt(0.1) .* cost ].^ 2, 'all');
cost = sum((sqrt(0.1) .* cost).^ 2, 'all');
end
2 changes: 1 addition & 1 deletion src/MuscleTendonPersonalization/Optimization/calcMtpCost.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
synxModeledValues, modeledValues, experimentalData, costTerm);
case "muscle_excitation_penalty"
cost = calcMuscleExcitationPenaltyCost( ...
synxModeledValues, experimentalData);%, costTerm);
synxModeledValues, experimentalData, costTerm);
otherwise
throw(MException('', 'Cost term %s is not valid for MTP', ...
costTerm.type))
Expand Down

0 comments on commit 5cac387

Please sign in to comment.