% specify crystal and specimen symmetry
CS = crystalSymmetry('m-3m');
SS = specimenSymmetry('-1');% specify file name
FileName = '*.txt';% load EBSD data
setMTEXpref('xAxisDirection','North');
setMTEXpref('zAxisDirection','IntoPlane');ebsd = loadEBSD(FileName,CS,SS,'interface','generic',...
'ColumnNames', {'Phase' 'x' 'y' 'Euler 1' 'Euler 2' 'Euler 3' 'Mad'},...
'ignorePhase', 0, 'Bunge', 'Degree');
% restrict to region
region = [xmin ymin xmax-xmin ymax-ymin];
ebsd_region = ebsd(inpolygon(ebsd,region));
% perform grain reconstruction
grains = calcGrains(ebsd_region,'angle',(5*degree));
% remove all grains with less than 20 measurements
grains = grains(grainSize(grains) >= 20);% perform new grain reconstruction
grains_cleaned = calcGrains(grains,'angle',(5*degree));
ebsd_cleaned = ebsd(grains)
grains_cleaned = calcGrains(ebsd,'angle',(5*degree));
grains = grains(grainSize(grains) >= 20);
Error using subsind (line 56)
There is no grainId stored within your EBSD data. You should compute grains by the command
[grains,ebsd.grainId] = calcGrains(ebsd)
Error in EBSD/subsref (line 12)
ind = subsind(ebsd,s(1).subs);
Error in untitled (line 258)
ebsd_cleaned = ebsd(large_grains);
% specify crystal and specimen symmetry
CS = crystalSymmetry('m-3m');
SS = specimenSymmetry('-1');
% specify file name
FileName = '*.txt';
% load EBSD data
setMTEXpref('xAxisDirection','North');
setMTEXpref('zAxisDirection','IntoPlane');
ebsd = loadEBSD(FileName,CS,SS,'interface','generic',...
'ColumnNames', {'Phase' 'x' 'y' 'Euler 1' 'Euler 2' 'Euler 3' 'Mad'},...
'ignorePhase', 0, 'Bunge', 'Degree');
% restrict to region
region = [xmin ymin xmax-xmin ymax-ymin];
ebsd_region = ebsd(inpolygon(ebsd,region));
% perform grain reconstruction
grains = calcGrains(ebsd_region,'angle',(5*degree));
% remove all grains with less than 20 measurements
large_grains = grains(grains.grainSize >= 20);
% perform new grain reconstruction
ebsd_cleaned = ebsd(large_grains);
grains_cleaned = calcGrains(ebsd_cleaned,'angle',(5*degree));
%// perform grain reconstruction
[grains, ebsd_region.grainId] = calcGrains(ebsd_region,'angle',5*degree);
% remove all grains with less than 20
measurements
large_grains = grains(grains.grainSize >= 20);
%// perform new grain reconstruction
ebsd_cleaned = ebsd_region(large_grains);
[grains_cleaned, ebsd_cleaned.grainId] = calcGrains(ebsd_cleaned,'angle',5*degree);
% perform grain reconstruction
[grains,GrainsID] = calcGrains(ebsd_region,'angle',(5*degree));
% remove all grains with less than 20 measurements
large_grains = GrainsID(grains.grainSize >= 20);
% perform new grain reconstruction
ebsd_cleaned = ebsd(large_grains);
grains_cleaned = calcGrains(ebsd_cleaned,'angle',(5*degree));
It works, however the results are not so good, The ebsd data loaded seems incomplete, as the size of the file created is equal to the number of grains found by the condition: large_grains = GrainsID(grains.grainSize >= 20);
So, I also didn't achieve good results using this cleaning procedure.
[grains, ebsd.grainId] = calcGrains(ebsd,'angle',15*degree)
valid_grains = grains( grains.grainSize > 10);
ebsd_clean = ebsd(valid_grains);
[grains, grainIds] = calcGrains(ebsd,'angle',15*degree)[grains, ebsd.grainId] = calcGrains(ebsd,'angle',15*degree)
ebsd(grains(1))