Processing data from a saved .mat file with a function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I'm struggling with coming to a solution for this particular problem. I have created a function that takes data from a .c3d file and creates a structure and substructure with normalized data for every joint, every plane of motion, maximum, minimum, etc...
Now, I have to save the result of this function with a particular name, automatically if possible. Among the input variables, I always call a file which has the name of a test subject inside (ex: dinamica_giovanni.c3d ). I would like to implement an automatic save with that name inside the function.
After that, I have to place some of this data, depending on different movements (1 to 8) to one in 4 holes (whack a mole structure) and then process the results through anova tests etc...
I would like to create a function that loads a particular name-based, saved data from the previous point and process the data.
The input variables I would like to use are: structure of the test subject, hole number where the mole spawned, movements. For example:
output = function(subject_name, 1, 7)
also in this case, i would like to save my data in a structure (can be the output variable) that collect data every time i run the function
here is function n.1
acq = c3d2c3d(filename);
source = acq.c3dpar.point.labels;
elb_sagitt = acq.data{1,contains(source,'relbanglesxzy')}(:,1);
figure('Name','Intervals Selection')
plot(elb_sagitt);
title('Intervals Selection')
hold on
xr = round(ginput(intervals));
x = xr(:,1);
close 'Intervals Selection'
figure(2)
%Elbow Sagittal/Flexion-Extension
pos1 = [0.37 0.7 0.25 0.2];
subplot('Position',pos1);
plot(elb_sagitt)
ylim([0 120])
title('Elbow: flexion-extension')
elb_smat = [];
for ii = 1:2:intervals
elb_s = eventsnormalize(elb_sagitt,[x(ii) x(ii+1)],100);
elb_smat = cat(2,elb_s,elb_smat);
end
final.elbow.sagittal.data = elb_smat;
%Elbow Transversal/Internal-External Rotation
elb_transvers = acq.data{1,contains(source,'relbanglesxzy')}(:,3);
pos2 = [0.70 0.7 0.25 0.2];
subplot('Position',pos2);
plot(elb_transvers);
ylim([0 60])
title('Elbow: internal-external rotation')
elb_tmat = [];
for ii = 1:2:intervals
elb_t = eventsnormalize(elb_transvers,[x(ii) x(ii+1)],100);
elb_tmat = cat(2,elb_t,elb_tmat);
end
final.elbow.transversal.data = elb_tmat;
%Shoulder Sagittal/Flexion-Extension
sho_sagitt = acq.data{1,contains(source,'rshoanglesxzy')}(:,1);
pos3 = [0.04 0.4 0.25 0.2];
subplot('Position',pos3);
plot(sho_sagitt);
ylim([0 80])
title('Shoulder: flexion-extension')
sho_smat = [];
for ii = 1:2:intervals
sho_s = eventsnormalize(sho_sagitt,[x(ii) x(ii+1)],100);
sho_smat = cat(2,sho_s,sho_smat);
end
final.shoulder.sagittal.data = sho_smat;
%Shoulder Frontal/Ab-Adduction
sho_front = acq.data{1,contains(source,'rshoanglesxzy')}(:,2);
pos4 = [0.37 0.4 0.25 0.2];
subplot('Position',pos4);
plot(sho_front);
ylim([0 60])
title('Shoulder:ab-adduction')
sho_fmat = [];
for ii = 1:2:intervals
sho_f = eventsnormalize(sho_front,[x(ii) x(ii+1)],100);
sho_fmat = cat(2,sho_f,sho_fmat);
end
final.shoulder.frontal.data = sho_fmat;
%Shoulder Transversal/Internal-External Rotation
sho_transvers = acq.data{1,contains(source,'rshoanglesxzy')}(:,3);
pos5 = [0.70 0.4 0.25 0.2];
subplot('Position',pos5);
plot(sho_transvers);
ylim([0 60])
title('Shoulder: internal-external rotation')
sho_tmat = [];
for ii = 1:2:intervals
sho_t = eventsnormalize(sho_transvers,[x(ii) x(ii+1)],100);
sho_tmat = cat(2,sho_t,sho_tmat);
end
final.shoulder.transversal.data = sho_tmat;
%Wrist Sagittal/Flexion-Extension
wri_sagitt = acq.data{1,contains(source,'rwristanglesxzy')}(:,1);
pos6 = [0.19 0.1 0.25 0.2];
subplot('Position',pos6);
plot(wri_sagitt);
ylim([-30 30])
title('Wrist: flexion-extension')
wri_smat = [];
for ii = 1:2:intervals
wri_s = eventsnormalize(wri_sagitt,[x(ii) x(ii+1)],100);
wri_smat = cat(2,wri_s,wri_smat);
end
final.wrist.sagittal.data = wri_smat;
%Wrist Frontal/Ab-Adduction
wri_front = acq.data{1,contains(source,'rwristanglesxzy')}(:,2);
pos7 = [0.56 0.1 0.25 0.2];
subplot('Position',pos7);
plot(wri_front);
ylim([-30 30])
title('Wrist: ab-adduction')
wri_fmat = [];
for ii = 1:2:intervals
wri_f = eventsnormalize(wri_front,[x(ii) x(ii+1)],100);
wri_fmat = cat(2,wri_f,wri_fmat);
end
final.wrist.frontal.data = wri_fmat;
%RTrunk x
trunk_sagitt = acq.data{1,contains(source,'rtrunkangles')}(:,1);
pos8 = [0.04 0.7 0.25 0.2];
subplot('Position',pos8);
plot(trunk_sagitt)
title('Trunk')
tru_smat = [];
for ii = 1:2:intervals
tru_s = eventsnormalize(trunk_sagitt,[x(ii) x(ii+1)],100);
tru_smat = cat(2,tru_s,tru_smat);
end
final.trunk.sagittal.data = tru_smat;
final.elbow.sagittal.MAX.data = max(final.elbow.sagittal.data);
final.elbow.sagittal.MIN.data = min(final.elbow.sagittal.data);
final.elbow.sagittal.ROM.data = final.elbow.sagittal.MAX.data - final.elbow.sagittal.MIN.data;
final.elbow.sagittal.MAX.mean = mean(final.elbow.sagittal.MAX.data);
final.elbow.sagittal.MIN.mean = mean(final.elbow.sagittal.MIN.data);
final.elbow.sagittal.ROM.mean = mean(final.elbow.sagittal.ROM.data);
final.elbow.sagittal.MAX.std = std(final.elbow.sagittal.MAX.data);
final.elbow.sagittal.MIN.std = std(final.elbow.sagittal.MIN.data);
final.elbow.sagittal.ROM.std = std(final.elbow.sagittal.ROM.data);
final.elbow.transversal.MAX.data = max(final.elbow.transversal.data);
final.elbow.transversal.MIN.data = min(final.elbow.transversal.data);
final.elbow.transversal.ROM.data = final.elbow.transversal.MAX.data - final.elbow.transversal.MIN.data;
final.elbow.transversal.MAX.mean = mean(final.elbow.transversal.MAX.data);
final.elbow.transversal.MIN.mean = mean(final.elbow.transversal.MIN.data);
final.elbow.transversal.ROM.mean = mean(final.elbow.transversal.ROM.data);
final.elbow.transversal.MAX.std = std(final.elbow.transversal.MAX.data);
final.elbow.transversal.MIN.std = std(final.elbow.transversal.MIN.data);
final.elbow.transversal.ROM.std = std(final.elbow.transversal.ROM.data);
final.shoulder.sagittal.MAX.data = max(final.shoulder.sagittal.data);
final.shoulder.sagittal.MIN.data = min(final.shoulder.sagittal.data);
final.shoulder.sagittal.ROM.data = final.shoulder.sagittal.MAX.data - final.shoulder.sagittal.MIN.data;
final.shoulder.sagittal.MAX.mean = mean(final.shoulder.sagittal.MAX.data);
final.shoulder.sagittal.MIN.mean = mean(final.shoulder.sagittal.MIN.data);
final.shoulder.sagittal.ROM.mean = mean(final.shoulder.sagittal.ROM.data);
final.shoulder.sagittal.MAX.std = std(final.shoulder.sagittal.MAX.data);
final.shoulder.sagittal.MIN.std = std(final.shoulder.sagittal.MIN.data);
final.shoulder.sagittal.ROM.std = std(final.shoulder.sagittal.ROM.data);
final.shoulder.transversal.MAX.data = max(final.shoulder.transversal.data);
final.shoulder.transversal.MIN.data = min(final.shoulder.transversal.data);
final.shoulder.transversal.ROM.data = final.shoulder.transversal.MAX.data - final.shoulder.transversal.MIN.data;
final.shoulder.transversal.MAX.mean = mean(final.shoulder.transversal.MAX.data);
final.shoulder.transversal.MIN.mean = mean(final.shoulder.transversal.MIN.data);
final.shoulder.transversal.ROM.mean = mean(final.shoulder.transversal.ROM.data);
final.shoulder.transversal.MAX.std = std(final.shoulder.transversal.MAX.data);
final.shoulder.transversal.MIN.std = std(final.shoulder.transversal.MIN.data);
final.shoulder.transversal.ROM.std = std(final.shoulder.transversal.ROM.data);
final.shoulder.frontal.MAX.data = max(final.shoulder.frontal.data);
final.shoulder.frontal.MIN.data = min(final.shoulder.frontal.data);
final.shoulder.frontal.ROM.data = final.shoulder.frontal.MAX.data - final.shoulder.frontal.MIN.data;
final.shoulder.frontal.MAX.mean = mean(final.shoulder.frontal.MAX.data);
final.shoulder.frontal.MIN.mean = mean(final.shoulder.frontal.MIN.data);
final.shoulder.frontal.ROM.mean = mean(final.shoulder.frontal.ROM.data);
final.shoulder.frontal.MAX.std = std(final.shoulder.frontal.MAX.data);
final.shoulder.frontal.MIN.std = std(final.shoulder.frontal.MIN.data);
final.shoulder.frontal.ROM.std = std(final.shoulder.frontal.ROM.data);
final.wrist.sagittal.MAX.data = max(final.wrist.sagittal.data);
final.wrist.sagittal.MIN.data = min(final.wrist.sagittal.data);
final.wrist.sagittal.ROM.data = final.wrist.sagittal.MAX.data - final.wrist.sagittal.MIN.data;
final.wrist.sagittal.MAX.mean = mean(final.wrist.sagittal.MAX.data);
final.wrist.sagittal.MIN.mean = mean(final.wrist.sagittal.MIN.data);
final.wrist.sagittal.ROM.mean = mean(final.wrist.sagittal.ROM.data);
final.wrist.sagittal.MAX.std = std(final.wrist.sagittal.MAX.data);
final.wrist.sagittal.MIN.std = std(final.wrist.sagittal.MIN.data);
final.wrist.sagittal.ROM.std = std(final.wrist.sagittal.ROM.data);
final.wrist.frontal.MAX.data = max(final.wrist.frontal.data);
final.wrist.frontal.MIN.data = min(final.wrist.frontal.data);
final.wrist.frontal.ROM.data = final.wrist.frontal.MAX.data - final.wrist.frontal.MIN.data;
final.wrist.frontal.MAX.mean = mean(final.wrist.frontal.MAX.data);
final.wrist.frontal.MIN.mean = mean(final.wrist.frontal.MIN.data);
final.wrist.frontal.ROM.mean = mean(final.wrist.frontal.ROM.data);
final.wrist.frontal.MAX.std = std(final.wrist.frontal.MAX.data);
final.wrist.frontal.MIN.std = std(final.wrist.frontal.MIN.data);
final.wrist.frontal.ROM.std = std(final.wrist.frontal.ROM.data);
final.trunk.sagittal.MAX.data = max(final.trunk.sagittal.data);
final.trunk.sagittal.MIN.data = min(final.trunk.sagittal.data);
final.trunk.sagittal.ROM.data = final.trunk.sagittal.MAX.data - final.trunk.sagittal.MIN.data;
final.trunk.sagittal.MAX.mean = mean(final.trunk.sagittal.MAX.data);
final.trunk.sagittal.MIN.mean = mean(final.trunk.sagittal.MIN.data);
final.trunk.sagittal.ROM.mean = mean(final.trunk.sagittal.ROM.data);
final.trunk.sagittal.MAX.std = std(final.trunk.sagittal.MAX.data);
final.trunk.sagittal.MIN.std = std(final.trunk.sagittal.MIN.data);
final.trunk.sagittal.ROM.std = std(final.trunk.sagittal.ROM.data);
0 Kommentare
Antworten (1)
Nikhilesh
am 31 Mär. 2023
Hi Davide,
Please look at the documentation for " save " function.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!