Batch Processing Scaling in MATLAB
- Koen Flores
- Posts: 2
- Joined: Fri Dec 15, 2017 11:12 am
Batch Processing Scaling in MATLAB
I am trying to batch process scaling in MATLAB, but I have not been able to get the .run() function to work. After looking at the python code provided by Opensim in the scripting folder (runScaling.py) I saw that the code to run the scale tool was quite different (scaleTool.getModelScaler().processModel(myState,myModel,path2subject,subjectMass);). I know that the IK and FD tool both utilized the .run() in MATLAB but I am less sure about the scale tool. Is there a MATLAB equivalent method to the python scale tool running above or known solutions to the error with the .run()? Thank you for the help.
Tags:
Re: Batch Processing Scaling in MATLAB
Unfortunately, no. If you want to do scaling through scripting, you have to run ModelScaler() and MarkerPlacer() as separate processes. The example code given in runScaling.py is the framework you will have to use for now. We hope to have a single ScaleTool.run() method in future releases.
- Koen Flores
- Posts: 2
- Joined: Fri Dec 15, 2017 11:12 am
Re: Batch Processing Scaling in MATLAB
Thank you, but I have been using the runScaling.py as a guide and only been lucky with creating a new xml file titled 'Unassigned'. What I am confused about is the relationship between the ScaleTool and ModelScaler within the code now that I have to run ModelScaler separately. Is there a simple scaleTool.ModelScaler.run()? Thanks once again.
Re: Batch Processing Scaling in MATLAB
The Tools (ScaleTool, InverseKinematicsTool, etc) were initially designed to be used by OpenSim GUI, exclusively. Because of this, their use in scripting (Matlab, Python, Jython) is not perfect. If you look at the documentation for the ScaleTool class, ModelScaler() and MarkerPlacer() are packaged as separate processes. When you run the ScaleTool through the GUI, the GUI will run these parts for you behind the scenes, but when you are trying to use the Tool through scripting, you have to run them separately (both ModelScaler() and MarkerPlacer() have a .processModel() method).
In OpenSim 4.0, we have made this easier by adding a .run() method on the ScaleTool. However, if you are running OpenSim 3.3, you will have to perform the operations as they are written out in the example script.
In OpenSim 4.0, we have made this easier by adding a .run() method on the ScaleTool. However, if you are running OpenSim 3.3, you will have to perform the operations as they are written out in the example script.
- Monica Armengol
- Posts: 8
- Joined: Fri Oct 07, 2016 1:58 am
Re: Batch Processing Scaling in MATLAB
Hi James,
I too am trying to run a scale through matlab. I have managed to get an scaled.osim model, but it doesn't really update the mass to what I am putting in, instead it updates it to the "generic file" data. I can't figure out where it's reading this from. this is part of the code I'm using:
Do you know what I'm missing?.
Thank you
I too am trying to run a scale through matlab. I have managed to get an scaled.osim model, but it doesn't really update the mass to what I am putting in, instead it updates it to the "generic file" data. I can't figure out where it's reading this from. this is part of the code I'm using:
Code: Select all
import org.opensim.modeling.*
scaleTool = ScaleTool(path.generic_scale_Setup)
model = Model(path.model_file);
model.initSystem();
state = model.initSystem();
scaleTool.setSubjectMass(subject.mass);
scaleTool.setSubjectHeight(subject.height);
scaleTool.setSubjectAge(subject.age);
scaleTool.getModelScaler().setApply(true);
scaleTool.getModelScaler().setMarkerFileName(path.static_external_MarkerName);
scaleTool.getModelScaler().setTimeRange(TimeArray);
scaleTool.getModelScaler().setPreserveMassDist(true);
scaleTool.getModelScaler().setPrintResultFiles(true);
scaleTool.getModelScaler().setOutputModelFileName(path.scaled_model);
scaleTool.getModelScaler().setOutputScaleFileName(path.scale_Set);
path2subject = scaleTool.getPathToSubject();
scaleTool.getModelScaler().processModel(state,model,path2subject,subject.mass);
state = model.initSystem();
model.print(path.scaled_model);
Thank you
Re: Batch Processing Scaling in MATLAB
What is the original mass of the model, your input mass, and the actual mass of the scaled model? What is "generic file" data?but it doesn't really update the mass to what I am putting in, instead it updates it to the "generic file" data.