Page MenuHomec4science

KINEMATICS_TOOL_reconstruction_main_file.m
No OneTemporary

File Metadata

Created
Mon, Nov 4, 14:26

KINEMATICS_TOOL_reconstruction_main_file.m

%{
--------------------------------------------------------------------------
GUI FOR RUNNING THE MOTION RECONSTRUCTION GUI
--------------------------------------------------------------------------
File Description :
This file creates the GUI for running motion reconstruction tools.
--------------------------------------------------------------------------
File Structure :
The GUI figure is created in KRHandle. The pushbuttons are defined next,
followed by the initialisation script. All the GUI control structures are
contained in KRGUIHandle. All the graphics are contained in a single
strucure : KRPlotHandles.
--------------------------------------------------------------------------
%}
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% CREATE THE MAIN FIGURE OF THE GUI
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
KRHandle = figure(...
'color', 'white',...
'units', 'normalized',...
'position', [0.1, 0.1, 0.4, 0.8],...
'toolbar', 'figure',...
'name', 'EPFL - LBO SHOULDER MODEL: BUILD MOTION (Option 2), reconstruction of a measured motion');
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% frames
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% frame defining the borders of the filtering tools
KRGUIHandle.PBFrame = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.78, 0.3, 0.16],...
'style', 'frame',...
'fontsize', 14,...
'backgroundcolor', 'white',...
'fontweight', 'bold');
% Text for the filteration frame
KRGUIHandle.PBFrameTxt = uicontrol(...
'units', 'normalized',...
'position', [0.8, 0.93, 0.1, 0.02],...
'style', 'text',...
'string', 'Data Filteration',...
'backgroundcolor', 'white',...
'fontsize', 12,...
'HorizontalAlignment','left',...
'fontweight', 'bold');
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% CREATE PUSHBUTTONS
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Push Button for Closing the GUI
KRGUIHandle.Close_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.95, 0.3, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- CLOSE TOOL ---------------------------------------</b><br><p style="font-size: 90%;"> <i> Closes the BUILD MOTION tool and returns to KINEMATICS TOOLBOX GUI</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Close Build Motion'));
% Push Button performing residual analysis
KRGUIHandle.Residual_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.89, 0.15, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- Residual Analysis --</b><br><p style="font-size: 90%;"> <i> Performs RA to define cutoff frequency</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Residual Analysis'));
% Push Button for performing harmonic analysis
KRGUIHandle.Harmonic_Button = uicontrol(...
'units', 'normalized',...
'position', [0.85, 0.89, 0.15, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- Harmonic Analysis --</b><br><p style="font-size: 90%;"> <i> Performs HA to define cutoff frequency</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Harmonic Analysis'));
% Push Button for filtering the measured kinematics
KRGUIHandle.Filter_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.78, 0.3, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- Filter Measured Data -----------------------------</b><br><p style="font-size: 90%;"> <i> Filters and transforms the measured data provided the necessary settings</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Filter Data'));
% Push Button for estimating the missing landmarks
KRGUIHandle.Estimate_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.72, 0.3, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- Estimate Missing Landmarks ------------------</b><br><p style="font-size: 90%;"> <i> Estimates evolutions of landmarks missing from the measured data (AC, TS, AI, GH, HU, CP)</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Estimate Data'));
% Push Button for performing the IK
KRGUIHandle.IK_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.67, 0.3, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- Perform Inverse Kinematics --------------------</b><br><p style="font-size: 90%;"> <i> Defines the generalized coordinates such that the model tracks the measured data</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('Inverse Kinematics'));
% Push Button for viewing the reconstructed motion together with the
% measured motion
KRGUIHandle.View_Button = uicontrol(...
'units', 'normalized',...
'position', [0.7, 0.62, 0.3, 0.05],...
'style', 'pushbutton',...
'string', '<html> <b>- View Motions ---------------------------------------</b><br><p style="font-size: 90%;"> <i> Shows the reconstructed motion resulted from IK together with the meaured+estimated motion</i></p>',...
'fontsize', 14,...
'fontweight', 'bold',...
'callback', KINEMATICS_TOOL_reconstruction_script_generator('View Motion'));
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Filtering setting
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% cutoff frequency text
KRGUIHandle.Cutoff_Frequency.Title = uicontrol(...
'units', 'normalized',...
'position', [0.71, 0.86, 0.13, 0.02],...
'style', 'text',...
'string', 'Cutoff Frequency [Hz]:',...
'backgroundcolor', 'white',...
'HorizontalAlignment','left',...
'fontsize', 12,...
'fontweight', 'bold');
% cutoff frequency value
KRGUIHandle.Cutoff_Frequency.Edit = uicontrol(...
'units', 'normalized',...
'position', [0.71, 0.84, 0.13, 0.02],...
'style', 'edit',...
'string', '2.8',...
'backgroundcolor', 'white',...
'fontsize', 14,...
'fontweight', 'bold');%,...
%'callback', KINEMATICS_TOOL_reconstruction_script_generator('Filter Data'));
% filter order text
KRGUIHandle.Filter_Order.Title = uicontrol(...
'units', 'normalized',...
'position', [0.86, 0.86, 0.13, 0.02],...
'style', 'text',...
'string', 'Filter Order:',...
'backgroundcolor', 'white',...
'fontsize', 12,...
'fontweight', 'bold');
% Height Value
KRGUIHandle.Filter_Order.Edit = uicontrol(...
'units', 'normalized',...
'position', [0.86, 0.84, 0.13, 0.02],...
'style', 'edit',...
'string', '8',...
'backgroundcolor', 'white',...
'fontsize', 14,...
'fontweight', 'bold');%,...
%'callback', KINEMATICS_TOOL_reconstruction_script_generator('Filter Data'));
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Final time
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% this time is not really important during the IK, except when we want to
% plot the resulted generalized coordinates along with time or when we want
% to define/plot their differntiation i.e. generalized velocities and
% accelerations. Otherwise, this value is of importance for force
% prediction. As it defines the dynamics of motion (accelerations and
% velocities).
% Text for imposing the final time (we know it from measurements)
KRGUIHandle.TimeFrameTxt = uicontrol(...
'units', 'normalized',...
'position', [0.57, 0.68, 0.13, 0.04],...
'style', 'text',...
'string', 'Motion time span [S]:',...
'backgroundcolor', 'white',...
'fontsize', 12,...
'HorizontalAlignment','left',...
'fontweight', 'bold');
% Edit for imposing the final time (we know it from measurements)
KRGUIHandle.TimeFrameEdit = uicontrol(...
'units', 'normalized',...
'position', [0.57, 0.68, 0.12, 0.02],...
'style', 'edit',...
'string', num2str(length(SSDATA.Measured_Kinematics.IJ)/100),... % the number of sample devided by the fs (sampling frequency) gives the total time span of the motion
'backgroundcolor', 'white',...
'fontsize', 14,...
'fontweight', 'bold');
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% INITIALISATION OF THE VISUALISATION
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Create the Axes:
%--------------------------------------------------------------------------
% axes for view motion
KRPlotHandles.View_Motion_Axes = axes(...
'units', 'normalized',...
'position', [0.2, 0.50, 0.35, 0.45]);
% Text instead of wireframe legend
KRGUIHandle.LegendTxt = uicontrol(...
'units', 'normalized',...
'position', [0.25, 0.9, 0.16, 0.04],...
'style', 'text',...
'string', 'green: measured motion blue: reconstructed motion',...
'backgroundcolor', 'white',...
'fontsize', 12,...
'HorizontalAlignment','left',...
'fontweight', 'bold');
% % axes for plot the results of IK
% KRPlotHandles.Plot_IK_Axes = axes(...
% 'units', 'normalized',...
% 'position', [0.57, 0.05, 0.41, 0.55],...
% 'xtick',[],'ytick',[],...
% 'box','on');
KRPlotHandles.Plot_IK_UiPanel = uipanel(...
'units', 'normalized',...
'Visible','on',...
'BackgroundColor','white',...
'FontSize', 10,...
'position', [-0.05, -0.02, 1.1, 0.50]);% 'BorderWidth', 0,...'BorderType', 'line',...
%--------------------------------------------------------------------------
% plot the primary view of the scaled model wireframe
%--------------------------------------------------------------------------
% Set the Axis
set(KRHandle, 'currentaxes', KRPlotHandles.View_Motion_Axes); hold on;
% % Create the 3-D Meshing Visualisations
% SPlotHandles.MeshHandle(1) = VISUALISATION_view_bone_meshing([], MEDATA, 0, BLDATA);
% SPlotHandles.MeshHandle(2) = VISUALISATION_view_bone_meshing([], MEDATA, 1, BLDATA);
% SPlotHandles.MeshHandle(3) = VISUALISATION_view_bone_meshing([], MEDATA, 2, BLDATA);
% SPlotHandles.MeshHandle(4) = VISUALISATION_view_bone_meshing([], MEDATA, 3, BLDATA);
% SPlotHandles.MeshHandle(5) = VISUALISATION_view_bone_meshing([], MEDATA, 4, BLDATA);
% SPlotHandles.MeshHandle(6) = VISUALISATION_view_bone_meshing([], MEDATA, 5, BLDATA);
% SPlotHandles.MeshHandle(7) = VISUALISATION_view_bone_meshing([], MEDATA, 6, BLDATA);
% make the meshings to look transparent
% for mesh = 1:7
% SPlotHandles.MeshHandle(mesh).FaceAlpha = 0.2;
% end
% Create the initial 3-D Wire Frame Visualisations of the scaled model
% (note that at this stage the measured data are not yet available because
% they need to be first rectified and filtered.
KRPlotHandles.WireFrameHandle(1) = VISUALISATION_view_bone_wireframe([], 0, BLDATA);
KRPlotHandles.WireFrameHandle(2) = VISUALISATION_view_bone_wireframe([], 1, BLDATA);
KRPlotHandles.WireFrameHandle(3) = VISUALISATION_view_bone_wireframe([], 2, BLDATA);
KRPlotHandles.WireFrameHandle(4) = VISUALISATION_view_bone_wireframe([], 3, BLDATA);
KRPlotHandles.WireFrameHandle(5) = VISUALISATION_view_bone_wireframe([], 4, BLDATA);
KRPlotHandles.WireFrameHandle(6) = VISUALISATION_view_bone_wireframe([], 5, BLDATA);
% the scaled model is always blue (the generic is red and the measured data are green)
for wire = 1:6
set(KRPlotHandles.WireFrameHandle(wire),'markerfacecolor', 'blue','markeredgecolor', 'blue');
end
%axis off
%axis equal; % Correct the apsect ratio.
axis ([-100 800 -400 800 -700 800]);
zoom(1); % Zoom in on the visualisation. otherwise it looks very small.
view([155, 15]); % Setup the initial camera postion [0,0] is behind horizontally.
box on;

Event Timeline