Code covered by the BSD License  

Highlights from
Toolbox to analyze nanoindentation data.

image thumbnail

Toolbox to analyze nanoindentation data.

by

 

06 Sep 2013 (Updated )

A MATLAB GUI to plot and to analyze (nano)indentation data (obtained with conical indenters)

GUI_Extraction_EP_properties_for_multilayer_sample
%% Copyright 2014 MERCIER David
function gui_handle = GUI_Extraction_EP_properties_for_multilayer_sample
%% Function to run the Matlab GUI for the calculations of elastic-plastic properties
% of a multilayer system from indentation experiments with a conical indenter
%% Initialization
clear all; close all; clear classes;
delete(findall(0,'Type','figure'));
format compact;
commandwindow; clc; clearvars;

%% Paths Management
path_management_GUI; %Definition of the Matlab search paths
if ismac || isunix
    addpath(genpath('path\to\codes'));
else
    addpath(genpath('path/to/codes'));
end

[startdir, f, ext] = fileparts(mfilename('fullpath'));
cd(startdir);

%% Import data from YAML config file
configYAML = sprintf('GUI_config.yaml');

if ~exist(configYAML, 'file')
    errordlg('YAML File not found !', 'File Error');
    gui.config = struct();
else
    gui.config = ReadYaml(configYAML);
end

if isfield(gui.config, 'data_path') == 0
    gui.config.data_path = pwd;
end

%% Main Window Coordinates Configuration
scrsize = get(0, 'ScreenSize'); % Get screen size
WX = 0.05 * scrsize(3);           % X Position (bottom)
WY = 0.10 * scrsize(4);           % Y Position (left)
WW = 0.90 * scrsize(3);           % Width
WH = 0.80 * scrsize(4);           % Height

%% Main Window Configuration
gui.handles.MainWindows = figure('Name', ['Main Menu',' (', mfilename,'.m)'],...
    'NumberTitle', 'off',...
    'PaperUnits', get(0, 'defaultfigurePaperUnits'),...
    'Color', [0.9 0.9 0.9],...
    'Colormap', get(0,'defaultfigureColormap'),...
    'toolBar', 'figure',...
    'InvertHardcopy', get(0, 'defaultfigureInvertHardcopy'),...
    'PaperPosition', [0 7 50 15],...
    'Color', [0.906 0.906 0.906],...
    'Position', [WX WY WW WH]);

%% Title of the GUI
gui.handles.title_GUI_1 = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.31 0.96 0.6 0.04],...
    'String', 'Extraction of mechanical properties of thin film(s) on substrate by nanoindentation (with conical indenters)',...
    'FontWeight', 'bold',...
    'FontSize', 12,...
    'HorizontalAlignment', 'center',...
    'ForegroundColor', 'red');

gui.handles.title_GUI_2 = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.31 0.93 0.6 0.03],...
    'String', 'Version 2.0 - Copyright 2014 MERCIER David',...
    'FontWeight', 'bold',...
    'FontSize', 10,...
    'HorizontalAlignment', 'center',...
    'ForegroundColor', 'red');

%% Date / Time
gui.handles.date_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'String', datestr(datenum(clock),'mmm.dd,yyyy HH:MM'),...
    'Position', [0.92 0.975 0.075 0.02]);

%% Buttons to browse in files
gui.handles.opendata_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'pushbutton',...
    'Position', [0.018 0.95 0.06 0.04],...
    'String', 'Select file',...
    'FontSize', 10,...
    'FontWeight','bold',...
    'BackgroundColor', [0.745 0.745 0.745],...
    'Callback', 'openfile');

gui.handles.opendata_str_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'edit',...
    'Position', [0.079 0.95 0.198 0.04],...
    'String', pwd,...
    'FontSize', 8,...
    'BackgroundColor', [0.9 0.9 0.9],...
    'HorizontalAlignment', 'left');

gui.handles.typedata_GUI1=uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.018 0.93 0.22 0.02],...
    'String', 'Units : Load (mN) / Displacement (nm) / Stiffness (N/m)',...
    'HorizontalAlignment', 'center');

