Skip to content

Instantly share code, notes, and snippets.

@dustynrobots
Created November 28, 2012 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustynrobots/4162048 to your computer and use it in GitHub Desktop.
Save dustynrobots/4162048 to your computer and use it in GitHub Desktop.
Visualizing data from the appendix of Winter's Biomechanics and Motor Control of Human Movement in MATLAB
clear all; % erases all data
clf; % clears previous plot
%read in all of Winter's relevant data
kinematics = xlsread('Winter_Appendix_data_DR07112012.xlsx','A4.RelJointAngularKinematics','a5:l110');
kinetics = xlsread('Winter_Appendix_data_DR07112012.xlsx','A5.ReactionForces&Moments','a6:x111');
positions = xlsread('Winter_Appendix_data_DR07112012.xlsx','A2.Filtered_Marker_Kinematics','a5:ay111');
time = xlsread('Winter_Appendix_data_DR07112012.xlsx','A4.RelJointAngularKinematics','c5:c110');
%constants
BMR = xlsread('Winter_Appendix_data_DR07112012.xlsx','SubjectInfo','b19'); % in W
AMR_target = xlsread('Winter_Appendix_data_DR07112012.xlsx','SubjectInfo','b22'); % from Weyand
frame_rate = xlsread('Winter_Appendix_data_DR07112012.xlsx','SubjectInfo','b17'); % Hz
step_length = xlsread('Winter_Appendix_data_DR07112012.xlsx','SubjectInfo','b4'); % m
nPos = 0.668;
nNeg = 3*nPos;
h_am = 0.1;
h_sl_Neg = 0.073;
h_sl_Pos = 3*h_sl_Neg;
%read in position data to usable variables
Rib_x = positions(28:95,3);
Rib_y = positions(28:95,6);
Rhip_x = positions(28:95,9);
Rhip_y = positions(28:95,12);
Rknee_x = positions(28:95,15);
Rknee_y = positions(28:95,18);
Rankle_x = positions(28:95,27);
Rankle_y = positions(28:95,30);
Rheel_x = positions(28:95,33);
Rheel_y = positions(28:95,36);
Rmetatarsal_x = positions(28:95,39);
Rmetatarsal_y = positions(28:95,42);
Rtoe_x = positions(28:95,45);
Rtoe_y = positions(28:95,48);
Lhip_x = cat(2, positions(62:103,9)'-step_length, positions(36:61,9)'+step_length)';
Lhip_y = cat(2, positions(62:103,12)', positions(36:61,12)')';
Lknee_x = cat(2, positions(62:103,15)'-step_length, positions(36:61,15)'+step_length)';
Lknee_y = cat(2, positions(62:103,18)', positions(36:61,18)')';
Lankle_x = cat(2, positions(62:103,27)'-step_length, positions(36:61,27)'+step_length)';
Lankle_y = cat(2, positions(62:103,30)', positions(36:61,30)')';
Lheel_x = cat(2, positions(62:103,33)'-step_length, positions(36:61,33)'+step_length)';
Lheel_y = cat(2, positions(62:103,36)', positions(36:61,36)')';
Lmetatarsal_x = cat(2, positions(62:103,39)'-step_length, positions(36:61,39)'+step_length)';
Lmetatarsal_y = cat(2, positions(62:103,42)', positions(36:61,42)')';
Ltoe_x = cat(2, positions(62:103,45)'-step_length, positions(36:61,45)'+step_length)';
Ltoe_y = cat(2, positions(62:103,48)', positions(36:61,48)')';
%read in kinematic and kinetic data to usable variables
Rankle_q_dot = -kinematics(28:95,4); %rad/s
Rankle_torque = kinetics(28:95,14); %Nm
Rknee_q_dot = -kinematics(28:95,7); %rad/s
Rknee_torque = kinetics(28:95,15); %Nm
Rhip_q_dot = kinematics(28:95,10); %rad/s
Rhip_torque = kinetics(28:95,23); %Nm
time = time(28:95);
m = length(time);
Lankle_q_dot = -cat(2, kinematics(62:103,4)', kinematics(36:61,4)')';
Lankle_torque = cat(2, kinetics(62:103,14)', kinetics(36:61,14)')';
Lknee_q_dot = -cat(2, kinematics(62:103,7)', kinematics(36:61,7)')';
Lknee_torque = cat(2, kinetics(62:103,15)', kinetics(36:61,15)')';
Lhip_q_dot = cat(2, kinematics(62:103,10)', kinematics(36:61,10)')';
Lhip_torque = cat(2, kinetics(62:103,23)', kinetics(36:61,23)')';
%calculate mechanical power
Rankle_power = Rankle_q_dot .* Rankle_torque;
Rknee_power = Rknee_q_dot .* Rknee_torque;
Rhip_power = Rhip_q_dot .* Rhip_torque;
Lankle_power = Lankle_q_dot .* Lankle_torque;
Lknee_power = Lknee_q_dot .* Lknee_torque;
Lhip_power = Lhip_q_dot .* Lhip_torque;
total_power = Rankle_power + Rknee_power + Rhip_power...
+ Lankle_power + Lknee_power + Lhip_power;
%determine appropriate multiplier for pos/neg power for each DOF
for i=1:m
if(Rankle_power(i) < 0)
Rn_ankle(i) = nNeg;
Rh_ankle(i) = h_sl_Neg;
else
Rn_ankle(i) = nPos;
Rh_ankle(i) = h_sl_Pos;
end
end
for i=1:m
if(Lankle_power(i) < 0)
Ln_ankle(i) = nNeg;
Lh_ankle(i) = h_sl_Neg;
else
Ln_ankle(i) = nPos;
Lh_ankle(i) = h_sl_Pos;
end
end
for i=1:m
if(Rknee_power(i) < 0)
Rn_knee(i) = nNeg;
Rh_knee(i) = h_sl_Neg;
else
Rn_knee(i) = nPos;
Rh_knee(i) = h_sl_Pos;
end
end
for i=1:m
if(Lknee_power(i) < 0)
Ln_knee(i) = nNeg;
Lh_knee(i) = h_sl_Neg;
else
Ln_knee(i) = nPos;
Lh_knee(i) = h_sl_Pos;
end
end
for i=1:m
if(Rhip_power(i) < 0)
Rn_hip(i) = nNeg;
Rh_hip(i) = h_sl_Neg;
else
Rn_hip(i) = nPos;
Rh_hip(i) = h_sl_Pos;
end
end
for i=1:m
if(Lhip_power(i) < 0)
Ln_hip(i) = nNeg;
Lh_hip(i) = h_sl_Neg;
else
Ln_hip(i) = nPos;
Lh_hip(i) = h_sl_Pos;
end
end
% active metabolic rate according to Winter
AMR_Winter = Rn_ankle' .* abs(Rankle_power) +...
Rn_knee' .* abs(Rknee_power) +...
Rn_hip' .* abs(Rhip_power)+...
Ln_ankle' .* abs(Lankle_power) +...
Ln_knee' .* abs(Lknee_power) +...
Ln_hip' .* abs(Lhip_power);
sp = 1.19; %multipler to convert sagittal plane data to 3D data
%sagittal plane accounts for 84% of joint powers -->1/.84=1.19
%su = AMR_target/(sp*mean(AMR_Winter)) % multiplier to convert lower body data to whole body data
su = 1.05; % multiplier to convert lower body data to whole body data
AMR_Winter_s = su * sp * AMR_Winter; %AMR Winter scaled for full 3D body
AMR_Winter_mean = mean(AMR_Winter_s);
% joint space model
AMR = h_am * abs(Rankle_torque) + Rh_ankle' .* abs(Rankle_power) + abs(Rankle_power) +...
h_am * abs(Lankle_torque) + Lh_ankle' .* abs(Lankle_power) + abs(Lankle_power) +...
h_am * abs(Rknee_torque) + Rh_knee' .* abs(Rknee_power) + abs(Rknee_power) +...
h_am * abs(Lknee_torque) + Lh_knee' .* abs(Lknee_power) + abs(Lknee_power) +...
h_am * abs(Rhip_torque) + Rh_hip' .* abs(Rhip_power) + abs(Rhip_power)+...
h_am * abs(Lhip_torque) + Lh_hip' .* abs(Lhip_power) + abs(Lhip_power);
AMR_s = su * sp * AMR; % scaled AMR
AMR_mean = mean(AMR_s); % should equal AMR_Winter_mean
percent_cycle = (0:100/(m-1):100);
figure(1); % metabolic rates
plot(percent_cycle, BMR, 'k');
hold on;
plot(percent_cycle, AMR_Winter_s + BMR, 'b-.');
hold on;
%plot(time, mean(AMR_Winter_s) + BMR, 'k');
%hold on;
plot(percent_cycle, AMR_s + BMR, 'r');
%hold on;
%plot(time, mean(AMR_s) + BMR, 'g');
%hold on;
%plot(time, AMR_target + BMR, 'k');
%hold off;
xlabel('% Gait Cycle');
ylabel('Energy Expenditure Rate (Watts)');
%
% figure(2) % ankle, knee, and hip kinematics and kinetics
% %TORQUE
% subplot(3,3,1); % ankle
% plot(percent_cycle, Rankle_torque);
% hold on;
% plot(percent_cycle, Lankle_torque, 'm');
% ylabel('Torque (Nm)');
% title('Ankle');
% subplot(3,3,2); % knee
% plot(percent_cycle, Rknee_torque);
% hold on;
% plot(percent_cycle, Lknee_torque, 'm');
% ylabel('Torque (Nm)');
% title('Knee');
% subplot(3,3,3); % hip
% plot(percent_cycle, Rhip_torque);
% hold on;
% plot(percent_cycle, Lhip_torque, 'm');
% ylabel('Torque (Nm)');
% title('Hip');
%
% %ANGULAR VELOCITY
% subplot(3,3,4); % ankle
% plot(percent_cycle, Rankle_q_dot);
% hold on;
% plot(percent_cycle, Lankle_q_dot, 'm');
% ylabel('Angular Velocity (rad/s)');
% %title('ankle rad/s');
% subplot(3,3,5); % knee
% plot(percent_cycle, Rknee_q_dot);
% hold on;
% plot(percent_cycle, Lknee_q_dot, 'm');
% ylabel('Angular Velocity (rad/s)');
% %title('knee rad/s');
% subplot(3,3,6); % hip
% plot(percent_cycle, Rhip_q_dot);
% hold on;
% plot(percent_cycle, Lhip_q_dot, 'm');
% ylabel('Angular Velocity (rad/s)');
% %title('hip rad/s');
%
% %POWER
% subplot(3,3,7); % ankle
% plot(percent_cycle, Rankle_power);
% hold on;
% plot(percent_cycle, Lankle_power, 'm');
% title('ankle power');
% subplot(3,3,8); % knee
% plot(percent_cycle, Rknee_power);
% hold on;
% plot(percent_cycle, Lknee_power, 'm');
% title('knee power');
% subplot(3,3,9); % hip
% plot(percent_cycle, Rhip_power);
% hold on;
% plot(percent_cycle, Lhip_power, 'm');
% title('hip power');
figure(3);
for f=1:m;
line([Rib_x(f) Rhip_x(f)],[Rib_y(f) Rhip_y(f)],'Marker','.','LineStyle','-','Color','k'); % rib to Rhip
line([Rhip_x(f) Rknee_x(f)],[Rhip_y(f) Rknee_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rhip to Rknee
line([Rknee_x(f) Rankle_x(f)],[Rknee_y(f) Rankle_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rknee to Rankle
line([Rankle_x(f) Rheel_x(f)],[Rankle_y(f) Rheel_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rankle to Rheel
line([Rheel_x(f) Rmetatarsal_x(f)],[Rheel_y(f) Rmetatarsal_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rheel to Rmetatarsal
line([Rmetatarsal_x(f) Rtoe_x(f)],[Rmetatarsal_y(f) Rtoe_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rmetatarsal to Rtoe
line([Rankle_x(f) Rmetatarsal_x(f)],[Rankle_y(f) Rmetatarsal_y(f)],'Marker','.','LineStyle','-','Color','k'); % Rankle to Rmetatarsal
line([Lhip_x(f) Lknee_x(f)],[Lhip_y(f) Lknee_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lhip to Lknee
line([Lknee_x(f) Lankle_x(f)],[Lknee_y(f) Lankle_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lknee to Lankle
line([Lankle_x(f) Lheel_x(f)],[Lankle_y(f) Lheel_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lankle to Lheel
line([Lheel_x(f) Lmetatarsal_x(f)],[Lheel_y(f) Lmetatarsal_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lheel to Lmetatarsal
line([Lmetatarsal_x(f) Ltoe_x(f)],[Lmetatarsal_y(f) Ltoe_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lmetatarsal to Ltoe
line([Lankle_x(f) Lmetatarsal_x(f)],[Lankle_y(f) Lmetatarsal_y(f)],'Marker','.','LineStyle','-','Color','m'); % Lankle to Lmetatarsal
hold on
end
xlabel('x (m)');
ylabel('y (m)');
axis equal
axis([.5 3 0 1.2])
@mrrezaie
Copy link

mrrezaie commented Jun 8, 2018

hi
how can i download Winter_Appendix_data_DR07112012.xlsx file?
thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment