I am attempting to create the scale setup file http://simtk-confluence.stanford.edu:80 ... Setup+File. This is proving somewhat difficult because this is not at all straight-forward. Though through the scant posts that I could find knocking around, I think I am half-way there. This provided some guidance: viewtopicPhpbb.php?f=91&t=3977.
Alas, this is what I have.
Code: Select all
import opensim as osim
import yaml
import os.path
class scaleTools(object):
def __init__(self, trial):
# Set data directory
self.subPath = "/data/DATA/experiments/"
self.trial = str(trial).zfill(3)
self.path = os.path.join(self.subPath, 'T' + self.trial + '/')
def createSetupFile(self):
with open(os.path.join(self.path + 'meta-' + self.trial + '.yml') , 'r') as f:
doc = yaml.load(f)
subjectMeta = doc['subject']
# Get some marker data stuff
markerData = osim.MarkerData(self.path+'marker_static-'+self.trial+'.trc')
initial_time = markerData.getStartFrameTime()
final_time = markerData.getLastFrameTime()
# Setup scaling
sct = osim.ScaleTool()
sct.setSubjectMass(float(subjectMeta['mass']))
sct.setSubjectHeight(float(subjectMeta['height']))
sct.setSubjectAge(subjectMeta['age'])
sct.setName('bob')
sct.getMarkerPlacer().setStaticPoseFileName(self.path + 'marker_static-' + self.trial + '.trc')
sct.setStartTime(initial_time)
sct.setEndTime(final_time)
sct.setPrintResultFiles()
1. I am loading .trc files from a directory.
2. The each experiment has a meta data stored in a .yml file from which I basically just copying pasting into what I hope will be a functioning .xml file.
Now the real problem is I am not entirely sure where to go from the above code, nor really how to execute it. Thus far I have filled out basic methods from the C/C++ API and that seems to work sort of well (though still no .xml file). But one of the users above seems to suggest that one should run
Code: Select all
osim.process.modelScaler()
Anyone care to fill in the blanks so I can actually save a setup_file.xml? Most appreciated.