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
278 stars 183 forks source link

concatenate grain2d subsets #1921

Closed vtvivian closed 11 months ago

vtvivian commented 1 year ago

Hi mtex team,

I think grain2d/subSet is producing some unexpected behaviour that errors when concatenating grain2d variables. These functions are quite deep inside mtex, so I didn't want to propose a change that fixes my code but accidentally breaks something else.

Thanks!

What do you want to do? Concatenate 2 grain2d datasets that were subsets of a

What code do you use? Please provide minimalist code with code in the following form


mtexdata testgrains

grainsS=grains(1:10);

size(grains) % ans =    40     1
size(grainsS) % ans =    10     1

size(grains.meanOrientation) % ans =    40     1
size(grainsS.meanOrientation) % ans =    1    10

% this causes quaternion/cat (which is called by grain2d/cat) to error
cat(1,grains,grainsS) % equivalent to [grains, grainsS] or [grains; grainsS]

What result do you get

the array grainsS.meanOrientation is permuted w.r.t the original data I think the the problem comes in line 44 of mtex\EBSDAnalysis\@grain2d

if ~islogical(ind)
  grains.prop.meanRotation = reshape(grains.prop.meanRotation, size(ind));
end

why do you need this step? grains is almost always a n*1 array?

What result do you expect

size(grains.meanOrientation)==size(grainsS.meanOrientation)

Error Message If you get an error message copy and paste it below

Error using cat
Dimensions of arrays being concatenated are not consistent.

Error in quaternion/cat (line 28)
q.a = cat(dim,qa{:});

Error in dynProp/cat (line 35)
        dp.prop.(fn{i}) = cat(dim,s.(fn{i}));

Error in grain2d/cat (line 16)
grains = cat@dynProp(1,varargin{:});

What MTEX version do you use? MTEX 5.12.0beta1

ralfHielscher commented 11 months ago

Hi Vivian,

thank you for reporting this issue. It is fixed in MTEX 5.10.2.

By the way, we also published MTEX 6.0.beta with includes pseudo 3d EBSD capabilities. Do you have by chance any EBSD from different sides of the same material, e.g., from the faces of a cube?

Ralf.

vtvivian commented 11 months ago

Thanks Ralf, I have some data from 2 faces (surface and cross-section) of 2 WC single crystals (zipped cpr/ctf files attached), but they are not from the same physical object (a FIB cross-section + lift-out happened in between), so you will need extra information to align the sample coordinates. How do you want me to give you this extra information?

2FaceEBSD_20230921.zip

Vivian