gui.handles.typedata_GUI2=uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.018 0.91 0.22 0.02],...
    'String', '.txt or .xls ==> 3 (or 6) columns : Displacement / Load / Stiffness',...
    'HorizontalAlignment', 'center');

gui.handles.typedata_GUI3=uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.018 0.89 0.22 0.02],...
    'String', '.xls : XP MTS data with ''Sample'' sheet obtained with Analyst',...
    'HorizontalAlignment', 'center');

%% Definition of the minimum/maximum depth
gui.handles.title_mindepth_prop_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.86 0.07 0.02],...
    'String', 'Minimum depth :',...
    'HorizontalAlignment', 'left',...
    'Visible', 'on');

gui.handles.value_mindepth_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'edit',...
    'Position', [0.08 0.86 0.03 0.02],...
    'String', '',...
    'Visible', 'on',...
    'Callback', 'A_get_and_plot');

gui.handles.unit_mindepth_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.11 0.86 0.02 0.02],...
    'String', 'nm',...
    'HorizontalAlignment', 'center',...
    'Visible', 'on');

gui.handles.title_maxdepth_prop_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.84 0.07 0.02],...
    'String', 'Maximum depth :',...
    'HorizontalAlignment', 'left',...
    'Visible', 'on');

gui.handles.value_maxdepth_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'edit',...
    'Position', [0.08 0.84 0.03 0.02],...
    'String', '',...
    'Visible', 'on',...
    'Callback', 'A_get_and_plot');

gui.handles.unit_maxdepth_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.11 0.84 0.02 0.02],...
    'String', 'nm',...
    'HorizontalAlignment', 'center',...
    'Visible', 'on');

%% CSM corrections
gui.handles.cb_CSM_corr_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'checkbox',...
    'Position', [0.02 0.81 0.2 0.02],...
    'String', 'CSM_correction (only valide for Berkovich indenters)',...
    'Visible', 'on',...
    'Value', 0,...
    'Callback', 'A_get_and_plot');

%% Choice of the indenter (only conical indenters...)
gui.handles.title_indentertype_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.77 0.1 0.02],...
    'String', 'Type of indenter',...
    'HorizontalAlignment', 'left');

gui.handles.value_indentertype_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.75 0.1 0.02],...
    'String', gui.config.Indenter_IDs,...
    'Value', 1,...
    'Callback', 'A_refresh_indenters_GUI');

set(gui.handles.value_indentertype_GUI, 'value', find(cell2mat(strfind(gui.config.Indenter_IDs, gui.config.Indenter_ID))));

% Berkovich tip - Creation of button group
gui.handles.bg_Berkovich_tip_GUI = uibuttongroup('Parent', gui.handles.MainWindows,...
    'Visible', 'on',...
    'Position', [0.02 0.64 0.255 0.1]);

% Vickers tip - Creation of button group
gui.handles.bg_Vickers_tip_GUI = uibuttongroup('Parent', gui.handles.MainWindows,...
    'Visible', 'off',...
    'Position', [0.02 0.64 0.255 0.1]);

% Conical tip - Creation of button group
gui.handles.bg_conical_tip_GUI = uibuttongroup('Parent', gui.handles.MainWindows,...
    'Visible', 'off',...
    'Position', [0.02 0.64 0.255 0.1]);

guidata(gcf, gui);

% Set properties of indenter
A_indenters_properties_GUI;

%% Encapsulation of data into the GUI
gui = guidata(gcf); guidata(gcf, gui);

%% Properties of the sample
% Number of thin films
gui.handles.title_numthinfilm_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.61 0.1 0.02],...
    'String', 'Number of thin films',...
    'HorizontalAlignment', 'left');

gui.handles.value_numthinfilm_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.59 0.1 0.02],...
    'String', '0|1|2|3',...
    'Value', 1,...
    'Callback', 'A_refresh_indenters_GUI');

% Creation of button groups
gui.handles.bg_film2_properties_GUI    = uibuttongroup('Parent', gui.handles.MainWindows, 'Visible', 'on', 'Position', [0.02 0.5425 0.255 0.0375]);
gui.handles.bg_film1_properties_GUI    = uibuttongroup('Parent', gui.handles.MainWindows, 'Visible', 'on', 'Position', [0.02 0.5050 0.255 0.0375]);
gui.handles.bg_film0_properties_GUI    = uibuttongroup('Parent', gui.handles.MainWindows, 'Visible', 'on', 'Position', [0.02 0.4675 0.255 0.0375]);
gui.handles.bg_substrat_properties_GUI = uibuttongroup('Parent', gui.handles.MainWindows, 'Visible', 'on', 'Position', [0.02 0.4100 0.255 0.0575]);

