Retrieving muscle parameters using Python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Cai Birch
Posts: 31
Joined: Tue Jan 02, 2018 7:40 am

Retrieving muscle parameters using Python

Post by Cai Birch » Tue Dec 11, 2018 3:20 am

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)

Tags:

User avatar
Cai Birch
Posts: 31
Joined: Tue Jan 02, 2018 7:40 am

Re: Retrieving muscle parameters using Python

Post by Cai Birch » Tue Dec 11, 2018 8:18 am

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

POST REPLY