Hello,
I have recently been exploring how to control OpenSim (3.1) with MATLAB (API). To get 'Normalized fiber length,' I wrote a script code (please see below) in MATALAB.
Although I could get 'Normalized fiber length' of the musculoskeletal model (Rajagopal et al.; Model_Rajagopal_2015.osim), I could not get 'Normalized fiber length' of another musculoskeletal model (Arnold et al.; Model_Arnold_2010.osim).
I found the same problem in this topic (viewtopicPhpbb.php?f=91&t=5834&p=0&start=0&view=). According to the topic, I will need to change 'Muscle type' from 'Schutte1993Muscle_Deprecated' to 'Thelen2003Muscle' or 'Millard2012EquilibriumMuscle.'
Although I checked this site (https://simtk.org/api_docs/opensim/api_docs/index.html) regarding API, I did not know how to change 'Muscle type' using MATLAB. Would you please modify my script code to get 'Normalized fiber length' of the musculoskeletal model (Arnold et al.)?
Best regards,
Takuma Inai
Institute for Human Movement and Medical Sciences
Niigata University of Health and Welfare
%=================
clear;
close all;
clc;
import org.opensim.modeling.*
cd(uigetdir());
%=================
% Rajagopal et al.
%=================
ModelName1 = 'Model_Rajagopal_2015';
myModel1 = Model(strcat(ModelName1,'.osim'));
state1 = myModel1.initSystem();
myModel1.updCoordinateSet().get('hip_flexion_r').setValue(state1,deg2rad(45));
myForce1 = myModel1.getMuscles().get('psoas_r');
muscleType1 = char(myForce1.getConcreteClassName()); % 'Millard2012EquilibriumMuscle'
eval(strcat('myMuscle1=',muscleType1,'.safeDownCast(myForce1);'));
myMuscle1.setDefaultActivation(0.01);
myModel1.equilibrateMuscles(state1);
display(myMuscle1.getNormalizedFiberLength(state1));
%=================
% Arnold et al.
%=================
ModelName2 = 'Model_Arnold_2010';
myModel2 = Model(strcat(ModelName2,'.osim'));
state2 = myModel2.initSystem();
myModel2.updCoordinateSet().get('hip_flexion_r').setValue(state2,deg2rad(45));
myForce2 = myModel2.getMuscles().get('psoas_r');
muscleType2 = char(myForce2.getConcreteClassName()); % 'Schutte1993Muscle_Deprecated'
eval(strcat('myMuscle2=',muscleType2,'.safeDownCast(myForce2);'));
myMuscle2.setDefaultActivation(0.01);
myModel2.equilibrateMuscles(state2);
display(myMuscle2.getNormalizedFiberLength(state2));
MATLAB and 'Normalized fiber length'
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: MATLAB and 'Normalized fiber length'
The Schutte1993Muscle_Deprecated model is deprecated and, as such, is no longer supported. Also note that you are using an old version of OpenSim and may want to upgrade to 3.3.
An easy way to change muscle type is by opening the .osim file in a text editor. Note that it may be necessary to adjust muscle properties as well.I did not know how to change 'Muscle type' using MATLAB
You should be able to use the getFiberLength() method from the Muscle class (https://simtk.org/api_docs/opensim/api_ ... 46468804f4) and then normalize by optimal fiber length (https://simtk.org/api_docs/opensim/api_ ... e843918a75).Would you please modify my script code to get 'Normalized fiber length' of the musculoskeletal model (Arnold et al.)?
- Takuma Inai
- Posts: 6
- Joined: Sat Oct 26, 2013 12:11 am
Re: MATLAB and 'Normalized fiber length'
Dear Mr Uchida,
Thank you for the quick response.
I do appreciate your help.
Best regards,
Takuma Inai
Institute for Human Movement and Medical Sciences
Niigata University of Health and Welfare
Thank you for the quick response.
I do appreciate your help.
Best regards,
Takuma Inai
Institute for Human Movement and Medical Sciences
Niigata University of Health and Welfare