Closed AzdiarGazder closed 5 months ago
Hi Rüdiger,
Due to pre-existing dependencies, I have aimed to make minimal changes to the original "mean" scripts from which the median and mode scripts are derived. But thank you for pointing out the issue with the median and mode calculations for the orientation case. I made changes to both median and mode scripts within @quaternion and @orientation. They have been uploaded for you to review.
If we now run your script:
cs = crystalSymmetry('432');
o = orientation.byEuler([1 0 0 0; 0 1 0 0; 0 1 1 1]',cs);
angle(o,o.median)
The output is as follows:
o = orientation (432 → xyz)
size: 4 x 1
Bunge Euler angles in degree
phi1 Phi phi2
57.2958 0 0
130.08 44.9216 310.08
57.2958 0 0
57.2958 0 0
ans =
0.0000
0.8750
0.0000
0.0000
The median function in @quaternion has 2 options:
figure; plot(o), hold all, plot(o.median)
figure; plot(o), hold all, plot(o.median('noSymmetry'))
In this instance, the in-built returns a somewhat better "middle" value.
Similarly, the mode function in @quaternion also has 2 options:
figure; plot(o), hold all, plot(o.mode)
figure; plot(o), hold all, plot(o.mode('noSymmetry'))
In this instance, the custom script returns a somewhat better "most repeated" value.
Given the above, my solutions are not perfect. While doing this, I've also had a bit of an question I've asked myself - given that we are working with orientations, maybe it is not an arithmetic median that should be sought but a geometric median like the Weiszfeld algorithm? Here is an example on MATLAB file exchange.
I am now a fair bit confused! :) I would be very grateful for some help and clarity on the way forward in this regard.
Thank you for this! Looking forward to hearing from you.
Warm regards, Azdi
Hi @kilir,
Based on your feedback, I am currently re-working the median and mode calculations. However, this will take me some time to work out.
In the meantime, if the export_crc function gets the maintainers' green light, I'd be grateful if that part could be pulled. Following that, please close this pull request. I'll make another pull request for the median and mode aspects at a later date.
Thank you for this! :)
Warm regards, Azdi
Hi Azdi, I think a key issue with e.g. a spherical median or a median orientation is that those are not so easily defined. The geometric median you suggest assumes an euclidean space (hence might work on the embedding) but for something like orientation space, I think it's more tricky. For the S2 case, e.g. there's a suggstion for a spherical median ( Fisher, 1985) however just for special cases such as unimodal distributions, but nothing universal as far as I could find.
Cheers, Rüdiger
Hi Maintainers,
There are 2 pull requests here:
Pull request 1: This is based on MTEX issue number: https://github.com/mtex-toolbox/mtex/issues/265. Ralf subsequently designated this as a future "feature request". In addition to mean, I've added the calculations for median and mode for all MTEX classes and objects. Before merging, please do re-check it for completeness and errors. Fingers crossed, everything works ok! :)
Pull request 2: This increases the versatility of the export_crc fucntion. Users can now export_crc ebsd maps in .cpr and .crc format from any input map. In case of hexagonal grids, prior conversion of map data to square grids is required before invoking the function.
Warm regards, Azdi