Skip to main content

reorderPreprocessedDataByMuscleNames.m


function inputs = reorderPreprocessedDataByMuscleNames(inputs, muscleNames)

indexesInParsedMuscleData = ...
ismember(inputs.muscleTendonColumnNames, muscleNames);

inputs.muscleTendonColumnNames = ...
inputs.muscleTendonColumnNames(indexesInParsedMuscleData);
inputs.muscleTendonLength = inputs.muscleTendonLength(:, ...
indexesInParsedMuscleData, :);
inputs.muscleTendonVelocity = inputs.muscleTendonVelocity(:, ...
indexesInParsedMuscleData, :);

indexesInParsedCoordinateData = ...
ismember( ...
inputs.inverseDynamicsMomentsColumnNames, ...
inputs.coordinateNames ...
);
indexesInParsedMuscleAnalysisData = ...
ismember( ...
inputs.momentArmsCoordinateNames, ...
inputs.coordinateNames ...
);

inputs.inverseDynamicsMoments = ...
inputs.inverseDynamicsMoments(:, indexesInParsedCoordinateData, :);
inputs.momentArms = inputs.momentArms(:, indexesInParsedMuscleAnalysisData, ...
indexesInParsedMuscleData, :);

if (isfield(inputs, "mtpActivationsColumnNames"))
indexesInParsedActivationData = ...
ismember(inputs.mtpActivationsColumnNames, muscleNames);

inputs.mtpActivationsColumnNames = ...
inputs.mtpActivationsColumnNames(indexesInParsedActivationData);
inputs.mtpActivations = ...
inputs.mtpActivations(:, indexesInParsedActivationData, :);
end

end