%% Convention
gui.handles.plot_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'pushbutton',...
    'Position', [0.14 0.59 0.08 0.03],...
    'String', 'Convention',...
    'FontSize', 12,...
    'BackgroundColor', [0.745 0.745 0.745],...
    'Callback', 'figure; imshow(''MCmodel_MERCIER2010.png'');');

%% Choice of the model for contact displacement calculation
gui.handles.title_modeldisp_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.38 0.1 0.02],...
    'String', 'Model for contact displacement calculation',...
    'HorizontalAlignment', 'left');

gui.handles.value_modeldisp_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.36 0.1 0.02],...
    'String', 'Doerner&Nix|Oliver&Pharr|Loubet',...
    'Value', 2,...
    'Callback', 'A_get_and_plot');

%% Choice of the correction parameter
gui.handles.title_corrparam_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.13 0.38 0.1 0.02],...
    'String', 'Correcting parameter choice',...
    'HorizontalAlignment', 'left');

gui.handles.value_corrparam_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.13 0.36 0.1 0.02],...
    'String', 'beta_King1987|gamma_Hay1999|beta_King1987 + gamma_Hay1999',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

%% Choice of the bilayer/multilayer model
gui.handles.title_bilayermodel_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.33 0.1 0.02],...
    'String', 'Bilayer Model (Y''s M calc.)',...
    'HorizontalAlignment', 'left');

gui.handles.value_bilayermodel_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.31 0.1 0.02],...
    'String', 'No_Bilayer_Model|Doerner&Nix|Gao_etal.|Perriot_etal.|Bec_etal.|Hay_etal.',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

gui.handles.title_multilayermodel_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.33 0.1 0.02],...
    'String', 'Multilayer Model (Y''s M calc.)',...
    'HorizontalAlignment', 'left',...
    'Visible', 'off');

gui.handles.value_multilayermodel_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.31 0.1 0.02],...
    'String', 'No_Multilayer_Model|Mercier&al.',...
    'Visible', 'off',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

%% Correction of the effective thickness
gui.handles.cb_corr_thickness_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'checkbox',...
    'Position', [0.13 0.31 0.1 0.03],...
    'String', 'Correction ''t_eff'' (Mencik)',...
    'Value', 1,...
    'Visible', 'off',...
    'Callback', 'A_get_and_plot');

%% Parameter to plot
gui.handles.title_param2plotinxaxis_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.26 0.1 0.02],...
    'String', 'Parameter to plot ==> x axis',...
    'HorizontalAlignment', 'left');

gui.handles.value_param2plotinxaxis_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.02 0.24 0.1 0.02],...
    'String', 'Displ.|Cont.rad./Thick.|Displ./Thick.',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

gui.handles.title_param2plotinyaxis_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.13 0.26 0.1 0.02],...
    'String', 'Parameter to plot ==> y axis',...
    'HorizontalAlignment', 'left');

gui.handles.value_param2plotinyaxis_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'popup',...
    'Position', [0.13 0.24 0.1 0.02],...
    'String', 'Load|Stiffness|Red. Young''s modulus(film+sub)|Red. Young''s modulus(film)|Hardness',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

%% Options of the plot
gui.handles.cb_log_plot_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'checkbox',...
    'Position', [0.02 0.19 0.05 0.03],...
    'String', 'Log',...
    'Visible', 'on',...
    'Value', 0,...
    'Callback', 'A_get_and_plot');

gui.handles.cb_grid_plot_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'checkbox',...
    'Position', [0.07 0.19 0.05 0.03],...
    'String', 'Grid',...
    'Visible', 'on',...
    'Value', 1,...
    'Callback', 'A_get_and_plot');

