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

Possible bug when selecting grains by their ID #1681

Closed mfuhr-mpg closed 1 year ago

mfuhr-mpg commented 1 year ago

What do you want to do? I'm trying to select an individual grain using grains.id.

What data do you have? I'm working on orientation data acquired using EBSD on a tungsten sample.

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

%load orientation data
ebsd = EBSD.load([pathname '\' filename],CS,'interface','ctf','convertEuler2SpatialReferenceFrame');

%calculate grains
[grains,ebsd.grainId,~] = calcGrains(ebsd('indexed'),'angle',2*degree);

% neglect grains with an area less than three pixels
grains(grains.grainSize<=2) = [];

for t = 1:numel(grains.id)
    % define, which grain shall be evaluated
    g  = grains(grains.id==grains.id(t));

    % ... some evaluation %
end

What result do you get None, the script stops at specific grains and the error message shown below is printed. It should however be noted that the majority of grains are evaluated without any issue.

What result do you expect The code should select the grain with the respective grainId and make it analysable.

Error Message

Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side.

Error in grain2d/subSet (line 68)
  inverseorder(ind2) = ind1;

Error in grain2d/subsref (line 65)
  grains = subSet(grains,ind);

What MTEX version do you use? I use MTEX version 5.8.1

kilir commented 1 year ago

Hi, since you delete grains, the index and the id may not coincide anymore. I think you could do g = grains('id',grains.id(t)); Cheers, Rüdiger

mfuhr-mpg commented 1 year ago

That resolved the issue, thanks!