Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (66 sloc) 2.59 KB
% Copyright 2013 Max-Planck-Institut für Eisenforschung GmbH
function ebsd = mtex_getEBSDdata
%% Import data with MTEX toolbox
% See in http://mtex-toolbox.github.io/
% authors: d.mercier@mpie.de / c.zambaldi@mpie.de
%% File to load
listEBSDFileType = listEBSDFile;
[fname,pname] = uigetfile(listEBSDFileType);
if isequal(fname,0)
disp('User selected Cancel');
p = 0;
else
disp(['User selected ', fullfile(pname,fname)]);
p = 1;
end
if p
[filepath,fnameNoext,ext] = fileparts(fname);
ext(1)=''; % Remove the dot for loadEBSD MTEX function
%% Select CS
warning('If your .cif file is missing, find it on the web or write it by yourself, then save it in the dedicated folder in the MTEX repository.');
listCS = listCIFFile;
[indCS,tf] = listdlg('ListString',listCS,'SelectionMode','single');
CS = loadCIF(char(listCS(indCS)));
%% Set coordinate system
list_coordsys = listCoordSys;
[CoordSysVal,tf] = listdlg('ListString',list_coordsys,'SelectionMode','single');
if CoordSysVal == 1
xAxisDirection = 'east'; zAxisDirection = 'outOfPlane';
elseif CoordSysVal == 2
xAxisDirection = 'north'; zAxisDirection = 'outOfPlane';
elseif CoordSysVal == 3
xAxisDirection = 'west'; zAxisDirection = 'outOfPlane';
elseif CoordSysVal == 4
xAxisDirection = 'south'; zAxisDirection = 'outOfPlane';
elseif CoordSysVal == 5
xAxisDirection = 'east'; zAxisDirection = 'intoPlane';
elseif CoordSysVal == 6
xAxisDirection = 'north'; zAxisDirection = 'intoPlane';
elseif CoordSysVal == 7
xAxisDirection = 'west'; zAxisDirection = 'intoPlane';
elseif CoordSysVal == 8
xAxisDirection = 'south'; zAxisDirection = 'intoPlane';
end
% plotting convention
setMTEXpref('xAxisDirection',xAxisDirection);
setMTEXpref('zAxisDirection',zAxisDirection);
%% Set Reference Frame
specimenRefFrame = questdlg('Which specimen reference frame?', ...
'Specimen reference frame - Use CRC interface flag', ...
'convertSpatial2EulerReferenceFrame',...
'convertEuler2SpatialReferenceFrame','convertEuler2SpatialReferenceFrame');
%% Import the Data using MTEX wizard
dname = [pname fname];
% create an EBSD variable containing the data
ebsd = loadEBSD(dname,CS,'interface',ext,specimenRefFrame);
else
ebsd = '';
end
%% Using import wizard (alternative loading solution, but bug for .crc file)
% try
% import_wizard('EBSD');
% catch err
% commandwindow;
% display(err.message);
% end
% uiwait(gcf)