forve-velocity curve(model arm26)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
sariah Mghames
Posts: 23
Joined: Thu Jun 30, 2016 5:56 am

forve-velocity curve(model arm26)

Post by sariah Mghames » Thu Apr 20, 2017 9:07 am

Hello,

I am working on the model of the arm 26 and I was in need to get the x and y points of the curves: passive and active force-length as well as force-velocity curve(fv)

on the github I found under opensim-core the force-length curves (x and y points) however for the fv curve i found only the implementation in ThelenMuscle of the contaction velocity (modified fv relationship)

should i do some calculation on my own for fv based on active and passive force length values then extract corresponding V and so gather some x and y points for the force-velocity curve.. or there exist somewhere on the github for uncalibrated arm26 model ?

thanks in advance for your time

Sariah

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: forve-velocity curve(model arm26)

Post by Thomas Uchida » Thu Apr 20, 2017 4:06 pm

The arm26 model contains Thelen muscles. You can use the Thelen2003Muscle::printCurveToCSVFile() method (https://simtk.org/api_docs/opensim/api_ ... 212911e4c3) to sample and export the curves. Here's a basic GUI script that will export all curves for a specified muscle:

Code: Select all

myModel = getCurrentModel()
if not myModel:
	print "ERROR: Must load a model first\n"

muscleName  = "TRIlong"
destination = "C:/OpenSim3.3/myMuscleCurves/"

mcl = modeling.Thelen2003Muscle.safeDownCast( myModel.getMuscles().get(muscleName) )
mcl.printCurveToCSVFile(modeling.Thelen2003Muscle.CurveType.FiberActiveForceLength, destination)
mcl.printCurveToCSVFile(modeling.Thelen2003Muscle.CurveType.FiberPassiveForceLength, destination)
mcl.printCurveToCSVFile(modeling.Thelen2003Muscle.CurveType.FiberForceVelocity, destination)
mcl.printCurveToCSVFile(modeling.Thelen2003Muscle.CurveType.TendonForceLength, destination)
You can modify this script to ensure the specified muscle exists or to iterate over all muscles, for example. Scripting in the GUI is described in the Confluence documentation here: http://simtk-confluence.stanford.edu:80 ... in+the+GUI. Also see the "Common Scripting Commands" page (http://simtk-confluence.stanford.edu:80 ... g+Commands) for more information.

User avatar
Eduardo Sáenz Aldea
Posts: 18
Joined: Thu Oct 25, 2018 2:47 am

Re: forve-velocity curve(model arm26)

Post by Eduardo Sáenz Aldea » Wed Apr 03, 2019 3:06 am

Hello all,

is there any way to use this command in the Matlab API (OpenSim 4.0)?
I don't really know how to access to the "Thelen2003Muscle$CurveType" variable in order to select the curve I need from the enum


https://simtk.org/api_docs/opensim/api_ ... c05a87a546

Thank you in advance

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: forve-velocity curve(model arm26)

Post by Thomas Uchida » Wed Apr 03, 2019 10:11 am

I don't really know how to access to the "Thelen2003Muscle$CurveType" variable in order to select the curve I need from the enum
Not sure this will work, but I would try "0" for FiberActiveForceLength, "1" for FiberPassiveForceLength, etc. (https://simtk.org/api_docs/opensim/api_ ... bf21ebf940).

User avatar
Eduardo Sáenz Aldea
Posts: 18
Joined: Thu Oct 25, 2018 2:47 am

Re: forve-velocity curve(model arm26)

Post by Eduardo Sáenz Aldea » Fri Apr 05, 2019 1:55 am

Thank you for the reply,

but I still can't make it work, as I do not know how to create a CurveType variable to modify the enum. I think once I get to access this OpenSim variable I will be able to choose the enum value. Any thoughts?
printCurveToCSVFile (const CurveType ctype, const std::string & path )


Thank you!

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: forve-velocity curve(model arm26)

Post by Thomas Uchida » Fri Apr 05, 2019 3:58 am

Did you try using "0" as the first argument?

User avatar
Eduardo Sáenz Aldea
Posts: 18
Joined: Thu Oct 25, 2018 2:47 am

Re: forve-velocity curve(model arm26)

Post by Eduardo Sáenz Aldea » Fri Apr 05, 2019 4:41 am

Yes I did, as you can see here:

Code: Select all

>> mcl.printCurveToCSVFile(0, destination)
No method 'printCurveToCSVFile' with matching signature found for class
'org.opensim.modeling.Thelen2003Muscle'.
 
>> mcl.printCurveToCSVFile("0", destination)
No method 'printCurveToCSVFile' with matching signature found for class
'org.opensim.modeling.Thelen2003Muscle'.
being "destination" an string for the path.

Is it there any other way to plot this kind of curves from Matlab?

User avatar
Thomas Uchida
Posts: 1795
Joined: Wed May 16, 2012 11:40 am

Re: forve-velocity curve(model arm26)

Post by Thomas Uchida » Fri Apr 05, 2019 1:56 pm

Unfortunately, I don't have a Matlab license so I can't investigate, but the CurveType enum (the first argument to printCurveToCSVFile()) may not be available in Matlab. You can check by typing "methodsview mcl" and seeing whether the first argument to printCurveToCSVFile() is recognized.

User avatar
Eduardo Sáenz Aldea
Posts: 18
Joined: Thu Oct 25, 2018 2:47 am

Re: forve-velocity curve(model arm26)

Post by Eduardo Sáenz Aldea » Mon Apr 08, 2019 8:53 am

Thank you! I think you're right, it's not available in Matlab. There is no other way to plot this kind of curves from Matlab?

User avatar
Eduardo Sáenz Aldea
Posts: 18
Joined: Thu Oct 25, 2018 2:47 am

Re: forve-velocity curve(model arm26)

Post by Eduardo Sáenz Aldea » Wed Apr 10, 2019 9:14 am

Just for the record and future use, I managed to plot this kind of curves by creating a Millard muscle with the same characteristics as the muscle I was working on. Once you have the Millard muscle there's a function that gives you access to all the muscle curves classes.

Code: Select all

import org.opensim.modeling.*
myModel = Model('Model.osim');
model_muscles = myModel.getMuscles();

% Get parameters that define the muscle
DELT1 = model_muscles.get('DELT1');
    MIF = DELT1.getMaxIsometricForce()
    OFL=DELT1.getOptimalFiberLength()
    TSL=DELT1.get_tendon_slack_length()
    PA=DELT1.getPennationAngleAtOptimalFiberLength()

% Create a Millard Muscle that replicates the previous muscle
MillardMuscle = org.opensim.modeling.Millard2012EquilibriumMuscle('DELT1Millard',MIF,OFL,TSL,PA);
% Get the curves
ffl=MillardMuscle.getFiberForceLengthCurve();
afl=MillardMuscle.getActiveForceLengthCurve();
fv=MillardMuscle.getForceVelocityCurve();
tfl=MillardMuscle.getTendonForceLengthCurve();

% Print curves
ffl.printMuscleCurveToCSVFile('D:\User\...\Curves');

% Import curves into Matlab environment 
ffl_data=importdata("D:\User\...Curves\ActiveForceLengthCurve.csv");

% Plot x and y
plot(ffl_data.data(:,1),ffl_data.data(:,2))

POST REPLY