Skip to content
Snippets Groups Projects
Commit ef9c4bd3 authored by Wolfgang Ludwig's avatar Wolfgang Ludwig
Browse files

some changes to simplify cluster & extended reconstructions on OAR

parent 4a5e9a45
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ classdef GtPhase < handle ...@@ -8,6 +8,7 @@ classdef GtPhase < handle
center = zeros(0, 3); % Center of mass of the grain center = zeros(0, 3); % Center of mass of the grain
R_vector = zeros(0, 3); % Orientation (in Rodrigues space) 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] ? 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 active = true; % Boolean that enables/disables the phase
phaseName = ''; % Recognisable name for the phase phaseName = ''; % Recognisable name for the phase
volumeFile = ''; % Path of the mat file which contains the data. volumeFile = ''; % Path of the mat file which contains the data.
...@@ -53,6 +54,7 @@ classdef GtPhase < handle ...@@ -53,6 +54,7 @@ classdef GtPhase < handle
obj.R_vector = zeros(number, 3); obj.R_vector = zeros(number, 3);
obj.boundingBox = zeros(number, 6); obj.boundingBox = zeros(number, 6);
obj.bboxExtremes = zeros(number, 6); obj.bboxExtremes = zeros(number, 6);
obj.volume = zeros(number, 1);
obj.orderedPositions = {}; obj.orderedPositions = {};
obj.use_extended = false(number, 1); obj.use_extended = false(number, 1);
...@@ -62,6 +64,21 @@ classdef GtPhase < handle ...@@ -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)); cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1), cell(0, 1));
end 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) function pushGrain(obj)
% GTPHASE/PUSHGRAIN Adds a new empty grain at the end of the list % GTPHASE/PUSHGRAIN Adds a new empty grain at the end of the list
obj.grains_number = obj.grains_number + 1; obj.grains_number = obj.grains_number + 1;
...@@ -229,6 +246,13 @@ classdef GtPhase < handle ...@@ -229,6 +246,13 @@ classdef GtPhase < handle
bbox = obj.bboxExtremes(grainid, :); bbox = obj.bboxExtremes(grainid, :);
end 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) function shift = getBoundingBoxShift(obj, grainid)
if ((~exist('grainid', 'var') || isempty(grainid))) if ((~exist('grainid', 'var') || isempty(grainid)))
grainid = 1:obj.getNumberOfGrains(); grainid = 1:obj.getNumberOfGrains();
...@@ -258,6 +282,33 @@ classdef GtPhase < handle ...@@ -258,6 +282,33 @@ classdef GtPhase < handle
aclusters = obj.clusters([obj.clusters(:).active]); aclusters = obj.clusters([obj.clusters(:).active]);
end 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 % grains fields
% function ids = getMergeIDs(obj, grainid) % function ids = getMergeIDs(obj, grainid)
% ids = obj.grains{grainid}.mergeIDs; % ids = obj.grains{grainid}.mergeIDs;
......
...@@ -526,12 +526,19 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -526,12 +526,19 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
offsets = {}; offsets = {};
end end
psf = {};
if (isfield(bl, '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')) elseif (isfield(proj, 'psf'))
psf = { permute(proj.psf, [1 3 2]) }; if ~isempty(proj.psf)
else psf = { permute(proj.psf, [1 3 2]) };
psf = {}; 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 end
algo_params = struct( ... algo_params = struct( ...
......
...@@ -19,6 +19,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -19,6 +19,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
'ospace_lims', [], ... 'ospace_lims', [], ...
'include_all', false, ... 'include_all', false, ...
'save', false, ... 'save', false, ...
'use_extended', true, ...
'psf', []); 'psf', []);
conf = parse_pv_pairs(conf, varargin); conf = parse_pv_pairs(conf, varargin);
...@@ -316,6 +317,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -316,6 +317,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
sample = GtSample.loadFromFile(); sample = GtSample.loadFromFile();
sample.phases{phase_id}.extended_params(gr.id) = ... sample.phases{phase_id}.extended_params(gr.id) = ...
GtPhase.makeExtendedField(estim_space_bbox_pix, estim_orient_bbox); GtPhase.makeExtendedField(estim_space_bbox_pix, estim_orient_bbox);
sample.phases{phase_id}.setUseExtended(gr.id, conf.use_extended);
sample.saveToFile(); sample.saveToFile();
fprintf('\b\b: Done.\n') fprintf('\b\b: Done.\n')
end end
......
...@@ -15,7 +15,9 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -15,7 +15,9 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
'min_eta', 15, ... 'min_eta', 15, ...
'det_index', 1, ... 'det_index', 1, ...
'ospace_oversize', 1.1, ... 'ospace_oversize', 1.1, ...
'save', false ); 'save', true, ...
'cluster_type', 0, ...
'active', true);
conf = parse_pv_pairs(conf, varargin); conf = parse_pv_pairs(conf, varargin);
num_grains = numel(grs_list); num_grains = numel(grs_list);
...@@ -298,7 +300,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -298,7 +300,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
fprintf('Saving to sample.mat..') fprintf('Saving to sample.mat..')
sample = GtSample.loadFromFile(); sample = GtSample.loadFromFile();
cl_info = GtPhase.makeCluster(grs_list, refor.R_vector, ... 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.phases{phase_id}.setClusterInfo(grs_list, cl_info);
sample.saveToFile(); sample.saveToFile();
fprintf('\b\b: Done.\n') fprintf('\b\b: Done.\n')
......
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