% Tuomo Nyyssönen & Matti Isakov 2015
% Parent austenite grain (PAG) reconstruction 1/3
% Script to import EBSD data for OR detection & parent austenite reconstruction. To be used with MTEX.

%% Import Script for EBSD Data

clear all
close all

%% Specify Crystal and Specimen Symmetries

% crystal symmetry
CS = {... 
  'notIndexed',...
  crystalSymmetry('m-3m', [2.866 2.866 2.866], 'mineral', 'Iron bcc (old)', 'color', 'light blue'),...
  crystalSymmetry('m-3m', [3.6599 3.6599 3.6599], 'mineral', 'Iron fcc', 'color', 'light green')};

% plotting convention
setMTEXpref('xAxisDirection','west');
setMTEXpref('zAxisDirection','outofPlane');

%% Input script parameters

min_bound = 3*degree; % Minimum angular deviation between grains

%% Specify File Names

% which files to be imported
fname = ['demo_martensite.cpr'];

%% Import the Data

% create an EBSD variable containing the data
ebsd = loadEBSD(fname,CS,'interface','crc',...
  'convertEuler2SpatialReferenceFrame');

region = [70 45 70 70];
ebsd = ebsd(inpolygon(ebsd,region));
ebsd.id = 1:length(ebsd);

clearvars -except ebsd
