% This function is part of the NMSM Pipeline, see file for full license.
%
% This function expands the given EMG .sto files to match the names and
% number of columns of a given muscle analysis file for use in the
% MuscleTendonPersonalizationTool.
%
% expandedFileName is the name of the file to match column names and muscle
% groups from. It is generally a Muscle Analysis file.
%
% (string, string, string, string) -> (None)
% Makes new EMG data files with columns matching the file given
function newEmgData = expandEmgDatas(model, emgData, groupColumnNames, ...
muscleNames)
model = Model(model);
groupToName = getMuscleNameByGroupStruct(model, groupColumnNames);
newEmgData = expandEmgData(muscleNames, emgData, ...
groupToName, groupColumnNames);
end
function newEmgData = expandEmgData(expandedColumnNames, emgData, ...
namesByGroup, emgColumnNames)
newEmgData = zeros(length(expandedColumnNames), size(emgData, 2));
for i=1:length(emgColumnNames)
musclesInGroup = namesByGroup.(emgColumnNames(i));
temp = emgData(i, :);
for j=1:length(musclesInGroup)
test = newEmgData(ismember(expandedColumnNames, ...
musclesInGroup(j)), :);
newEmgData(ismember(expandedColumnNames, ...
musclesInGroup(j)), :) = temp;
end
end
end