forve-velocity curve(model arm26)
- sariah Mghames
- Posts: 23
- Joined: Thu Jun 30, 2016 5:56 am
forve-velocity curve(model arm26)
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
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
- Thomas Uchida
- Posts: 1795
- Joined: Wed May 16, 2012 11:40 am
Re: forve-velocity curve(model arm26)
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:
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.
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)
- Eduardo Sáenz Aldea
- Posts: 18
- Joined: Thu Oct 25, 2018 2:47 am
Re: forve-velocity curve(model arm26)
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
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
- Thomas Uchida
- Posts: 1795
- Joined: Wed May 16, 2012 11:40 am
Re: forve-velocity curve(model arm26)
Not sure this will work, but I would try "0" for FiberActiveForceLength, "1" for FiberPassiveForceLength, etc. (https://simtk.org/api_docs/opensim/api_ ... bf21ebf940).I don't really know how to access to the "Thelen2003Muscle$CurveType" variable in order to select the curve I need from the enum
- Eduardo Sáenz Aldea
- Posts: 18
- Joined: Thu Oct 25, 2018 2:47 am
Re: forve-velocity curve(model arm26)
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!
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!
- Thomas Uchida
- Posts: 1795
- Joined: Wed May 16, 2012 11:40 am
Re: forve-velocity curve(model arm26)
Did you try using "0" as the first argument?
- Eduardo Sáenz Aldea
- Posts: 18
- Joined: Thu Oct 25, 2018 2:47 am
Re: forve-velocity curve(model arm26)
Yes I did, as you can see here:
being "destination" an string for the path.
Is it there any other way to plot this kind of curves from Matlab?
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'.
Is it there any other way to plot this kind of curves from Matlab?
- Thomas Uchida
- Posts: 1795
- Joined: Wed May 16, 2012 11:40 am
Re: forve-velocity curve(model arm26)
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.
- Eduardo Sáenz Aldea
- Posts: 18
- Joined: Thu Oct 25, 2018 2:47 am
Re: forve-velocity curve(model arm26)
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?
- Eduardo Sáenz Aldea
- Posts: 18
- Joined: Thu Oct 25, 2018 2:47 am
Re: forve-velocity curve(model arm26)
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))