% This function is part of the NMSM Pipeline, see file for full license.
%
% This function takes a list of muscle group names and returns a cell
% array of the muscle indices in each group.
%
% (array of string, Model) -> (cell array of num arrays)
% parses synergy groups from XML tree
function groups = groupNamesToGroups(groupNames, model)
groups = {};
model = Model(model);
for i=1:length(groupNames)
group = [];
for j=0:model.getForceSet().getGroup(groupNames(i)).getMembers().getSize()-1
count = 1;
for k=0:model.getForceSet().getMuscles().getSize()-1
if strcmp(model.getForceSet().getMuscles().get(k).getName() ...
.toCharArray', model.getForceSet().getGroup( ...
groupNames(i)).getMembers().get(j))
break
end
if(model.getForceSet().getMuscles().get(k).get_appliesForce())
count = count + 1;
end
end
group(end+1) = count;
end
groups{end + 1} = group;
end
end