Scale Factors not reflecting- Matlab Scaling
Posted: Mon Jun 08, 2020 5:02 pm
Hi,
I am trying to add scale factors to ScaleSetup.xml file through Matlab scripting as below for scaled.osim file.
1. The program executes without error but the scale factors doesn't appear to be utilized. Kindly let me know what could be the error.
2, Kindly confirm me if Im looking at the appropriate value for ScaleFactors
Thanks,
Mritula
I am trying to add scale factors to ScaleSetup.xml file through Matlab scripting as below for scaled.osim file.
1. The program executes without error but the scale factors doesn't appear to be utilized. Kindly let me know what could be the error.
2, Kindly confirm me if Im looking at the appropriate value for ScaleFactors
Thanks,
Mritula
Code: Select all
%Scaling in Matlab without write xml
import org.opensim.modeling.*;
%% Include all geometry files
path='C:\OpenSim4pt1\Geometry';
ModelVisualizer.addDirToGeometrySearchPaths(path);
%%
subjectMass=100;
model = Model('D:\Gait_Recognition_Mritula\Public_Dataset\WIP\Scaling\ExecuteMatlabBatchScaling\Models\LOWER_EXTRE_MODIFIED_MRITULA2705.osim');
%% add markers to model
% set = MarkerSet(model,'D:\Gait_Recognition_Mritula\Public_Dataset\WIP\Scaling\ExecuteMatlabBatchScaling\ScaleSetup\gait2392_MarkerSet_forscalingOpensim4.xml');
% model.updMarkerSet().assign(set);
%%adding Scale Factors for segments
segNames = {'pelvis','femur_r','tibia_r','talus_r','calcn_r','toes_r',...
'femur_l','tibia_l','talus_l','calcn_l','toes_l'};
newScaleSet = ScaleSet();
s=[2,2,2];
vec = osimVec3FromArray(s)
for i = 1:length(segNames)
segScale(i) = Scale();
segScale(i).setSegmentName(segNames{i});
segScale(i).getScaleFactors(vec); %scaleFactor as input- eg[1.1 1.1 1.1]
segScale(i).setScaleFactors(vec);
segScale(i).setApply(true);
newScaleSet.cloneAndAppend(segScale(i));
end
% scale the model
state = model.initSystem;
model.scale(state,newScaleSet, subjectMass, true);
model.setName('Scaled_Model2');
model.initSystem();
model.print(['ScaledModel2.osim']);
No change in the below section before and after Scale execution
<FrameGeometry name="frame_geometry">
<!--Path to a Component that satisfies the Socket 'frame' of type Frame.-->
<socket_frame>..</socket_frame>
<!--Scale factors in X, Y, Z directions respectively.-->
-------->> <scale_factors>0.20000000000000001 0.20000000000000001 0.20000000000000001</scale_factors>
</FrameGeometry>