%==========================================================================
%==========================================================================
%
%                    /$$$$$$$$ /$$$$$$$   /$$$$$$  /$$$$$$$                 
%                   | $$_____/| $$__  $$ /$$__  $$| $$__  $$                
%                   | $$      | $$  \ $$| $$  \__/| $$  \ $$                
%                   | $$$$$   | $$$$$$$ |  $$$$$$ | $$  | $$                
%                   | $$__/   | $$__  $$ \____  $$| $$  | $$                
%                   | $$      | $$  \ $$ /$$  \ $$| $$  | $$                
%                   | $$$$$$$$| $$$$$$$/|  $$$$$$/| $$$$$$$/                
%                   |________/|_______/  \______/ |_______/                 
%                                                                           
%                                                                           
%                                                                           
%                                                    /$$                    
%                                                   |__/                    
%  /$$$$$$  /$$   /$$  /$$$$$$   /$$$$$$   /$$$$$$$ /$$  /$$$$$$$  /$$$$$$ 
% /$$__  $$|  $$ /$$/ /$$__  $$ /$$__  $$ /$$_____/| $$ /$$_____/ /$$__  $$
%| $$$$$$$$ \  $$$$/ | $$$$$$$$| $$  \__/| $$      | $$|  $$$$$$ | $$$$$$$$
%| $$_____/  >$$  $$ | $$_____/| $$      | $$      | $$ \____  $$| $$_____/
%|  $$$$$$$ /$$/\  $$|  $$$$$$$| $$      |  $$$$$$$| $$ /$$$$$$$/|  $$$$$$$
% \_______/|__/  \__/ \_______/|__/       \_______/|__/|_______/  \_______/
%                                                                           
%                                                                           
%                                                                           
%                     /$$$$$$   /$$$$$$   /$$$$$$    /$$                    
%                    /$$__  $$ /$$$_  $$ /$$__  $$ /$$$$                    
%                   |__/  \ $$| $$$$\ $$|__/  \ $$|_  $$                    
%                     /$$$$$$/| $$ $$ $$  /$$$$$$/  | $$                    
%                    /$$____/ | $$\ $$$$ /$$____/   | $$                    
%                   | $$      | $$ \ $$$| $$        | $$                    
%                   | $$$$$$$$|  $$$$$$/| $$$$$$$$ /$$$$$$                  
%                   |________/ \______/ |________/|______/                  
%                                                                           
%                                                                           
%                                                                          
%==========================================================================
%==========================================================================


%% import a simple ebsd dataset using the import_wizard

% data is from Giulia degli Alessandrini MSc thesis,
% "THE EITA SHEAR ZONE; Val Grosina (N Italy), 2013
% supervised by Neil Mancktelow, Eric Reusser
% data by Karsten Kunze, ETHZ

% use sample40.ang
import_wizard('EBSD')

%% we can put the output of import_wizard here





% % create an EBSD variable containing the data
% ebsd = EBSD.load(fname,CS,'interface','ang',...
%   'convertEuler2SpatialReferenceFrame','setting 2');

% note that when we use the import_wizard the "setting" option form OIM is 
% not set, meaning 'setting 1' by default (for historic reasons). However, 
% 'setting 2' seems to be the default in many cases as is also the case here.

%% 1) inspect the ebsd object


%% 2) plot the image quality with grey colormap and colorbar
% useful commands: plot, mtexColorMap, mtexColorbar


%% 2) select points with a certain property 
% a) plot the confidence index and plot only those points with a 
% confidence index > 0.1,



% b) assign the notIndexed phase to the points with ci <=0.1
% % useful info: ebsd.phaseMap ebsd.phase



%% 3) inspect the orientations - ipf plots
% a) make an ipf color mapping  with respect to x,y,z
% b) plot the corresponding (inverse) pole figures (with colored points)
% useful commands: ipfHSVKey




%% 4) inspect the orientations - pdf plots
% a) make a c-axis colorcoding and plot a c-axis mapping
% b) plot a polefigure for c,a,m,r,z with the same colorcoding
% useful commands: HSVDirectionKey





%% 5) colorize all points as a function of angular distance
% from one of the c-axis maxima
% useful commands: calcDensity, (calcPDF) max, angle





%% 6) make a colorcoding as a function of the angle between the
% a-axis and the xvector
% useful commands: ipfSpotKey, angle





%% 7) extract the ebsd data along a line
% plot the line in the map and plot the pole figure from the extracted data
% useful commands: spatialProfile




 
%% 8) Question session: What else would you want to do?





%% Bonus: remove single pixels which are nonIndexed and 
% completely surrounded by indexed pixels WITHOUT computing grains
% and fill them afterwards with the nearest neighbor interpolation
% useful commands: gridify, squareNeighbors2





%% save data for the next exercise or whenever you need it

