Calculating metabolic cost in matlab using OpenSim API
Posted: Thu Jun 25, 2020 7:00 pm
Hello,
How to get metabolic cost from the model using OpenSim API commands.
The procedure I followed :
1. Attach metabolic probe to the model in OpenSim GUI using the already given python code.
2. Import this model in Matlab.
3. From the saved files of joint trajectory (theta vs time), muscle activities and muscle excitations, I access these values, and assign them one at a time to the current state of the model.
4. Then, the model is realised to the dynamics stage and integrated. This operation is done in a for loop, which is the number of steps in the trajectory file.
5. In every loop, the metabolic probe is being accessed by the command model.getProbeSet().get(0) and it's output is taken by model.getProbeSet().get(0).getProbeOutput(). This gave an array whose first element is the total metabolic rate.
The input files of angle, activation and excitation to this code which I am using are the output from CMC in OpenSim GUI. So, the metabolic cost plot obtained from the CMC has to match with the metabolic cost plot obtained here. But this is not happening.
The result I am getting here has the same pattern as that of from the CMC of OpenSim GUI but the value is much less. May be one component of metabolic cost is not being calculated by this inbuilt metabolic probe. Or is this method wrong somewhere.
Is there some other way, to do this. I just want to use those files to calculate metabolic cost, how can I do this. Please help.
Thanks,
Ratna
How to get metabolic cost from the model using OpenSim API commands.
The procedure I followed :
1. Attach metabolic probe to the model in OpenSim GUI using the already given python code.
2. Import this model in Matlab.
3. From the saved files of joint trajectory (theta vs time), muscle activities and muscle excitations, I access these values, and assign them one at a time to the current state of the model.
4. Then, the model is realised to the dynamics stage and integrated. This operation is done in a for loop, which is the number of steps in the trajectory file.
5. In every loop, the metabolic probe is being accessed by the command model.getProbeSet().get(0) and it's output is taken by model.getProbeSet().get(0).getProbeOutput(). This gave an array whose first element is the total metabolic rate.
The input files of angle, activation and excitation to this code which I am using are the output from CMC in OpenSim GUI. So, the metabolic cost plot obtained from the CMC has to match with the metabolic cost plot obtained here. But this is not happening.
The result I am getting here has the same pattern as that of from the CMC of OpenSim GUI but the value is much less. May be one component of metabolic cost is not being calculated by this inbuilt metabolic probe. Or is this method wrong somewhere.
Is there some other way, to do this. I just want to use those files to calculate metabolic cost, how can I do this. Please help.
Thanks,
Ratna