From d4c2e307f0dd3ad05b9aeaeafb3f815ad9944c19 Mon Sep 17 00:00:00 2001 From: Lorenzo Valzania <valzania@rnice7-0201.esrf.fr> Date: Thu, 5 Feb 2015 15:24:12 +0100 Subject: [PATCH] GtSample/GtPhase: fixed a few bugs introduced by removing the GtGrain class Signed-off-by: Lorenzo Valzania <valzania@rnice7-0201.esrf.fr> --- 4_grains/GtThreshold.m | 7 +++++-- zUtil_DataStructures/GtPhase.m | 24 +++++++----------------- zUtil_TomoUtils/GtGrainsManager.m | 2 +- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/4_grains/GtThreshold.m b/4_grains/GtThreshold.m index 00d641b1..8922ad43 100644 --- a/4_grains/GtThreshold.m +++ b/4_grains/GtThreshold.m @@ -100,7 +100,7 @@ classdef GtThreshold < handle gauge.incrementAndDisplay(); try - grain = obj.loadGrain(phaseID, grainID); + grain = obj.loadGrain(phaseID, grainID, sample); % Actually threshold now! if (obj.checkIsIterative()) @@ -144,8 +144,11 @@ classdef GtThreshold < handle % GTTHRESHOLD/singleGrainThresholdInFile % grain = singleGrainThresholdInFile(obj, phaseID, grainID, threshold, center) + samplefile = fullfile(obj.param.acq.dir, '4_grains', 'sample.mat'); + sample = GtSample.loadFromFile(samplefile); + fprintf('Segmenting Grain %d, from phase %d.. ', grainID, phaseID); - grain = obj.loadGrain(phaseID, grainID); + grain = obj.loadGrain(phaseID, grainID, sample); if (exist('center', 'var')) do_morpho = true; diff --git a/zUtil_DataStructures/GtPhase.m b/zUtil_DataStructures/GtPhase.m index 929e84c3..8d8f07d2 100644 --- a/zUtil_DataStructures/GtPhase.m +++ b/zUtil_DataStructures/GtPhase.m @@ -47,10 +47,6 @@ classdef GtPhase < handle % grains obj.grains_number = number; - obj.grains = cell(number,1); - for ii = 1:number - obj.grains{ii} = GtGrain(); - end obj.selectedGrains = true(number, 1); obj.completeness = ones(number, 1); obj.center = zeros(number, 3); @@ -70,7 +66,6 @@ classdef GtPhase < handle % GTPHASE/PUSHGRAIN Adds a new empty grain at the end of the list obj.grains_number = obj.grains_number + 1; - obj.grains{end+1} = GtGrain(); obj.selectedGrains = [obj.selectedGrains; true]; obj.completeness = [obj.completeness; 1]; obj.center = [obj.center; 0 0 0]; @@ -90,7 +85,6 @@ classdef GtPhase < handle copy.active = obj.active; copy.volumeFile = obj.volumeFile; - copy.grains = obj.grains; copy.selectedGrains = obj.selectedGrains; copy.completeness = obj.completeness; copy.center = obj.center; @@ -135,9 +129,9 @@ classdef GtPhase < handle end % grains fields - function setMergeIDs(obj, grainid, ids) - obj.grains{grainid}.mergeIDs = ids; - end +% function setMergeIDs(obj, grainid, ids) +% obj.grains{grainid}.mergeIDs = ids; +% end function setUseExtended(obj, grainid, use_ext) obj.use_extended(grainid, 1) = use_ext; @@ -197,13 +191,9 @@ classdef GtPhase < handle end % grains fields - function ids = getMergeIDs(obj, grainid) - ids = obj.grains{grainid}.mergeIDs; - end - - function grain = getGrain(obj, grainid) - grain = obj.grains{grainid}; - end +% function ids = getMergeIDs(obj, grainid) +% ids = obj.grains{grainid}.mergeIDs; +% end function grainIDs = getGrainsWithCompletenessLessThan(obj, value) % GTPHASE/GETGRAINSWITHCOMPLETENESSLESSTHAN Gets grains with @@ -251,7 +241,7 @@ classdef GtPhase < handle if (~exist('oversize', 'var')) oversize = 1; end - numGrains = length(obj.grains); + numGrains = obj.getNumberOfGrains(); replOnes = ones(numGrains, 1); halfLengths = obj.boundingBox(:, 4:6) / 2; diff --git a/zUtil_TomoUtils/GtGrainsManager.m b/zUtil_TomoUtils/GtGrainsManager.m index 3fee2732..15de519f 100644 --- a/zUtil_TomoUtils/GtGrainsManager.m +++ b/zUtil_TomoUtils/GtGrainsManager.m @@ -1712,7 +1712,7 @@ classdef GtGrainsManager < GtVolView filePath = fullfile(obj.dataDir, '4_grains', ... sprintf('phase_%02d', phaseID), 'grain_*.mat'); fileInfo = dir(filePath); - numGrains = length(phase.grains); + numGrains = phase.getNumberOfGrains(); if (length(fileInfo) < numGrains) upToDate = false; return -- GitLab