gui.handles.cb_residual_plot_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'checkbox',...
    'Position', [0.13 0.19 0.1 0.03],...
    'String', 'Residuals',...
    'Visible', 'off',...
    'Value', 0,...
    'Callback', 'A_get_and_plot');

%% Plot configuration
gui.handles.AxisPlot_GUI = axes('Parent', gui.handles.MainWindows,...
    'Position', [0.325 0.06 0.66 0.82]);

set(gui.handles.MainWindows,'CurrentAxes', gui.handles.AxisPlot_GUI);

%% Get values from plot
gui.handles.cb_get_values_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'pushbutton',...
    'Position', [0.02 0.15 0.1 0.03],...
    'String', 'Get values x and y values',...
    'Visible', 'on',...
    'Callback', 'plot_get_values');

gui.handles.title_x_values_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.13 0.03 0.02],...
    'String', 'X value :',...
    'HorizontalAlignment', 'left',...
    'Visible', 'on');

gui.handles.value_x_values_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'edit',...
    'Position', [0.05 0.13 0.03 0.02],...
    'String', '',...
    'Visible', 'on');

gui.handles.title_y_values_prop_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'text',...
    'Position', [0.02 0.11 0.03 0.02],...
    'String', 'Y value :',...
    'HorizontalAlignment', 'left',...
    'Visible', 'on');

gui.handles.value_y_values_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'edit',...
    'Position', [0.05 0.11 0.03 0.02],...
    'String', '',...
    'Visible', 'on');

%% Save
gui.handles.save_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'pushbutton',...
    'Position', [0.13 0.05 0.1 0.05],...
    'String', 'SAVE',...
    'FontSize', 12,...
    'BackgroundColor', [0.745 0.745 0.745],...
    'Callback', 'export_data_to_YAML_file');

%% Quit
gui.handles.quit_GUI = uicontrol('Parent', gui.handles.MainWindows,...
    'Units', 'normalized',...
    'Style', 'pushbutton',...
    'Position', [0.02 0.05 0.1 0.05],...
    'String', 'QUIT',...
    'FontSize', 12,...
    'BackgroundColor', [0.745 0.745 0.745],...
    'Callback', 'close(gcf);clear all');

%% Set flags
gui.flag.flag = 0;
gui.flag.flag_data = 0;
guidata(gcf, gui);

%% Set properties of thin films
A_thin_films_properties_GUI;

%% Encapsulation of data into the GUI
gui = guidata(gcf); guidata(gcf, gui);

gui_handle = ishandle(gcf);

end

function path_management_GUI
%% This MATLAB file is used to set MATLAB search path
% http://www.mathworks.de/de/help/matlab/ref/addpath.html
commandwindow;
% http://stackoverflow.com/questions/2720140/find-location-of-current-m-file-in-matlab
S = dbstack('-completenames');
[folder, name, ext] = fileparts(S(1).file);
display (folder);
answer = input('Add the above folder with subfolders to the MATLAB search path ?\n ([y](default)/n/rm(remove))','s');
path_to_add = genpath(folder);
% workaround to not include the .svn subdirectory
% -> not needed any more, since moved to matlab subdirectory
% path_to_ignore = genpath(fullfile(folder,'.svn'));

if strcmpi(answer, 'y') || isempty(answer)
    display 'adding it';
    addpath(path_to_add);
    %rmpath(path_to_ignore)
    savepath;
    CHANGED = 1;
elseif strcmpi(answer, 'rm')
    display 'removing it';
    rmpath(path_to_add);
    CHANGED = 1;
else
    display 'doing nothing';
    CHANGED = 0;
end

%% Optionally display the matlab search path after modifications with the 'path' command
%path

if CHANGED
    if ispc
        userpath_ = regexp(userpath, ';', 'split');
    elseif ismac || isunix
        userpath_ = regexp(userpath, ':', 'split');
    end
    
    userpathdef = fullfile(userpath_{1}, 'pathdef.m');
    fprintf('Do you want to make the changes permanent ?');
    answer = input(sprintf('\n Write to %s ?y / n(default)', strrep(userpathdef, '\', '\\')), 's');
    
    if strcmpi(answer, 'y')
        fprintf('Writing to\n%s\n',userpathdef);
        savepath(userpathdef);
    end
    
end

end

Contact us