Share 
Follow 
AboutDownloadsDocumentsForumsSource CodeIssuesNews
Date:
2017-05-07 23:25
Priority:
3
State:
Open
Submitted by:
Michael Samaan (msamaan)
Assigned to:
Nobody (None)
Summary:
RRA adjusted segment weights

Detailed description
Currently, upon completion of RRA the user needs to manually input the adjusted segment weights into the RRA adjusted model (.osim) file. If possible, is there a way to have the adjusted segment weights exported to some sort of readable (i.e., .out, .xls) type of file so that these adjusted segment weights can be easily inputted into the RRA adjusted model via automated processes using Matlab?

Add A Comment: Notepad

Message  ↓
Date: 2020-02-25 22:05
Sender: Ricky Pimentel

Our group has gotten past this while scripting in Matlab by using the diary function and saving to a text file (saved as the variable RRA.MassChanges in the code below). Then we read in the text file and search for the updated segment masses and save to a new model.

Hope this helps! Contact me at rickypim@live.unc.edu for any questions.

clc;
diary(RRAfile.MassChanges); % save all text printed into command window into text file
rraTool.run(); % run RRA
diary off;
clc;

fid = fopen(RRAfile.MassChanges, 'r');
TxtData1 = textscan(fid,'%q');
TxtDataString = TxtData1{1,1};
[StarWars,~] = find(contains(TxtDataString, '*****'));

TxtData = TxtDataString(StarWars(1):end);
CellDif = 8; % number of cells between segment name and new mass value
Segments = {'pelvis','femur_r','tibia_r','talus_r','calcn_r','toes_r', ...
'femur_l','tibia_l','talus_l','calcn_l','toes_l', 'torso'};

SegInOutput = find(contains(TxtData, Segments));
SegInOutput([1, 14, 15, 16]) = []; % remove mentions of pelvis that are not for segment masses

for i = 1:length(SegInOutput) % save mass changes into Subjects structure
Subjects(subj).Trials(trial).RRAmassChanges(i).segment = Segments{i};
Subjects(subj).Trials(trial).RRAmassChanges(i).value = ...
str2double(cell2mat(TxtData(SegInOutput(i)+CellDif)));
end

% Update model segment masses based on RRA results
newModel = Model(model); % create new model
for i = 1:length(SegInOutput)
Seg = Segments{i};
Segment = newModel.getBodySet().get(Seg);
Segment.setMass(Subjects(subj).Trials(trial).RRAmassChanges(i).value);
end

% save model as osim file
RRAUpdatedModel = strcat(RRAFolder2, '\', Subjects(subj).name, '_RRA_Post1.osim');
newModel.print(RRAUpdatedModel);

No Changes Have Been Made to This Item

Feedback