diff --git a/zUtil_ForwardSim/gtForwardSimulate_v2.m b/zUtil_ForwardSim/gtForwardSimulate_v2.m index f2226e331f6cf302490a2d51c8ddaecc47b1578c..6f30f93c0095123b19d222e3bba367ed7feabe7e 100644 --- a/zUtil_ForwardSim/gtForwardSimulate_v2.m +++ b/zUtil_ForwardSim/gtForwardSimulate_v2.m @@ -413,8 +413,9 @@ for n = first : last for ii_d = 1:num_dets fprintf(' + Detector: %d\n', conf.det_index(ii_d)) for ii_t = 1:numel(fp_twins) - fprintf(' %d) %d\n', ii_t, ... - numel(fp_twins(ii_t).proj(ii_d).included)); + fprintf(' %d) included: %d, auto-selected: %d\n', ii_t, ... + numel(fp_twins(ii_t).proj(ii_d).included), ... + numel(find(fp_twins(ii_t).proj(ii_d).selected)) ); end end fprintf(' - Assembling final data-structure..') @@ -706,6 +707,10 @@ function twin_vars = forward_simulate_twin(gr, gr_fwd_sim, gr_proj, conf, spotsC 'R_vector', twin_vars(ii_t).R_vector, 'center', gr.center); twin = gtCalculateGrain(twin, parameters, 'ref_omind', gr.allblobs.omind); + % Determining reflections that are shared with the twin and + % selected by the parent + refl_match = gt6DGetMatchingReflections(gr, twin, conf.twin_angular_toll_deg * 2); + twin.stat = gr.stat; twin.stat.bbxsstd = twin.stat.bbxsstd * 0.1; twin.stat.bbysstd = twin.stat.bbysstd * 0.1; @@ -737,9 +742,19 @@ function twin_vars = forward_simulate_twin(gr, gr_fwd_sim, gr_proj, conf, spotsC twin_proj(ii_d).stack = permute(cat(3, spots{:}), [1 3 2]); end + % We will auto-select the shared reflections with the parent + % that got also selcted there (if the same blob was used!) + parent_sel = false(size(gr.allblobs.omega)); + parent_sel(gr_proj.ondet(gr_proj.included(gr_proj.selected))) = true; + + parent_spots = zeros(size(gr.allblobs.omega)); + parent_spots(gr_proj(ii_d).ondet(gr_proj(ii_d).included)) = gr_fwd_sim(ii_d).difspotID; + twin_proj(ii_d).ondet = twin_ondet; twin_proj(ii_d).included = twin_incl; - twin_proj(ii_d).selected = false(numel(twin_incl), 1); + twin_proj(ii_d).selected = refl_match(twin_ondet(twin_incl))... + & parent_sel(twin_ondet(twin_incl)) ... + & (parent_spots(twin_ondet(twin_incl)) == twin_fwd_sim(ii_d).difspotID); end twin_vars(ii_t).allblobs = twin.allblobs;