diff --git a/zUtil_DataStructures/GtPhase.m b/zUtil_DataStructures/GtPhase.m index 6217a7cd8a48deba4567d5a001044555aa711a4f..90e47785b706d521fef3165e88cdb387cb1b6a13 100644 --- a/zUtil_DataStructures/GtPhase.m +++ b/zUtil_DataStructures/GtPhase.m @@ -8,6 +8,7 @@ classdef GtPhase < handle center = zeros(0, 3); % Center of mass of the grain R_vector = zeros(0, 3); % Orientation (in Rodrigues space) of the grain boundingBox = zeros(0, 6); % Bounding Box: [x y z lx ly lz] ? + volume = zeros(0, 1); % Volume of the segmented grain active = true; % Boolean that enables/disables the phase phaseName = ''; % Recognisable name for the phase volumeFile = ''; % Path of the mat file which contains the data. @@ -53,6 +54,7 @@ classdef GtPhase < handle obj.R_vector = zeros(number, 3); obj.boundingBox = zeros(number, 6); obj.bboxExtremes = zeros(number, 6); + obj.volume = zeros(number, 1); obj.orderedPositions = {}; obj.use_extended = false(number, 1); @@ -62,6 +64,21 @@ classdef GtPhase < handle cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1)); end + function dropGrain(obj) + obj.grains_number = obj.grains_number - 1; + + obj.selectedGrains = obj.selectedGrains(1 : end-1); + obj.completeness = obj.completeness(1 : end-1); + obj.center = obj.center(1 : end-1, :); + obj.R_vector = obj.R_vector(1: end-1, :); + obj.boundingBox = obj.boundingBox(1 : end-1, :); + obj.bboxExtremes = obj.bboxExtremes(1: end-1, :); + obj.orderedPositions = {}; + + obj.use_extended = obj.use_extended(1:end-1); + obj.extended_params = obj.extended_params(1:end-1); + end + function pushGrain(obj) % GTPHASE/PUSHGRAIN Adds a new empty grain at the end of the list obj.grains_number = obj.grains_number + 1; @@ -229,6 +246,13 @@ classdef GtPhase < handle bbox = obj.bboxExtremes(grainid, :); end + function volume = getGrainVolume(obj, grainid) + if ((~exist('grainid', 'var') || isempty(grainid))) + grainid = 1:obj.getNumberOfGrains(); + end + volume = prod(obj.boundingBox(grainid, 4:6),2); + end + function shift = getBoundingBoxShift(obj, grainid) if ((~exist('grainid', 'var') || isempty(grainid))) grainid = 1:obj.getNumberOfGrains(); @@ -258,6 +282,33 @@ classdef GtPhase < handle aclusters = obj.clusters([obj.clusters(:).active]); end + function setClusterActive(obj, clusterID, state) + obj.clusters(clusterID).active = state; + end + + function clusterIDs = getActiveClusterIDs(obj) + clusterIDs = find([obj.clusters.active]); + end + + function cluster_table = getClusterTable(obj) + active_clusters = obj.getActiveClusterIDs; + grainIDs = []; + clusterIDs = []; + for ii = 1:numel(active_clusters) + grainIDs = [grainIDs, obj.clusters(active_clusters(ii)).included_ids]; + clusterIDs = [clusterIDs, repmat(active_clusters(ii), 1, numel(obj.clusters(active_clusters(ii)).included_ids))]; + end + cluster_table = cat(1,grainIDs, clusterIDs); + end + + function clusterID = getClusterID(obj, grainID) + cluster_table = obj.getClusterTable(); + if ~isempty(cluster_table) + clusterID = cluster_table(2, find(cluster_table(1, :) == grainID)); + else + clusterID = []; + end + end % grains fields % function ids = getMergeIDs(obj, grainid) % ids = obj.grains{grainid}.mergeIDs; diff --git a/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m b/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m index f089bd7e481656d9222899bdd66d9fc05729a5ae..7269b3cbb4c90f7815cd7c50726e0fcbc3bded40 100644 --- a/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m +++ b/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m @@ -526,12 +526,19 @@ classdef Gt6DReconstructionAlgorithmFactory < handle offsets = {}; end + psf = {}; if (isfield(bl, 'psf')) - psf = arrayfun(@(x){ permute(x.psf, [1 3 2]) }, bl); + if ~isempty(bl.psf) + psf = arrayfun(@(x){ permute(x.psf, [1 3 2]) }, bl); + end elseif (isfield(proj, 'psf')) - psf = { permute(proj.psf, [1 3 2]) }; - else - psf = {}; + if ~isempty(proj.psf) + psf = { permute(proj.psf, [1 3 2]) }; + end + elseif (isfield(self.parameters.rec.grains.options, 'psf')) + if ~isempty(self.parameters.rec.grains.options.psf) + psf = { permute(self.parameters.rec.grains.options.psf, [1 3 2]) }; + end end algo_params = struct( ... diff --git a/zUtil_Deformation/gt6DCreateProjDataFromExtendedGrain.m b/zUtil_Deformation/gt6DCreateProjDataFromExtendedGrain.m index d9d7cd123e2f48d310071b86651bb742fb89749d..f1a5e3b40f9a2ce7c834a7e5b09b47353efcd178 100644 --- a/zUtil_Deformation/gt6DCreateProjDataFromExtendedGrain.m +++ b/zUtil_Deformation/gt6DCreateProjDataFromExtendedGrain.m @@ -19,6 +19,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr 'ospace_lims', [], ... 'include_all', false, ... 'save', false, ... + 'use_extended', true, ... 'psf', []); conf = parse_pv_pairs(conf, varargin); @@ -316,6 +317,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr sample = GtSample.loadFromFile(); sample.phases{phase_id}.extended_params(gr.id) = ... GtPhase.makeExtendedField(estim_space_bbox_pix, estim_orient_bbox); + sample.phases{phase_id}.setUseExtended(gr.id, conf.use_extended); sample.saveToFile(); fprintf('\b\b: Done.\n') end diff --git a/zUtil_Deformation/gt6DCreateProjDataFromGrainCluster.m b/zUtil_Deformation/gt6DCreateProjDataFromGrainCluster.m index a552ea9eb84d4e298f4cfc834c74cdb0e310122d..0be03f8cf83af352fb4e6f8424e20ab3f29dbea0 100644 --- a/zUtil_Deformation/gt6DCreateProjDataFromGrainCluster.m +++ b/zUtil_Deformation/gt6DCreateProjDataFromGrainCluster.m @@ -15,7 +15,9 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr 'min_eta', 15, ... 'det_index', 1, ... 'ospace_oversize', 1.1, ... - 'save', false ); + 'save', true, ... + 'cluster_type', 0, ... + 'active', true); conf = parse_pv_pairs(conf, varargin); num_grains = numel(grs_list); @@ -298,7 +300,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr fprintf('Saving to sample.mat..') sample = GtSample.loadFromFile(); cl_info = GtPhase.makeCluster(grs_list, refor.R_vector, ... - estim_space_bbox_pix, estim_orient_bbox); + estim_space_bbox_pix, estim_orient_bbox, conf.cluster_type, conf.active); sample.phases{phase_id}.setClusterInfo(grs_list, cl_info); sample.saveToFile(); fprintf('\b\b: Done.\n')