Skip to content
Snippets Groups Projects
Commit a917ba8d authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Fixed a few bugs in GtGrainsManager

parent ffdf8e0e
No related branches found
No related tags found
No related merge requests found
...@@ -371,8 +371,12 @@ classdef GtGrainsManager < GtVolView ...@@ -371,8 +371,12 @@ classdef GtGrainsManager < GtVolView
bboxList = sample.phases{phaseID}.simpleSearchBBtouched(voxel); bboxList = sample.phases{phaseID}.simpleSearchBBtouched(voxel);
for jj = 1:length(bboxList) for jj = 1:length(bboxList)
grainID = bboxList(jj); grainID = bboxList(jj);
seg = obj.cache.get('grain', {phaseID, grainID}, 'seg'); try
if isempty(seg) gr_seg = obj.cache.get('grain_det', {phaseID, grainID}, 'SEG');
catch
gr_seg = obj.cache.get('grain', {phaseID, grainID}, {'seg'});
end
if (isempty(gr_seg.seg) || numel(gr_seg.seg) == 1)
fprintf('Segmentation volume for grain %d is empty. Please run Reconstruction and 3d Threshold again!\n', grainID) fprintf('Segmentation volume for grain %d is empty. Please run Reconstruction and 3d Threshold again!\n', grainID)
continue continue
end end
...@@ -999,8 +1003,12 @@ classdef GtGrainsManager < GtVolView ...@@ -999,8 +1003,12 @@ classdef GtGrainsManager < GtVolView
% %
% viewSegmentedGrain(obj, phaseID, grainID) % viewSegmentedGrain(obj, phaseID, grainID)
grainSeg = obj.cache.get('grain', {phaseID, grainID}, 'seg'); try
GtVolView(grainSeg); gr_seg = obj.cache.get('grain_det', {phaseID, grainID}, 'SEG');
catch
gr_seg = obj.cache.get('grain', {phaseID, grainID}, {'seg'});
end
GtVolView(gr_seg.seg);
end end
function displayForwardSim(obj, phaseID, grainID, varargin) function displayForwardSim(obj, phaseID, grainID, varargin)
...@@ -1329,7 +1337,11 @@ classdef GtGrainsManager < GtVolView ...@@ -1329,7 +1337,11 @@ classdef GtGrainsManager < GtVolView
% GTGRAINSMANAGER/GETCONTOUROFGRAIN Function that gets border of grains, % GTGRAINSMANAGER/GETCONTOUROFGRAIN Function that gets border of grains,
% when grain is not into assembled volume % when grain is not into assembled volume
sample = obj.getSample(); sample = obj.getSample();
vol = obj.cache.get('grain', {phaseID, grainID}, 'seg'); try
gr_seg = obj.cache.get('grain_det', {phaseID, grainID}, 'SEG');
catch
gr_seg = obj.cache.get('grain', {phaseID, grainID}, {'seg'});
end
bbox = sample.phases{phaseID}.getBoundingBox(grainID); bbox = sample.phases{phaseID}.getBoundingBox(grainID);
indx = obj.conf.slicendx - bbox(obj.conf.ortDim); indx = obj.conf.slicendx - bbox(obj.conf.ortDim);
...@@ -1337,15 +1349,15 @@ classdef GtGrainsManager < GtVolView ...@@ -1337,15 +1349,15 @@ classdef GtGrainsManager < GtVolView
switch (obj.conf.ortDim) switch (obj.conf.ortDim)
case 3 % equivalent to plane 'xy' or 'yx' case 3 % equivalent to plane 'xy' or 'yx'
slice = zeros(obj.conf.dim(1), obj.conf.dim(2)); slice = zeros(obj.conf.dim(1), obj.conf.dim(2));
sliceVol = vol(:, :, indx); sliceVol = gr_seg.seg(:, :, indx);
slice = gtPlaceSubVolume(slice, sliceVol, ([bbox(1) bbox(2) 1]-1)); slice = gtPlaceSubVolume(slice, sliceVol, ([bbox(1) bbox(2) 1]-1));
case 1 % equivalent to plane 'yz' or 'zy' case 1 % equivalent to plane 'yz' or 'zy'
slice = zeros(obj.conf.dim(2), obj.conf.dim(3)); slice = zeros(obj.conf.dim(2), obj.conf.dim(3));
sliceVol = squeeze(vol(indx, :, :)); sliceVol = squeeze(gr_seg.seg(indx, :, :));
slice = gtPlaceSubVolume(slice, sliceVol, ([1 bbox(2) bbox(3)]-1)); slice = gtPlaceSubVolume(slice, sliceVol, ([1 bbox(2) bbox(3)]-1));
case 2 % equivalent to plane 'zx' or 'xz' case 2 % equivalent to plane 'zx' or 'xz'
slice = zeros(obj.conf.dim(1), obj.conf.dim(3)); slice = zeros(obj.conf.dim(1), obj.conf.dim(3));
sliceVol = squeeze(vol(:, indx, :)); sliceVol = squeeze(gr_seg.seg(:, indx, :));
slice = gtPlaceSubVolume(slice, sliceVol, ([bbox(1) 1 bbox(3)]-1)); slice = gtPlaceSubVolume(slice, sliceVol, ([bbox(1) 1 bbox(3)]-1));
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment