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

Enable reconstruction of twinclusters on OAR, using gtSetupReconstruction

parent 17eccabd
No related branches found
No related tags found
No related merge requests found
function cluster = gtLoadCluster(phase_id, grain_ids, varargin)
function cluster = gtLoadCluster(phase_id, cl_or_gr_ids, varargin)
% GTLOADCLUSTER load the projection input of a grain cluster
% cl = function cluster = gtLoadCluster(phase_id, cl_or_gr_ids, varargin)
% INPUT:
% phaseID = <int> phase ID
% cl_or_gr_ids = <int> either the cluster_id (->sample) or
% list of grain_ids composing the
% cluster
%
% OPTIONAL INPUT (p/v pairs):
% fields = <string> only load specific fields from
% cluster structure ('ODF6D', 'SEG')
% parameters = <struct> for security (make sure to load from right directory)
%
conf = struct('fields', {{}}, 'parameters', {[]});
conf = parse_pv_pairs(conf, varargin);
......@@ -8,13 +21,19 @@ function cluster = gtLoadCluster(phase_id, grain_ids, varargin)
phase_dir = fullfile(conf.parameters.acq.dir, '4_grains', sprintf('phase_%02d', phase_id));
end
grain_ids_sorted = sort(grain_ids);
if (any(grain_ids_sorted ~= grain_ids))
warning('gtLoadCluster:wrong_argumet', ...
'Some grain IDs were no sorted: %s', sprintf(' %d', grain_ids));
if numel(cl_or_gr_ids) == 1 %if only one element we assume it refers to a cluster
sample = GtSample.loadFromFile;
grain_ids_sorted = sample.phases{phase_id}.clusters(cl_or_gr_ids).included_ids;
else
grain_ids_sorted = sort(cl_or_gr_ids);
if (any(grain_ids_sorted ~= cl_or_gr_ids))
warning('gtLoadCluster:wrong_argumet', ...
'Some grain IDs were no sorted: %s', sprintf(' %d', cl_or_gr_ids));
end
end
str_ids = sprintf('_%04d', grain_ids_sorted);
cluster_file = fullfile(phase_dir, sprintf('grain_cluster%s.mat', str_ids));
......
function cluster_rec = gtLoadClusterRec(phase_id, grain_ids, varargin)
function cluster_rec = gtLoadClusterRec(phase_id, cl_or_gr_ids, varargin)
% GTLOADCLUSTERREC load the 6D reconstruction output of a grain cluster
% cl = function cluster_rec = gtLoadClusterRec(phase_id, cl_or_gr_ids, varargin)
% INPUT:
% phaseID = <int> phase ID
% cl_or_gr_ids = <int> either the cluster_id (->sample) or
% list of grain_ids composing the
% cluster
%
% OPTIONAL INPUT (p/v pairs):
% fields = <string> only load specific fields from
% cluster structure ('ODF6D', 'SEG')
% parameters = <struct> for security (make sure to load from right directory)
%
conf = struct('fields', {{}}, 'parameters', {[]});
conf = parse_pv_pairs(conf, varargin);
......@@ -8,11 +22,15 @@ function cluster_rec = gtLoadClusterRec(phase_id, grain_ids, varargin)
phase_dir = fullfile(conf.parameters.acq.dir, '4_grains', sprintf('phase_%02d', phase_id));
end
grain_ids_sorted = sort(grain_ids);
if (any(grain_ids_sorted ~= grain_ids))
warning('gtLoadCluster:wrong_argumet', ...
'Some grain IDs were no sorted: %s', sprintf(' %d', grain_ids));
if numel(cl_or_gr_ids) == 1 %only one element - it refers to a cluster
sample = GtSample.loadFromFile;
grain_ids_sorted = sample.phases{phase_id}.clusters(cl_or_gr_ids).included_ids;
else
grain_ids_sorted = sort(cl_or_gr_ids);
if (any(grain_ids_sorted ~= cl_or_gr_ids))
warning('gtLoadCluster:wrong_argumet', ...
'Some grain IDs were no sorted: %s', sprintf(' %d', cl_or_gr_ids));
end
end
str_ids = sprintf('_%04d', grain_ids_sorted);
......
function gtReconstructGrainTwinCluster(grain_ids, phase_id, parameters, varargin)
function gtReconstructGrainTwinCluster(phase_id, cluster_id, workingdirectory, parameters, varargin)
% gtReconstructGrainOrientation 6D reconstructions on a GPU machine
% gtAstraReconstructGrain(grainIDs, phaseID, [parameters])
% gtReconstructGrainTwinCluster(phase_id, cluster_id, workingdirectory, parameters, varargin)
% -------------------------------------------------------
cd(workingdirectory);
if (isdeployed)
global GT_DB %#ok<NUSED,TLEV>
global GT_MATLAB_HOME %#ok<NUSED,TLEV>
load('workspaceGlobal.mat');
phase_id = str2double(phase_id);
cluster_id = str2double(cluster_id);
end
sample = GtSample.loadFromFile;
grain_ids = sample.phases{phase_id}.clusters(cluster_id).included_ids;
if (~exist('parameters', 'var') || isempty(parameters))
parameters = gtLoadParameters();
end
......@@ -150,4 +163,3 @@ function gtReconstructGrainTwinCluster(grain_ids, phase_id, parameters, varargin
save(grain_full_details_file, 'ODF6D', '-v7.3');
end
end
function gtSetupReconstruction(phaseID, list)
function gtSetupReconstruction(phaseID, varargin)
% GTSETUPRECONSTRUCTION Simple helper function to launch reconstruction and segmentation of
% absorption volume - as well as reconstruction and segmentation of grain volumes
%
% gtSetupReconstruction(phaseID, list)
% gtSetupReconstruction(phaseID, varargin)
% ------------------------------
%
% INPUT:
% phaseID = number of the phase <double> {1}
% list = vector of grainids, default value is {[1: num_grains]}
%
% OPTIONAL INPUT:
% grain_ids = vector of grain_ids, default value is {[1: num_grains]}
% cluster_ids = vector of cluster_ids, default value is {[1: num_clusters]}
% 'is_cluster
% Version 005 12-10-2016 by W. Ludwig
% Add possibility to launch grain-cluster reconstructions
% Version 004 25-05-2016 by W. Ludwig
% Add possibility to specify a list of grainids - which will be
% handled by OAR
......@@ -23,6 +28,12 @@ function gtSetupReconstruction(phaseID, list)
% Move gtModifyStructure to before the abs reconstruction is done.
GPU_OK = gtCheckGpu();
conf.grain_ids = [];
conf.cluster_ids = [];
if (~isempty(varargin))
conf = parse_pv_pairs(conf, varargin);
end
if (~GPU_OK)
disp('Not on a GPU machine, you won''t be able to reconstruct localy!');
......@@ -57,7 +68,7 @@ gtSaveParameters(parameters);
nof_phases = numel(parameters.cryst);
if (nof_phases > 1)
if (nof_phases > 1) && isempty(phaseID)
phaseID = inputwdefaultnumeric('Enter phaseID', num2str(1));
end
phaseID_str = sprintf('%02d', phaseID);
......@@ -128,16 +139,21 @@ else
end
end
% If input parameter list is empty, we will use all grains by default
first = 1;
last = sample.phases{phaseID}.getNumberOfGrains();
% If input parameter grain_ids is empty, we will use all grains by default
if (~exist('list', 'var') || isempty(list))
list = [first : last];
if ~isempty(varargin)
conf = parse_pv_pairs(conf, varargin);
end
if isempty(conf.grain_ids)
first = 1;
last = sample.phases{phaseID}.getNumberOfGrains();
list = [first : last];
end
check = inputwdefault('Launch reconstruction? [y/n]', 'y');
check = inputwdefault('Launch grain reconstruction? [y/n]', 'y');
rec_on_OAR = false;
if strcmpi(check, 'y')
if (GPU_OK)
......@@ -148,13 +164,35 @@ if strcmpi(check, 'y')
end
if (rec_on_OAR)
launch_on_OAR('gtReconstructGrains', first, last, phaseID_str, ...
parameters, 'njobs', 8, 'walltime', 3600 * 16, ...
'gpu', true, 'distribute', true, 'list', list);
parameters, 'njobs', 8, 'walltime', 3600 * 16, ...
'gpu', true, 'distribute', true, 'list', list);
else
gtReconstructGrains(first, last, parameters.acq.dir, phaseID, parameters, 'list', list);
end
end
if ~isempty(conf.cluster_ids)
list = conf.cluster_ids;
check = inputwdefault('Launch cluster reconstruction? [y/n]', 'y');
rec_on_OAR = false;
if strcmpi(check, 'y')
if (GPU_OK)
check2 = inputwdefault('Launch grain reconstruction via OAR? [y/n]', 'y');
rec_on_OAR = strcmpi(check2, 'y');
else
rec_on_OAR = true;
end
if (rec_on_OAR)
launch_on_OAR('gtReconstructGrainTwinClusters', first, last, phaseID_str, ...
parameters, 'njobs', 8, 'walltime', 3600 * 16, ...
'gpu', true, 'distribute', true, 'list', list);
else
gtReconstructGrainTwinClusters(first, last, parameters.acq.dir, phaseID, parameters, 'list', list);
end
end
end
if (~rec_on_OAR)
check = inputwdefault('Launch grain segmentation? [y/n]', 'y');
if strcmpi(check, 'y')
......
......@@ -47,6 +47,9 @@
<function name="gtReconstructGrains">
<path absolute="false">5_reconstruction/gtReconstructGrains.m</path>
</function>
<function name="gtReconstructGrainTwinClusters">
<path absolute="false">5_reconstruction/gtReconstructGrainTwinClusters.m</path>
</function>
<function name="gtForwardSimulate_v2">
<path absolute="false">zUtil_ForwardSim/gtForwardSimulate_v2.m</path>
</function>
......
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