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
281 stars 185 forks source link

error in Variant Graph Clustering #1565

Closed Tijmenvermeij closed 1 year ago

Tijmenvermeij commented 1 year ago

I have some Ferrite/Martensite data on which I want to apply the variant graph method for PAG reconstruction. I've done this successfully for other datasets with Ferrite/Martensite, but here it goes wrong with clustering. I suspect it is because of martensite grains with only 1 neighbour, but I'm not sure.

What do you want to do? PAG reconstruction using variant graph method

What data do you have? Ferrite/Martensite EBSD map .mat file: https://www.dropbox.com/s/x2pmgul6w4a49am/variantGraphError.mat?dl=1

What code do you use?


%% Preparing for PAG Reconstruction
% misori angle grain reconstruction
misOri = 5;

% remove small grains
small_grains = 4; 

% perform a new grain reconstruction 
[grains,ebsd('indexed').grainId] = calcGrains(ebsd('indexed'),'angle',misOri*degree);
ebsd(grains(grains.grainSize < small_grains)) = [];
[grains,ebsd('indexed').grainId] = calcGrains(ebsd('indexed'),'angle',misOri*degree);

figure;
plot(grains('martensite'),grains('martensite').meanOrientation)  
hold on
plot(grains('martensite').boundary,'linewidth',1)

%% Setting up the PAG Reconstruction 
job = parentGrainReconstructor(ebsd,grains);
job.csChild = ebsd.CSList{3};
job.csParent = ebsd.CSList{4};

% Initial Guess for the OR
job.p2c = orientation.KurdjumovSachs(job.csParent, job.csChild);

% Optimizing the parent child orientation relationship
job.calcParent2Child

%% Graph based parent grain reconstruction
thresh = 2.5*degree;
tol = 2.5*degree;

job.calcVariantGraph('threshold',thresh,'tolerance',tol);   % Default: 2.5*degree and 2.5*degree)

job.calcVariantGraph('threshold',thresh,'tolerance',tol,'mergeSimilar');   

% job.clusterVariantGraph
job.clusterVariantGraph('inflationPower',1.1)

job.calcVariantGraph('threshold',thresh,'tolerance',tol)

job.clusterVariantGraph('includeSimilar','inflationPower',1.1)

figure
plot(job.grains,job.votes.prob(:,1))
mtexColorbar

What result do you get

What result do you expect

Error Message

Error using repelem
In repelem(v, N), N must be a scalar or a vector of length equal to v.

Error in parentGrainReconstructor/clusterVariantGraph/normalize (line 194)
    s = repelem(s,numV * job.isChild + job.isParent);

Error in parentGrainReconstructor/clusterVariantGraph (line 75)
normalize

Error in variantGraphErrors (line 39)
job.clusterVariantGraph('inflationPower',1.1)

What MTEX version do you use? 5.8.0

ralfHielscher commented 1 year ago

Hi Tijmen,

is there any reason you call calcVariantGraph twice? The usual route

job.calcVariantGraph('threshold',thresh,'tolerance',tol);   % Default: 2.5*degree and 2.5*degree)
job.clusterVariantGraph('inflationPower',1.1)
job.calcParentFromVote

seems to work.

Raf.

Tijmenvermeij commented 1 year ago

Hi Ralf,

Hmm. I think it may have ended up there twice by copying directly from the documentation, where a two-step process is suggested for large maps. The two-step process should however not include running calcVariantGraph twice, without performing clustering in between. I guess copying everything without reading a bit more carefully is tricky... :)

Thanks a lot! Tijmen