Plotting Results
Treatment Optimization supports the plotting of many relevant quantities. The most high level plotting function for the Treatment Optimization tools is as follows:
plotTreatmentOptimizationResultsFromSettingsFile("settingsFileName.xml")
This function works for all three Treatment Optimization tools, and will automatically generate plots depending on what elements are included in your Treatment Optimization runs. The plots created by this function are listed below.
- Joint angles are always plotted from this function.
- Joint velocities are always plotted from this function.
- Joint loads are alwyas plotted from this function.
- Ground reactions are plotted if your TO run used a ground contact model.
- Torque controls are plotted if your TO run used torque controls.
- Muscle activations are plotted if your TO run used synergy controls.
- Synergy commands are plotted if your TO run used synergy controls.
- Synergy weights are plotted if your TO run used synergy controls.
Each plot shows the tracking quality of your TO results compared to the input data. The input data will always use a blue line. The function calculates RMSE between the tracking data and the TO results for all plots.
You may compare multiple TO runs on the same plot by using the following line of code:
plotTreatmentOptimizationResultsFromSettingsFile("settingsFileName.xml", ["resultsDirectory1", "resultsDirectory2"]).
This line will parse the input data from the given settings file, but will replace the results directory in the settings file with the results directories specified in the second function argument.
If you want more control over individual plots, you may also call individual plotting functions.
plotTreatmentOptimizationJointAngles(modelFileName, trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationJointVelocities(modelFileName, trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationJointLoads(trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationGroundReactions(trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationMuscleActivations(trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationTorqueControls(trackedDataFile, resultsDataFiles, varargin)plotTreatmentOptimizationSynergyControls(trackedActivationsFile, trackedWeightsFile, resultsActivationsFiles, resultsWeightsFiles, osimxFileName, modelFileName, synergyNormalizationMethod, synergyNormalizationValue, varargin)
The arugments to these functions are detailed below.
modelFileNameis the OpenSim model file.trackedDataFileis the .sto file containing the your input data. All RMSE values will be calculated with respect to this data file.resultsDataFilescontains a list of the .sto files you want to plot. You may plot anywhere from 0-6 sets of results on the same plot. If you want to plot no results and only the tracked data, simply input[]forresultsDataFiles.
The synergy control plotting function uses different input arguments than the other functions.
osimxFileNameis the NMSM Pipeline Model File. This file is used to split the synergy weight plots between synergy sets.trackedActivationsFileandresultsActivationsFilescontain the tracked and results synergy activations (not muscle activations).trackedWeightsFileandresultsWeightsFilescontain the tracked and results synergy weights.synergyNormalizationMethodspecifies the method for renormalizing synergy weights. Acceptable values are "sum", "magnitude", or "none".synergyNormalizationValuespecifies the value the synergy weights should be normalized to using the specified method. For example, ifsynergyNormalizationMethodis "sum" andsynergyNormalizationValueis 10, the synergy weights are normalized such that the sum of all of the weights in one synergy equals 10. If instead they are "magnitude" and 1, the synergy weights are normalized such that the magnitude of the weights in one synergy equals 1.
All of these individual functions also support optional arguments using varargin that control how the plot is formatted. These arguments are detailed below.
useRadianscan be either true or false for joint angle or joint velocity plots.- Example:
useRadians=trueoruseRadians=false
- Example:
columnsToUsespecifies the columns from your .sto file that will be plotted. These must exactly match the column names inside the .sto file, and can be in any order.- Example:
columnsToUse=["hip_flexion_r", "knee_angle_r", "ankle_angle_r"]
- Example:
columnNamesoverrides the subplot titles with the text given. The default subplot titles simply use the column names from the given .sto file. The given column names must be in the same order ascolumnsToUse.- Example:
columnNames=["Hip Flexion", "Knee Flexion", "Ankle Angle"]
- Example:
legendoverrides the names in the legend. The default legend is constructed using the given file names.- Example:
legend=["Tracked", "TO Results", "DO Results"]
- Example:
showRmsecan be either true or false if you want to show RMSE values in the subplot titles.- Example:
showRmse=falseorshowRmse=true
- Example:
figureGridSizespecifies the width and height of the figures. The default is to size the figures so that all of the data fits on one plot. If the number of subplots exceeds the number allowed in one plot, a new plot will be created.- Example:
figureGridSize=[5, 2]makes the figures have a width of 5 subplots, and a height of 2 subplots.
- Example: