From 32011bcfed0ebc50d9eaf16602bb2e22421eb4f6 Mon Sep 17 00:00:00 2001 From: Laura Nervo <lnervo@esrf.fr> Date: Mon, 3 Dec 2012 10:34:00 +0000 Subject: [PATCH] Conflicts analysis : bug fix and better commenting... ForwardSimulate_v2 : add ';' to end lines Signed-off-by: Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@938 4c865b51-4357-4376-afb4-474e03ccb993 --- 5_reconstruction/gtAnalyseGrainsConflicts.m | 31 ++++---- 5_reconstruction/gtForwardSimulate_v2.m | 2 +- gtGetSinglesValues.m | 28 ------- zUtil_Maths/gtGetSinglesValues.m | 87 +++++++++++++++++++++ 4 files changed, 104 insertions(+), 44 deletions(-) delete mode 100644 gtGetSinglesValues.m create mode 100644 zUtil_Maths/gtGetSinglesValues.m diff --git a/5_reconstruction/gtAnalyseGrainsConflicts.m b/5_reconstruction/gtAnalyseGrainsConflicts.m index 0bcee178..b4b33e4d 100644 --- a/5_reconstruction/gtAnalyseGrainsConflicts.m +++ b/5_reconstruction/gtAnalyseGrainsConflicts.m @@ -4,20 +4,21 @@ function grains_merge = gtAnalyseGrainsConflicts(analyse_flag, update_flag, solv % grains_merge = gtAnalyseGrainsConflicts(analyse_flag, update_flag, solve_flag, log_flag, save_flag, minnum, maxnum) % ------------------------------------------------------------------------------------------------------------------- % -% Reads ./parameters.mat +% Reads ./parameters.mat : cryst -> length(cryst) +% ./parameters.mat : acq : dir +% % ./4_grains/spot2grain.mat -% ./4_grains/phase_##/index.mat:grain % -% Saves ./4_grains/grains_merge.mat -% ./4_grains/conflicts.mat +% ./4_grains/phase_##/index.mat : grain -> length(grain) % -% conflicts.mat contains: grain_conflict = list of logical if difspot(i) -% is claimed by more than one grain -% <row vector num_phases x num_spots> -% phase_conflict = list of difspots in conflict between phases -% <row vector num_phases x spotids> -% phase = list of difspotIDs for each phase -% <cell num_phases x 1> +% Saves ./4_grains/grains_merge.mat (See output for details) +% ./4_grains/conflicts.mat : grain_conflict = list of logical if difspot(i) +% is claimed by more than one grain +% <row vector num_phases x num_spots> +% phase_conflict = list of difspots in conflict between phases +% <row vector num_phases x spotids> +% phase = list of difspotIDs for each phase +% <cell num_phases x 1> % % SUB-FUNCTIONS: %[sub]- sfCompareGrains @@ -55,10 +56,10 @@ function grains_merge = gtAnalyseGrainsConflicts(analyse_flag, update_flag, solv % .difspotID = vector of difspotID from Fsim <double> % % .conflicts{grainid} = GtConflict object array <cell numgrainx1> -% .difspots = [idconflict, [difspots]] <cell> -% .maxnum = logical -% .merge = [idconflict, [difspots]] if maxnum = true <cell> -% .allequals = logical +% .difspots = [idconflict, [difspots]] <cell> +% .maxnum = logical +% .merge = [idconflict, [difspots]] if maxnum = true <cell> +% .allequals = logical % % .hasConflicts(grainid) = boolean to say if grainid has conflicts <logical numgrainx1> % .nofConflicts(grainid) = number of conflicts <int numgrainx1> diff --git a/5_reconstruction/gtForwardSimulate_v2.m b/5_reconstruction/gtForwardSimulate_v2.m index 0d9dd982..3a357fd4 100644 --- a/5_reconstruction/gtForwardSimulate_v2.m +++ b/5_reconstruction/gtForwardSimulate_v2.m @@ -486,7 +486,7 @@ for n = first : last out.proj.num_rows = vsize; out.proj.num_cols = hsize; % We should in the future handle properly vertical detector (general geometry) - out.proj.vol_size_x = round(grainBBox(1) * fsim.oversizeVol) + out.proj.vol_size_x = round(grainBBox(1) * fsim.oversizeVol); out.proj.vol_size_y = round(grainBBox(1) * fsim.oversizeVol); out.proj.vol_size_z = round(grainBBox(2) * fsim.oversizeVol); out.proj.num_iter = parameters.rec.num_iter; diff --git a/gtGetSinglesValues.m b/gtGetSinglesValues.m deleted file mode 100644 index aaf7a9a3..00000000 --- a/gtGetSinglesValues.m +++ /dev/null @@ -1,28 +0,0 @@ -function [allvalues, ids] = gtGetSinglesValues(cellArray, selected) - -allvalues = []; -ids = []; -count = 0; - -if ~isempty(selected) - cellArray = arrayfun(@(num) cellArray{num}, selected, 'UniformOutput', false); -else - selected = 1:length(cellArray); -end - -for i = 1 : length(cellArray) - array = cellArray{i}; - if ~isempty(array) - for j = 1 : length(array) - current = array(j); - if isempty(current) - count = count + 1; - else - ids = [ids; selected(i)]; - allvalues = [allvalues; current]; - end - end - end -end - -end diff --git a/zUtil_Maths/gtGetSinglesValues.m b/zUtil_Maths/gtGetSinglesValues.m new file mode 100644 index 00000000..5dd64538 --- /dev/null +++ b/zUtil_Maths/gtGetSinglesValues.m @@ -0,0 +1,87 @@ +function [allvalues, ids] = gtGetSinglesValues(cellArray, selected) +% GTGETSINGLEVALUES Operates on cellArray to get values as column vector +% [allvalues, ids] = gtGetSinglesValues(cellArray, selected) +% ---------------------------------------------------------- +% +% The empty element are skipped. +% +% INPUT: +% cellArray = cell array as input <cell> +% selected = indexes to be taken into account <double> +% +% OUTPUT: +% allvalues = column vector as output +% ids = indexes as column vector <double> +% +% USAGE: cellArray = {1,2,3,4,5}; +% selected = [2 3]; +% [allvalues, ids] = gtGetSinglesValues(cellArray, selected); +% allvalues = +% 2 +% 3 +% ids = +% 2 +% 3 +% +% +% cellArray = {0,4,[],3,5}; (empty entry) +% selected = [2 3]; +% [allvalues, ids] = gtGetSinglesValues(cellArray, selected) +% allvalues = +% 4 +% ids = +% 2 +% +% +% cellArray = {[1 -1],[2 3 5],[]}; (empty entry and vector as +% element) +% selected = [2 3]; +% [allvalues, ids] = gtGetSinglesValues(cellArray, selected) +% allvalues = +% 2 +% 3 +% 5 +% ids = +% 2 +% 2 +% 2 +% +% +% confl = {{'2', '-1'},[2 3 5],[]}; (empty entry and vectors as +% element: includes strings) +% selected = [1 3]; +% [allvalues, ids] = gtGetSinglesValues(cellArray, selected) +% allvalues = +% '2' +% '-1' +% ids = +% 1 +% 1 +% +% +% Version 001 03-12-2012 by LNervo + + +allvalues = []; +ids = []; + +if ~isempty(selected) + cellArray = arrayfun(@(num) cellArray{num}, selected, 'UniformOutput', false); +else + selected = 1:length(cellArray); +end + +for ii = 1 : length(cellArray) + array = cellArray{ii}; + if ~isempty(array) + for jj = 1 : length(array) + current = array(jj); + if ~isempty(current) + ids = [ids; selected(ii)]; + allvalues = [allvalues; current]; + end + end + end +end + +end % end of function -- GitLab