Dear OpenSim Team,
I am trying to compute normalised muscle fiber lengths with the AnalyzeTool in OpenSim GUI and Python. The problem I encountered is that the output is just a straight line at some value. It does happen with different models and interfaces (Python vs GUI). Is anybody else encountering the problem? The fiber length changes are fine.
Thanks and kind regards
Christian
Analysis Tool computing normalised muscle fiber lengths
- Christian Greve
- Posts: 41
- Joined: Mon Jun 13, 2016 11:14 pm
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: Analysis Tool computing normalised muscle fiber lengths
Hey Christian,
What files are you inputting into the analysis tool and what is your simulation pipeline? If you have performed static optimization you can determine the normalized fibre length by subtracting the tendon slack length from the muscle tendon unit length and dividing by the muscle's optimum fibre length - due to the rigid tendon assumption. If you have performed Computed Muscle Control then I believe you should get an output file with the time histories of the normalised muscle fibre lengths - as they are included as state variables.
Hope that helps!
Nicos
What files are you inputting into the analysis tool and what is your simulation pipeline? If you have performed static optimization you can determine the normalized fibre length by subtracting the tendon slack length from the muscle tendon unit length and dividing by the muscle's optimum fibre length - due to the rigid tendon assumption. If you have performed Computed Muscle Control then I believe you should get an output file with the time histories of the normalised muscle fibre lengths - as they are included as state variables.
Hope that helps!
Nicos
- Christian Greve
- Posts: 41
- Joined: Mon Jun 13, 2016 11:14 pm
Re: Analysis Tool computing normalised muscle fiber lengths
Hi Nicos,
thanks for your fast reply. I am using OpenSim Moco to compute muscle activations and excitations. I am using the output from the Moco solution as controls for the AnalyzeTool() + the coordinates. Maybe the code snipet below helps to clarify what I am doing.
thanks for your fast reply. I am using OpenSim Moco to compute muscle activations and excitations. I am using the output from the Moco solution as controls for the AnalyzeTool() + the coordinates. Maybe the code snipet below helps to clarify what I am doing.
Code: Select all
solution = osim.MocoTrajectory(Controls_Filename)
coordinates = osim.Storage(Coordinates_Filename)
osim.STOFileAdapter.write(solution.exportToControlsTable(),os.path.join(Path,"MocoInverse_controls.sto"))
ControlsFile = os.path.join(Path, 'MocoInverse_controls.sto')
setUpFile = os.path.join(Path,'subject01_Setup_Analyze_generic.xml')
analyzeTool = osim.AnalyzeTool(setUpFile,False)
model = osim.Model(Scaled_modelFileName)
model.initSystem()
AnalysisResultsFolder = os.path.join(Path,"AnalysisResults")
if not os.path.exists(AnalysisResultsFolder):
os.mkdir(AnalysisResultsFolder)
initial_time = coordinates.getFirstTime()
final_time = coordinates.getLastTime()
myState = model.initSystem()
# model = getCurrentModel()
analyzeTool.setModel(model)
analyzeTool.setName('MocoAnalysis')
analyzeTool.setResultsDir(AnalysisResultsFolder)
analyzeTool.setCoordinatesFileName(Coordinates_Filename)
analyzeTool.setControlsFileName("MocoInverse_controls.sto")
analyzeTool.setInitialTime(initial_time);
analyzeTool.setFinalTime(final_time);
analyzeTool.updAnalysisSet().cloneAndAppend(osim.MuscleAnalysis())
analyzeTool.setStatesFromMotion(myState,coordinates,True)
analyzeTool.run()
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: Analysis Tool computing normalised muscle fiber lengths
You should be able to extract the normalised muscle fibre lengths without having to use the Analyze tool due to using Moco - you can access them after solving a problem. This code snippet should provide some insight into doing so:
mySolution = study.solve(); % Solve your problem
outputPaths = StdVectorString();
outputPaths.add('.*fiber_length');
outputTable = study.analyze(mySolution,outputPaths);
opensimMoco,writeTableToFile(outputTable,'yourFile.sto');
If it doesn't help then posting your question on the Moco forum should definitely help (Limited experience with using Moco).
Thanks,
Nicos
mySolution = study.solve(); % Solve your problem
outputPaths = StdVectorString();
outputPaths.add('.*fiber_length');
outputTable = study.analyze(mySolution,outputPaths);
opensimMoco,writeTableToFile(outputTable,'yourFile.sto');
If it doesn't help then posting your question on the Moco forum should definitely help (Limited experience with using Moco).
Thanks,
Nicos
- Jingke Song
- Posts: 34
- Joined: Tue Oct 19, 2021 4:52 am
Re: Analysis Tool computing normalised muscle fiber lengths
Hi,Nicos!
In the matlab moco simulation, I use the following code to extract the target result information.
gaitTrackingSolution = study.solve();
outputs = StdVectorString();
outputs.add('/jointset/groundPelvis/pelvis_tilt/value');
table = study.analyze(gaitTrackingSolution,outputs);
However, the desired results cannot be obtained, and the following warning prompts are provided:
"Warning: No outputs were connected to 'reporter' of type TableReporter__double_. You can connect outputs by calling addToReport()."
Could you help me? Or give me some inspiration.
Thank you very much!
Song Jingke
In the matlab moco simulation, I use the following code to extract the target result information.
gaitTrackingSolution = study.solve();
outputs = StdVectorString();
outputs.add('/jointset/groundPelvis/pelvis_tilt/value');
table = study.analyze(gaitTrackingSolution,outputs);
However, the desired results cannot be obtained, and the following warning prompts are provided:
"Warning: No outputs were connected to 'reporter' of type TableReporter__double_. You can connect outputs by calling addToReport()."
Could you help me? Or give me some inspiration.
Thank you very much!
Song Jingke
- Jingke Song
- Posts: 34
- Joined: Tue Oct 19, 2021 4:52 am
Re: Analysis Tool computing normalised muscle fiber lengths
OK, I have found the cause of the problem.