|
34 | 34 | % ------------------------------------------------------------------------% |
35 | 35 | function [MFD, MFDSumStruct] = getMuscleForceDirection(osimModel_name,... |
36 | 36 | IK_mot_file,... |
| 37 | + MFD_sto_file,... |
37 | 38 | bodyOfInterest_name,... |
38 | 39 | bodyExpressResultsIn_name,... |
39 | 40 | effective_attachm,... |
|
55 | 56 | % get body of interest |
56 | 57 | bodyOfInterest = osimModel.getBodySet.get(bodyOfInterest_name); |
57 | 58 |
|
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) |
59 | 61 | if strcmp(bodyExpressResultsIn_name, bodyOfInterest_name)==1 |
60 | 62 | bodyExpressResultsIn = bodyOfInterest; |
61 | 63 | else |
|
132 | 134 | n_keep = 1; |
133 | 135 |
|
134 | 136 | % 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('--------------------'); |
138 | 140 |
|
139 | 141 | for n_m = 0:N_target_muscles-1 |
140 | 142 |
|
|
143 | 145 | curr_mus = muscleSet.get(curr_mus_name); |
144 | 146 |
|
145 | 147 | % 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]); |
148 | 150 |
|
149 | 151 | % make available info about the muscle pointSet (body names |
150 | 152 | % and points coordinates) |
|
245 | 247 | %----------- OUTPUT FILES ------------ |
246 | 248 | % Output files are the same as the C++ plugin. |
247 | 249 | % 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 | + |
249 | 254 | %----------------------------------- |
250 | 255 | % MuscleForceDirection_vectors.sto | |
251 | 256 | %----------------------------------- |
|
256 | 261 | % part of the column header of each muscle. |
257 | 262 | MFD.vectors.colheaders = colheaders_MFD_vec; |
258 | 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"]; |
| 267 | +Mat2sto(MFD.vectors, MFD_sto_file_vec, MFD_vec_descr) |
259 | 268 |
|
260 | 269 | %--------------------------------------- |
261 | 270 | % MuscleForceDirection_attachments.sto | |
|
265 | 274 | % attachments in the local reference system, the file will contain the |
266 | 275 | % first and last muscle points specified for that muscle in the original model file. |
267 | 276 |
|
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) |
270 | 291 |
|
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); |
273 | 298 |
|
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 |
282 | 299 |
|
283 | 300 | %-------------------------- |
284 | 301 | % Advanced MATLAB summary | |
|
0 commit comments