% This function is part of the NMSM Pipeline, see file for full license.
%
% This function reformats synergy weights from a number array to a 2D
% matrix.
%
% (Array of number, struct) -> (2D matrix)
% Returns synergy weights as a 2D matrix
function synergyWeightsReformatted = getSynergyWeightsFromGroups(...
synergyWeights, params)
synergyWeightsReformatted = zeros(params.numSynergies, params.numMuscles);
valuesIndex = 1;
row = 1;
column = 1; % the sum of the muscles in the previous synergy groups
for i = 1:length(params.synergyGroups)
for j = 1: params.synergyGroups{i}.numSynergies
synergyWeightsReformatted(row, column : ...
column + length(params.synergyGroups{i}.muscleNames) - 1) = ...
synergyWeights(valuesIndex : ...
valuesIndex + length(params.synergyGroups{i}.muscleNames) - 1);
valuesIndex = valuesIndex + length(params.synergyGroups{i}.muscleNames);
row = row + 1;
end
column = column + length(params.synergyGroups{i}.muscleNames);
end
end