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

Different results in 5.11.2 than 5.10.X #2127

Closed zmichels closed 5 months ago

zmichels commented 5 months ago

What do you want to do? Compute an orientation dispersion analysis using code (from CVA toolbox I maintain) that worked in MTEX versions 4.X-5.10.X

What data do you have? mtexdata forsterite

What code do you use?

Code for Principal Geodesic Analysis (PGA) available here: https://github.com/zmichels/CVA

Please provide minimalist code with code in the following form


% load data
mtexdata forsterite

% grain reconstruction and filtering
[grains,ebsd.grainId,ebsd.mis2mean]  = calcGrains(ebsd('indexed'),'threshold',[1 10]*degree,'boundary','tight')
grains = grains(grains.grainSize>2);
ebsd = ebsd(grains)
[grains,ebsd.grainId,ebsd.mis2mean]  = calcGrains(ebsd('indexed'),'threshold',[1 10]*degree,'boundary','tight')

% Principal Geodesic Analysis of orientations
[gCVA, ~] = grainsCVA(grains, ebsd);

% plot the results
figure,
plot(gCVA.CVA,'antipodal','lower','smooth','halfwidth',10*degree)

What result do you get I get completely different results in 5.11.2 than any previous versions of MTEX

What result do you expect I expect the results to match those achieved with previous versions

What MTEX version do you use? 5.11.2

MTEX_forsterite_orientation_dispersion_PGA_5_11_2 MTEX_forsterite_orientation_dispersion_PGA_5_10_2

zmichels commented 5 months ago

Additional info: All mtex_settings for plotting conventions are set the same when running each version.

I'm not sure what changed since 5.10.2, and I am hoping I can figure that outin order to make any necessary modifications. Unless it is some bug. It seems like a "bug" in that identical code produces different results.

zmichels commented 5 months ago

Plotting all the eigenvectors of the grain-scale orientation dispersion using the different versions of MTEX...

5.10.2: forsterite_5_10_2_PGA

5.11.2 forsterite_5_11_2_PGA

zmichels commented 5 months ago

The following code produces a set of orientations dispersed about the Z-axis and computes a covariance matrix and associated tensor.

However, the results in 5.11.2 are different than previous versions.

%% setup
cs = loadCIF('olivin');
h = [Miller(1,0,0,'direction',cs),Miller(0,1,0,'direction',cs),Miller(0,0,1,'direction',cs)];

o = orientation('map',vector3d.X, vector3d.Z, cs);

%% dispersion range
dispAx = vector3d.Z;
numOrs = 1000;
maxAng = 60;
dispMin = 1;
dispMax = round((maxAng-dispMin).*rand + dispMin);
dispRange = (dispMax-dispMin).*rand(numOrs,1) + dispMin;

% noise to add
nzMin = 1;
nzMax = (dispMax/2-nzMin).*rand + .1;
nzRange = (nzMax-nzMin).*rand(numOrs,1) + nzMin;

r1 = rotation('axis',dispAx,'angle',dispRange*degree);
r2 = rotation('axis',vector3d.rand(numOrs),'angle',nzRange*degree);

ors = r2.*r1.*o;

dOrs = ors(:,1);

%% plot the model-dispersion of orientations
figure,
plotPDF(dOrs,h,'antipodal','lower','smooth','halfwidth',10*degree,'colorrange','equal')

%% principal geodesic analysis

% mean / center
oriRef = mean(dOrs);

% compute the projection of orientations onto the three dimensional
% tangential space centered about the mean
t = log(dOrs, oriRef,'left');

% covariance matrix as tensor
T = tensor(t*t,'rank',2);

%% plot the tensor
figure,
plot(T)
zmichels commented 5 months ago

The dispersed orientations: 5_10_2_orientations

5.10.2 dispersion tensor: 5_10_2_dispersion_tensor

Note that the maxima in the plot matches the Z-axis direction used for modeling the dispersion.

That is unlike the result from 5.11.2: 5_11_2_dispersion_tensor

zmichels commented 5 months ago

here is a link to the data I am using, generated by the code above.

It seems the result of variable 't' in 5.10.2 was a vector3d object, whereas in 5.11.2, the result is a Miller object

https://drive.google.com/drive/folders/1MidpkAAxBYl7r7-J_fdGHyrSbYHZScDe?usp=sharing

ralfHielscher commented 5 months ago

Hi Zach,

if you replace in

t = log(dOrs, oriRef,'left');

'left' by SO3TangentSpace.leftVector you should get the expected result.

I think we should make it possible to still use the old left syntax.

Ralf.

zmichels commented 5 months ago

@ralfHielscher Excellent! Thank you. Will this work with all current versions?

zmichels commented 5 months ago

@ralfHielscher This works great for 5.11.2, but it throws an error in 5.10.2

Is there a method to query which mtex version is being used, such that I can switch between sytaxes?

ralfHielscher commented 5 months ago

You can do

getMTEXpref('version')

Ralf.

zmichels commented 5 months ago

Hi Zach,

if you replace in

t = log(dOrs, oriRef,'left');

'left' by SO3TangentSpace.leftVector you should get the expected result.

I think we should make it possible to still use the old left syntax.

Ralf.

Hi @ralfHielscher, Do you think it will be possible if future releases to include support for the legacy 'left' syntax?