Analysis Tool computing normalised muscle fiber lengths

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Christian Greve
Posts: 41
Joined: Mon Jun 13, 2016 11:14 pm

Analysis Tool computing normalised muscle fiber lengths

Post by Christian Greve » Wed Jun 15, 2022 8:04 am

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

Tags:

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: Analysis Tool computing normalised muscle fiber lengths

Post by Nicos Haralabidis » Wed Jun 15, 2022 4:47 pm

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

User avatar
Christian Greve
Posts: 41
Joined: Mon Jun 13, 2016 11:14 pm

Re: Analysis Tool computing normalised muscle fiber lengths

Post by Christian Greve » Thu Jun 16, 2022 1:11 am

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.

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()

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: Analysis Tool computing normalised muscle fiber lengths

Post by Nicos Haralabidis » Thu Jun 16, 2022 10:46 am

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

User avatar
Jingke Song
Posts: 34
Joined: Tue Oct 19, 2021 4:52 am

Re: Analysis Tool computing normalised muscle fiber lengths

Post by Jingke Song » Sat Apr 01, 2023 6:40 am

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

User avatar
Jingke Song
Posts: 34
Joined: Tue Oct 19, 2021 4:52 am

Re: Analysis Tool computing normalised muscle fiber lengths

Post by Jingke Song » Sat Apr 01, 2023 8:12 pm

OK, I have found the cause of the problem.

POST REPLY