Page 1 of 1

Retrieving muscle parameters using Python

Posted: Tue Dec 11, 2018 3:20 am
by 00ocai
I'd like to retrieve a list of muscles in my model. Ultimately the goal is to be able to access and edit the muscle parameters for each muscle but to begin with, I thought it'd be a good idea to try and retrieve a list of muscles first and go from there. The code I've been trying to so far is resulting in "None" being printed. Any help to point me in the right direction would be great!

Code: Select all

import opensim
myModel = opensim.Model('Strong_Model.osim')
muscleSet = myModel.safeDownCast(myModel.getMuscles())
print(muscleSet)

Re: Retrieving muscle parameters using Python

Posted: Tue Dec 11, 2018 8:18 am
by 00ocai
I managed to resolve the list issue and have attached the code that I used incase someone else might find it useful:

Code: Select all

import opensim
myModel = opensim.Model('Strong_Model.osim')
myModel.muscleSet = myModel.getMuscles()
print("\nMUSCLES")
for i in range(myModel.muscleSet.getSize()):
            print(i,myModel.muscleSet.get(i).getName())
I found this link to script particulary useful:
https://github.com/stanfordnmbl/osim-rl ... nv/osim.py