Skip to content
Snippets Groups Projects
Commit 19cfd39f authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

zUtil_DataStructures : commented GtPhase and removed gtCreateGtSample


Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@719 4c865b51-4357-4376-afb4-474e03ccb993
parent 0c82efdc
No related branches found
No related tags found
No related merge requests found
......@@ -531,7 +531,7 @@ classdef GtPhase < handle
merge.value2 = merge_value2;
merge.value = merge_value1 & merge_value2;
end
end % end checkOverlapConflict
end
end
end % end methods
end % end classdef
function sample = gtCreateGtSample()
% GTCREATEGTSAMPLE Loads the grain.mat file and generates the GtSample data
% structure
% sample = gtCreateGtSample()
% ---------------------------
parameters = [];
load('parameters.mat');
phaseNum = length(parameters.cryst);
samplefile = fullfile(parameters.acq.dir, '4_grains', 'sample.mat');
if exist(samplefile, 'file')
sample = GtSample.loadFromFile(samplefile);
else
sample = GtSample(phaseNum);
end
gtDBConnect();
difspot_num = mym(['SELECT MAX(difspotID) FROM ' parameters.acq.name 'difspot']); % number of difspots in database
spot2grain = cell(difspot_num, 1); % cell array linking difspots with grainids
spot2phase = cell(difspot_num, 1);
for phaseid = 1 : phaseNum
sprintf('Collecting information for phase %d', phaseid)
phaseName = parameters.cryst(phaseid).name;
indexterFile = fullfile(parameters.acq.dir, '4_grains', sprintf('phase_%02d', phaseid), 'index.mat');
grain = [];
load(indexterFile,'grain');
% Preallocate the space for the grains
grainsNum = length(grain);
phase = GtPhase(phaseName, grainsNum);
phaseDir = sprintf('phase_%02d', phaseid);
fprintf('Phase %02d: ', phaseid);
%% Check if we have already reconstructed volumes or not
grainFile = sprintf('grain_%04d.mat', 1);
grainPath = fullfile('4_grains', phaseDir, grainFile);
grainInfo = load(grainPath);
if all(isfield(grainInfo,{'vol', 'segbb', 'threshold'}))
variables = {'shift', 'vol', 'segbb', 'selected', 'threshold', 'completeness', 'difspotID'};
if ~isempty(grainInfo.vol)
reconstructed = 1;
else
reconstructed = 0;
end
else
variables = {'shift', 'selected', 'completeness', 'difspotID'};
reconstructed = 0;
end
for grainid = 1 : grainsNum
fprintf('%04d/%04d', grainid, grainsNum);
grainFile = sprintf('grain_%04d.mat', grainid);
grainPath = fullfile('4_grains', phaseDir, grainFile);
grainInfo = load(grainPath, variables{:});
phase.setR_vector(grainid, grain{grainid}.R_vector);
phase.setCenter(grainid, grain{grainid}.center);
if reconstructed
phase.setBoundingBox(grainid, grainInfo.segbb);
phase.setThreshold(grainid, grainInfo.threshold);
end
selected = zeros(length(grainInfo.difspotID),1);
selected(grainInfo.selected) = 1;
phase.setSelectedDiffspots(grainid, selected);
phase.setCompleteness(grainid, grainInfo.completeness);
phase.setDifspotID(grainid, grainInfo.difspotID);
difspotID = grainInfo.difspotID;
for kk = 1 : length(grainInfo.selected)
if grainInfo.selected(kk)
spot2grain{difspotID(kk)} = [spot2grain{difspotID(kk)}, grainid];
spot2phase{difspotID(kk)} = [spot2phase{difspotID(kk)}, phaseid];
end
end
fprintf('\b\b\b\b\b\b\b\b\b');
end
sample.phases{phaseid} = phase;
fprintf('(%04d) Done.\n', grainsNum);
end
save(samplefile, 'sample', '-v7.3');
filename = fullfile(parameters.acq.dir,'4_grains','spot2grain.mat');
save(filename, 'spot2grain', 'spot2phase')
end % end of 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