Skip to main content

calcMuscleActivations.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the muscle activations given the
% EMG signals and activation dynamic parameters
%
% (3D Array of number, Array of number) -> (3D Array of number)
% computes the muscle activations from neural activations and nonlinearity


function muscleActivations = calcMuscleActivations(neuralActivations, ...
activationNonlinearity)

nonlinearityCoefficients = [29.280183270562596 4.107869238218326 ...
1.000004740962477 -7.623282868703527 17.227022969058535 ...
0.884220539986325]; % defined by BJ Fregly
% see Meyer 2017 equation 8 (coefficients relabeled)
g = nonlinearityCoefficients;
expandedActivationNonlinearity = ones(1, ...
size(activationNonlinearity, 2), 1);
expandedActivationNonlinearity(1, :, 1) = activationNonlinearity;
denominator = g(1) * (neuralActivations + g(6)) .^ g(5) + g(2);
bracketed = (g(4) / denominator) + g(3);
muscleActivations = (1 - expandedActivationNonlinearity) .* ...
neuralActivations + expandedActivationNonlinearity .* bracketed;
end