Skip to content

Commit 7192ef2

Browse files
committed
add time to results and fix sot file headers
1 parent 9fe5df7 commit 7192ef2

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

MATLAB/getMuscleForceDirection.m

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
% check feasibility of the requested operation
5454
isBodyInModel(osimModel, bodyOfInterest_name);
5555

56+
% TODO: deal with multiple body expressed in distinct reference systems by
57+
% creating a loop here and using cell arrays.
58+
5659
% get body of interest
5760
bodyOfInterest = osimModel.getBodySet.get(bodyOfInterest_name);
5861

@@ -244,12 +247,15 @@
244247
end
245248
end
246249

250+
% time vector
251+
time_v = getMatStructColumn(IKStruct, 'time');
252+
247253
%----------- OUTPUT FILES ------------
248254
% Output files are the same as the C++ plugin.
249255
% Names and descriptions are taken from the manual
250256
[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]);
257+
MFD_sto_file_att = fullfile(p, [n,'_MuscleForceDirection_attachments', e]);
258+
MFD_sto_file_vec = fullfile(p, [n,'_MuscleForceDirection_vectors', e]);
253259

254260
%-----------------------------------
255261
% MuscleForceDirection_vectors.sto |
@@ -259,11 +265,12 @@
259265
% selected body where the attachment is located outwards. The body in whose
260266
% reference system the vector is expressed is always reported as the final
261267
% part of the column header of each muscle.
262-
MFD.vectors.colheaders = colheaders_MFD_vec;
263-
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"];
268+
MFD.vectors.colheaders = [{'time'} colheaders_MFD_vec];
269+
MFD.vectors.data = [time_v, mus_info_mat(:, :, 3)];
270+
MFD_vec_descr = ['the normalized muscle lines of action expressed in ',...
271+
bodyExpressResultsIn_name, ...
272+
' reference system'];
273+
% write file
267274
Mat2sto(MFD.vectors, MFD_sto_file_vec, MFD_vec_descr)
268275

269276
%---------------------------------------
@@ -274,20 +281,23 @@
274281
% attachments in the local reference system, the file will contain the
275282
% first and last muscle points specified for that muscle in the original model file.
276283

277-
MFD.attach.colheaders = colheaders_MFD_attach;
284+
MFD.attach.colheaders = [{'time'}, colheaders_MFD_attach];
278285

286+
% check if anatomical or effective attachments are required
279287
if strcmp(effective_attachm, 'true')
280-
% anatomical
281-
MFD.anatom_attach.data = mus_info_mat(:, :, 1);
288+
% effective attachment if required
289+
MFD.attach.data = [time_v, mus_info_mat(:, :, 2)];
290+
descr = 'effective';
282291
else
283-
% effective
284-
MFD.effect_attach.data = mus_info_mat(:, :, 2);
292+
% anatomical attachments by default
293+
MFD.attach.data = [time_v, mus_info_mat(:, :, 1)];
294+
descr = 'amatomical';
285295
end
286296

287-
MFD_attach_descr = ["the position of the muscle attachments expressed in ",...
297+
MFD_attach_descr = ['the ',descr ,' position of the muscle attachments expressed in ',...
288298
bodyExpressResultsIn_name, ...
289-
" reference system"];
290-
Mat2sto(MFD.vectors, MFD_sto_file_att, MFD_attach_descr)
299+
' reference system'];
300+
Mat2sto(MFD.attach, MFD_sto_file_att, MFD_attach_descr)
291301

292302
%----------------------------------------
293303
% MuscleForceDirection_transp_moment.sto |

0 commit comments

Comments
 (0)