Hi,
I'm trying to scalar an 0penSim upper limb model (MoBL_ARMS) using Matlab with the characteristics of my subject.
Matlab does the scaling, but the scaled model is wrong. During scaling, the model loses the ground(represented by thorax) and some bodies, in spite of they are listed in the corresponding compartment.
I wrote .c3d file, using Matlab, to create .trc file.
The script that I use is:
acq = btkNewAcquisition(n_marker, n, 0, 1);
btkSetFrequency(acq, 100);
btkSetMarkersValues(acq, M);
btkWriteAcquisition(acq, [name '_MarkerPosition.c3d']);
acq = btkReadAcquisition([name '_MarkerPosition.c3d']);
acq = btk_loadc3d([name '_MarkerPosition.c3d']);
I modified the file .c3d, adding element in the struct 'acq'.
Subject = btk_c3d2trc(acq, 'off'); % create .trc file
Also, I created .xml setup file:
subjectDir = uigetdir('Selection path where there are subject files');
[fname1, pname1] = uigetfile('*.trc','Selection Marker File ',subjectDir);
[fname2, pname2] = uigetfile('*.xml','Selection Force File ',subjectDir);
myModel = Model('MoBL_ARMS_module2_4_allmuscles.osim');
myState = myModel.initSystem();
newMarkers = MarkerSet([subjectDir '\markers.xml']);
myModel.updateMarkerSet(newMarkers);
Scale = setup_scale('ModelFile', 'MoBL_ARMS_module2_4_allmuscles.osim',...
'MarkerFile','Subject1_MarkerPosition.trc', 'data', acq);
Then, I scaled the model:
scaleTool = ScaleTool('Subject1_SetUp_Scale.xml');
scaleTool.setSubjectMass(subjectMass);
scaleTool.setSubjectHeight(subjectHeight);
path2subject = ([subjectDir '\']);
I = scaleTool.getModelScaler();
I.setMarkerFileName([name '_MarkerPosition.trc']);
I.setOutputModelFileName([name '_scaled_MoBL_ARMS.osim']);
I.setOutputScaleFileName([name '_scaleSet_applied.xml']);
initial_time = time(1);
final_time = time(end);
TimeArray=ArrayDouble();
TimeArray.set(0, initial_time);
TimeArray.set(1,final_time);
I.setTimeRange(TimeArray);
I.processModel(myModel, path2subject, subjectMass)
Thanks in advance for the help,
Maria Cristina
Scale Tool - OpenSim
- Maria Cristina Panettieri
- Posts: 8
- Joined: Sat Nov 09, 2019 1:42 am