API for Matlab to call OpenSim

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Xiao Hu
Posts: 21
Joined: Fri Jun 26, 2009 9:25 am

API for Matlab to call OpenSim

Post by Xiao Hu » Wed Jun 30, 2010 7:36 am


Hi,

In the user's guide Release 2.01, it is said that API is available so that we can programmatically call OpenSim from other programs (such as Matlab).

I wonder where I can find specific information about how to use this API. I do not find this information in user's guide. Is it in the developer's guide? I feel developer's guide talks a lot about API, but does not specifically say anything about the API for Matlab.

Thanks a lot!

Xiao

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

RE: API for Matlab to call OpenSim

Post by Ayman Habib » Wed Jun 30, 2010 10:05 am

Hi Xiao,

There's nothing specifically done by the OpenSim team to connect/enable the use of OpenSim in Matlab, however:
1. Since OpenSim exposes a C++ API, you can write your own wrappers to call this API from Matlab using Matlab's mex functions.
2. There are a couple efforts to enable tighter integration between OpenSim and Simulink (e.g. https://simtk.org/home/opensim_matlab). Please contact the project administrators on simtk.org if you need more info about availability.
3. Depending on the level of integration you want it maybe sufficient for you to run the OpenSim command line tools (e.g. scale, ik, cmc, forward) from the Matlab shell, and use Matlab to create/edit the setup files necessary to run these tools. The user guide has instructions regarding the use of these command line tools included with the OpenSim distribution.

It would be helpful to explain what you're trying to accomplish so that we can point you in the right direction.

Best regards,
-Ayman

User avatar
Xiao Hu
Posts: 21
Joined: Fri Jun 26, 2009 9:25 am

RE: API for Matlab to call OpenSim

Post by Xiao Hu » Wed Jun 30, 2010 10:30 am

Hi Ayman,

Thanks a lot for your response!

I am thinking to call OpenSim from Matlab to pull out muscle parameters necessary for the computation in Matlab.

For example, I specify arm posture (joint angles) in Matlab; Matlab passes it to OpenSim; then OpenSim calculates muscle parameters (like moment arms, musculo-tendon length) at the specified arm posture and return muscle parameters to Matlab. Finally, Matlab takes over and finish the rest computation.

So, which way is the most appropriate and simplest way to achieve my goal?

Again, thanks a lot for your help!

Xiao

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

RE: API for Matlab to call OpenSim

Post by Ayman Habib » Wed Jun 30, 2010 10:49 am

Xiao,

Depending on how comfortable you are with coding you can do either 1 or 3. Option 3 can be done with no C++ programming altogether by executing the "analyze" command line tool, including a "MuscleAnalysis". Then you can dig thru output files to extract the parameters you need. Please check the user guide for info on running the "analyze" tool. You might find it useful to run the analyze tool from the GUI first and save settings to see what the setup file looks like.

Good luck,
-Ayman

POST REPLY