Skip to content

Commit 7ad205d

Browse files
committed
(feat) print results on sto file
1 parent 50c58a7 commit 7ad205d

1 file changed

Lines changed: 36 additions & 19 deletions

File tree

MATLAB/getMuscleForceDirection.m

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
% ------------------------------------------------------------------------%
3535
function [MFD, MFDSumStruct] = getMuscleForceDirection(osimModel_name,...
3636
IK_mot_file,...
37+
MFD_sto_file,...
3738
bodyOfInterest_name,...
3839
bodyExpressResultsIn_name,...
3940
effective_attachm,...
@@ -55,7 +56,8 @@
5556
% get body of interest
5657
bodyOfInterest = osimModel.getBodySet.get(bodyOfInterest_name);
5758

58-
% get body used to express results (if different from body of interest)
59+
% get body where results will be expressed
60+
% (if different from body of interest)
5961
if strcmp(bodyExpressResultsIn_name, bodyOfInterest_name)==1
6062
bodyExpressResultsIn = bodyOfInterest;
6163
else
@@ -132,9 +134,9 @@
132134
n_keep = 1;
133135

134136
% display time progression
135-
disp('--------------------');
136-
disp(['FRAME: ',num2str(n_frame),'/',num2str(N_frames),'.']);
137-
disp('--------------------');
137+
%disp('--------------------');
138+
disp(['FRAME: ',num2str(n_frame),'/',num2str(N_frames)]);
139+
%disp('--------------------');
138140

139141
for n_m = 0:N_target_muscles-1
140142

@@ -143,8 +145,8 @@
143145
curr_mus = muscleSet.get(curr_mus_name);
144146

145147
% loop through the points
146-
147-
disp(['Processing muscle (',num2str(n_m+1),'/',num2str(N_target_muscles),'): ', curr_mus_name]);
148+
% this print is too fast to be useful apart from debugging
149+
% disp(['Processing muscle (',num2str(n_m+1),'/',num2str(N_target_muscles),'): ', curr_mus_name]);
148150

149151
% make available info about the muscle pointSet (body names
150152
% and points coordinates)
@@ -245,7 +247,10 @@
245247
%----------- OUTPUT FILES ------------
246248
% Output files are the same as the C++ plugin.
247249
% Names and descriptions are taken from the manual
248-
%
250+
[p, n, e] = fileparts(MFD_sto_file);
251+
MFD_sto_file_vec = fullfile(p, [n,'_MuscleForceDirection_attachments', e]);
252+
MFD_sto_file_att = fullfile(p, [n,'_MuscleForceDirection_vectors', e]);
253+
249254
%-----------------------------------
250255
% MuscleForceDirection_vectors.sto |
251256
%-----------------------------------
@@ -256,6 +261,10 @@
256261
% part of the column header of each muscle.
257262
MFD.vectors.colheaders = colheaders_MFD_vec;
258263
MFD.vectors.data = mus_info_mat(:, :, 3);
264+
MFD_vec_descr = ["the normalized muscle lines of actions expressed in ",...
265+
bodyExpressResultsIn_name, ...
266+
" reference system"];
267+
Mat2sto(MFD.vectors, MFD_sto_file_vec, MFD_vec_descr)
259268

260269
%---------------------------------------
261270
% MuscleForceDirection_attachments.sto |
@@ -265,20 +274,28 @@
265274
% attachments in the local reference system, the file will contain the
266275
% first and last muscle points specified for that muscle in the original model file.
267276

268-
MFD.anatom_attach.colheaders = colheaders_MFD_attach;
269-
MFD.anatom_attach.data = mus_info_mat(:, :, 1);
277+
MFD.attach.colheaders = colheaders_MFD_attach;
278+
279+
if strcmp(effective_attachm, 'true')
280+
% anatomical
281+
MFD.anatom_attach.data = mus_info_mat(:, :, 1);
282+
else
283+
% effective
284+
MFD.effect_attach.data = mus_info_mat(:, :, 2);
285+
end
286+
287+
MFD_attach_descr = ["the position of the muscle attachments expressed in ",...
288+
bodyExpressResultsIn_name, ...
289+
" reference system"];
290+
Mat2sto(MFD.vectors, MFD_sto_file_att, MFD_attach_descr)
270291

271-
MFD.effect_attach.colheaders = colheaders_MFD_attach;
272-
MFD.effect_attach.data = mus_info_mat(:, :, 2);
292+
%----------------------------------------
293+
% MuscleForceDirection_transp_moment.sto |
294+
%----------------------------------------
295+
% this will write a sto file for transport moment.
296+
% MFD.transp_mom.colheaders = colheaders_MFD_vec;
297+
% MFD.transp_mom.data = mus_info_mat(:, :, 4);
273298

274-
MFD.transp_mom.colheaders = colheaders_MFD_vec;
275-
MFD.transp_mom.data = mus_info_mat(:, :, 4);
276-
%
277-
% if strcmp(effective_attachm, 'true')
278-
%
279-
% else
280-
%
281-
% end
282299

283300
%--------------------------
284301
% Advanced MATLAB summary |

0 commit comments

Comments
 (0)