mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
292 stars 186 forks source link

EBSD.load unable to read .ang files on HEX grid data, only works for SQUARE grid data, due to use of gridify in loadEBSD.m function #2110

Closed StopkaKris closed 7 months ago

StopkaKris commented 7 months ago

Hello,

I am attempting to read in .ang files using MTEX and ran into the error EBSD format ‘ANG’ does not match the data file. I was able to trace down the issue to the loadEBSD_ang.m function, to the four lines of code below:

ebsd=ebsd.gridify;
ind_no = isnan(ebsd.rotations);
ebsd=EBSD(ebsd);
ebsd(ind_no(:)).phase=notIndexedID;

gridify creates a grid in ebsd.gridify. However, ebsd(ind_no(:)) then throws the Arrays have incompatible sizes for this operation, since the array sizes are not the same when these operations are performed on HEX grid data. The issue is not present when processing SQUARE grid data.

Data to replicate this error:

I downloaded a publically available .ang file from Dr. Gregory Rohrer's website, listed below. The data is under "EBSD data" labeled "These are the original .ang files. Download the data to your computer."

http://mimp.materials.cmu.edu/~gr20/Grain_Boundary_Data_Archive/Ni/Ni.html#EBSDdata

The .zip file contains 30 .ang files, the first of which is named "000_Mod_Mod.ang". To convert this HEX grid data set to a SQUARE data set, I used DREAM.3D version 6.5.171 and a single filter entitled "Convert Hexagonal Grid Data to Square Grid Data (TSL - .ang)." This filter simply interpolates the original data in the HEX grid format and saves it as a new file, in a SQUARE grid format.

The .zip file below contains the original HEX grid data set (saved as "0.ang") and the data converted to a SQUARE grid format (saved as "Sqr_0.ang"):

hex_and_square_EBSD_data.zip

Code to replicate this error:

This occurs in mtex-6.0.beta3 but I believe I have had similar problems in the past with other versions. The code will fail with fname = '0.ang'; and work with fname = 'Sqr_0.ang';.

%%
% Add path to mtex
addpath('C:\Users\stopk\Desktop\mtex-6.0.beta3');
startup_mtex

%%
clear variables; close all;

CS = {... 
  'notIndexed',...
  crystalSymmetry('m-3m', [3.6 3.6 3.6], 'mineral', 'Ni-superalloy', 'color', [0.53 0.81 0.98])};

% Define one of two file names
% fname = '0.ang';
fname = 'Sqr_0.ang';

% Read in the EBSD Data
ebsd = EBSD.load(fname,CS,'interface','ang',...
  'convertEuler2SpatialReferenceFrame', 'setting 2');

Error message:

Error using loadEBSD_ang
EBSD format 'ANG' does not match the data
 file: '0.ang'

Error in EBSD.load (line 86)
  ebsd{k} = feval(['loadEBSD_',char(interface)],...

Please let me know if I am overlooking an option in the EBSD.load command that should appropriately handle .ang files with data in the HEX grid format. Thank you in advance for your help.

Best regards, Krzysztof Stopka

ralfHielscher commented 7 months ago

Hi Krzysztof,

thank you for reporting. This bug has already been fixed in MTEX 5.11. It will also be fixed in the next prerelease of MTEX 6.0.

Ralf.

StopkaKris commented 7 months ago

Hi Ralf,

That is great news. I downloaded MTEX 5.11 and saw the change in the code, which I have summarized for other readers of this post. I just changed these lines in the loadEBSD_ang.m file and it works.

In loadEBSD_ang.m, replace:

ebsd=EBSD(ebsd);
ebsd(ind_no(:)).phase=notIndexedID;

with

ebsd(ind_no).phase=notIndexedID;

Best regards, Krzysztof Stopka