|
53 | 53 | % check feasibility of the requested operation |
54 | 54 | isBodyInModel(osimModel, bodyOfInterest_name); |
55 | 55 |
|
| 56 | +% TODO: deal with multiple body expressed in distinct reference systems by |
| 57 | +% creating a loop here and using cell arrays. |
| 58 | + |
56 | 59 | % get body of interest |
57 | 60 | bodyOfInterest = osimModel.getBodySet.get(bodyOfInterest_name); |
58 | 61 |
|
|
244 | 247 | end |
245 | 248 | end |
246 | 249 |
|
| 250 | +% time vector |
| 251 | +time_v = getMatStructColumn(IKStruct, 'time'); |
| 252 | + |
247 | 253 | %----------- OUTPUT FILES ------------ |
248 | 254 | % Output files are the same as the C++ plugin. |
249 | 255 | % Names and descriptions are taken from the manual |
250 | 256 | [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]); |
253 | 259 |
|
254 | 260 | %----------------------------------- |
255 | 261 | % MuscleForceDirection_vectors.sto | |
|
259 | 265 | % selected body where the attachment is located outwards. The body in whose |
260 | 266 | % reference system the vector is expressed is always reported as the final |
261 | 267 | % 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 |
267 | 274 | Mat2sto(MFD.vectors, MFD_sto_file_vec, MFD_vec_descr) |
268 | 275 |
|
269 | 276 | %--------------------------------------- |
|
274 | 281 | % attachments in the local reference system, the file will contain the |
275 | 282 | % first and last muscle points specified for that muscle in the original model file. |
276 | 283 |
|
277 | | -MFD.attach.colheaders = colheaders_MFD_attach; |
| 284 | +MFD.attach.colheaders = [{'time'}, colheaders_MFD_attach]; |
278 | 285 |
|
| 286 | +% check if anatomical or effective attachments are required |
279 | 287 | 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'; |
282 | 291 | 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'; |
285 | 295 | end |
286 | 296 |
|
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 ',... |
288 | 298 | 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) |
291 | 301 |
|
292 | 302 | %---------------------------------------- |
293 | 303 | % MuscleForceDirection_transp_moment.sto | |
|
0 commit comments