MATLAB and 'Normalized fiber length'
Posted: Sat Apr 14, 2018 7:51 pm
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));
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));