Skip to content
Snippets Groups Projects
Commit c04ac62f authored by Christophe Le Bourlot's avatar Christophe Le Bourlot
Browse files

Add the option sample_shif during the 'assemble volume' step, to shift the...

Add the option sample_shif during the 'assemble volume' step, to shift the sample of the given vector in order to have it within the field of view
parent e15ab051
No related branches found
No related tags found
No related merge requests found
...@@ -541,6 +541,13 @@ classdef GtAssembleVol3D < handle ...@@ -541,6 +541,13 @@ classdef GtAssembleVol3D < handle
rot = gtMathsRotationTensorComposite(rot_axes, rot_angles); rot = gtMathsRotationTensorComposite(rot_axes, rot_angles);
end end
% Sample translation
sample_shift = obj.localPar.sample_shift;
sample_shift_size = size(sample_shift);
if sample_shift_size(2)<3
sample_shift = [0, 0, 0];
end
% Adding clusters first! % Adding clusters first!
clusters = sample.phases{phase_id}.getActiveClusters(); clusters = sample.phases{phase_id}.getActiveClusters();
...@@ -579,7 +586,7 @@ classdef GtAssembleVol3D < handle ...@@ -579,7 +586,7 @@ classdef GtAssembleVol3D < handle
if (obj.localPar.solve_conflict_with_intensity) if (obj.localPar.solve_conflict_with_intensity)
[p_gids, p_int_vol, p_dm_vol] = obj.placeClusterSubVolume( ... [p_gids, p_int_vol, p_dm_vol] = obj.placeClusterSubVolume( ...
clusters(ii).included_ids(1), cl_rec.ODF6D, cl_rec.SEG, p_gids, p_int_vol, p_dm_vol); clusters(ii).included_ids(1), cl_rec.ODF6D, cl_rec.SEG, p_gids, p_int_vol, p_dm_vol, sample_shift);
else else
seg_vol = int16(cl_rec.SEG.seg); seg_vol = int16(cl_rec.SEG.seg);
seg_bb = cl_rec.SEG.segbb; seg_bb = cl_rec.SEG.segbb;
...@@ -592,15 +599,15 @@ classdef GtAssembleVol3D < handle ...@@ -592,15 +599,15 @@ classdef GtAssembleVol3D < handle
int_vol = int_vol * numel(find(seg_vol)) / sum(int_vol(:)); int_vol = int_vol * numel(find(seg_vol)) / sum(int_vol(:));
p_gids = gtPlaceSubVolume( p_gids, seg_vol, ... p_gids = gtPlaceSubVolume( p_gids, seg_vol, ...
seg_bb(1:3), ... seg_bb(1:3) + sample_shift, ...
clusters(ii).included_ids(1), ... clusters(ii).included_ids(1), ...
obj.localPar.overlaps); obj.localPar.overlaps);
p_int_vol = gtPlaceSubVolume( p_int_vol, ... p_int_vol = gtPlaceSubVolume( p_int_vol, ...
int_vol, seg_bb(1:3) ); int_vol, seg_bb(1:3) + sample_shift );
seg = struct('vol', seg_vol, 'bb', seg_bb); seg = struct('vol', seg_vol, 'bb', seg_bb);
p_dm_vol = obj.placeSubDmVol(p_dm_vol, cl_rec.ODF6D, seg); p_dm_vol = obj.placeSubDmVol(p_dm_vol, cl_rec.ODF6D, seg, sample_shift);
end end
catch mexc catch mexc
gtPrintException(mexc, sprintf('\nCluster %d (%s) failed!!\n', ii, str_ids)); gtPrintException(mexc, sprintf('\nCluster %d (%s) failed!!\n', ii, str_ids));
...@@ -685,17 +692,19 @@ classdef GtAssembleVol3D < handle ...@@ -685,17 +692,19 @@ classdef GtAssembleVol3D < handle
if (obj.localPar.deal_with_twins) if (obj.localPar.deal_with_twins)
[p_gids, obj.twinInfo{phase_id}.output{ii}] = ... [p_gids, obj.twinInfo{phase_id}.output{ii}] = ...
obj.placeTwinSubVolume(gauge, p_gids, phase_id, grain_id, seg_vol, seg_bb); obj.placeTwinSubVolume(gauge, p_gids, phase_id, grain_id, seg_vol, seg_bb, sample_shift);
elseif (obj.localPar.solve_conflict_with_intensity) elseif (obj.localPar.solve_conflict_with_intensity)
if (assemble_6D) if (assemble_6D)
[p_gids, p_int_vol, p_dm_vol] = obj.placeClusterSubVolume( ... [p_gids, p_int_vol, p_dm_vol] = obj.placeClusterSubVolume( ...
grain_id, gr_rec, gr_seg, p_gids, p_int_vol, p_dm_vol); grain_id, gr_rec, gr_seg, p_gids, p_int_vol, p_dm_vol, sample_shift);
else else
[p_gids, p_int_vol] = obj.placeClusterSubVolume( ... [p_gids, p_int_vol] = obj.placeClusterSubVolume( ...
grain_id, gr_rec, gr_seg, p_gids, p_int_vol); grain_id, gr_rec, gr_seg, p_gids, p_int_vol, sample_shift);
end end
else else
p_gids = gtPlaceSubVolume(p_gids, seg_vol, seg_bb(1:3), grain_id, obj.localPar.overlaps); %fprintf(" seg_bb(1:3): ");
p_gids = gtPlaceSubVolume(p_gids, seg_vol, seg_bb(1:3) + sample_shift, grain_id, obj.localPar.overlaps);
end end
if (assemble_6D && ~obj.localPar.solve_conflict_with_intensity) if (assemble_6D && ~obj.localPar.solve_conflict_with_intensity)
seg = struct('vol', seg_vol, 'bb', seg_bb); seg = struct('vol', seg_vol, 'bb', seg_bb);
...@@ -705,7 +714,7 @@ classdef GtAssembleVol3D < handle ...@@ -705,7 +714,7 @@ classdef GtAssembleVol3D < handle
crop_bb(1:3) = crop_bb(1:3) - gr_rec.shift + 1; crop_bb(1:3) = crop_bb(1:3) - gr_rec.shift + 1;
int_vol = gtCrop(gr_rec.intensity, crop_bb) .* logical(seg_vol); int_vol = gtCrop(gr_rec.intensity, crop_bb) .* logical(seg_vol);
int_vol = int_vol * numel(find(seg_vol)) / sum(int_vol(:)); int_vol = int_vol * numel(find(seg_vol)) / sum(int_vol(:));
p_int_vol = gtPlaceSubVolume(p_int_vol, int_vol, seg_bb(1:3)); p_int_vol = gtPlaceSubVolume(p_int_vol, int_vol, seg_bb(1:3) + sample_shift);
end end
% Trigger callback (usually used in graphical applications) % Trigger callback (usually used in graphical applications)
...@@ -730,6 +739,7 @@ classdef GtAssembleVol3D < handle ...@@ -730,6 +739,7 @@ classdef GtAssembleVol3D < handle
end end
function cluster_rec = mergeTwinClusterRec(~, cluster_rec, dilate_steps) function cluster_rec = mergeTwinClusterRec(~, cluster_rec, dilate_steps)
%sample_shift not added here...
if (exist('dilate_steps', 'var') && ~isempty(dilate_steps) ... if (exist('dilate_steps', 'var') && ~isempty(dilate_steps) ...
&& (dilate_steps > 0)) && (dilate_steps > 0))
seg_vol = single(cluster_rec.SEG(1).seg); seg_vol = single(cluster_rec.SEG(1).seg);
...@@ -763,10 +773,10 @@ classdef GtAssembleVol3D < handle ...@@ -763,10 +773,10 @@ classdef GtAssembleVol3D < handle
cluster_rec = struct('ODF6D', cl_rec, 'SEG', cl_seg); cluster_rec = struct('ODF6D', cl_rec, 'SEG', cl_seg);
end end
function [ph_gids, ph_ints, ph_dms] = placeClusterSubVolume(obj, grain_id, gr_rec, gr_seg, ph_gids, ph_ints, ph_dms) function [ph_gids, ph_ints, ph_dms] = placeClusterSubVolume(obj, grain_id, gr_rec, gr_seg, ph_gids, ph_ints, ph_dms, sample_shift)
% the bbox extremes start from 0 ad not from 1 (matlab coords). % the bbox extremes start from 0 ad not from 1 (matlab coords).
% seg_bb(1:3) is a shift (argument 3) that starts from zero! % seg_bb(1:3) is a shift (argument 3) that starts from zero!
[lims_vol, lims_gr] = gtGetVolsIntersectLimits(size(ph_gids), size(gr_seg.seg), gr_seg.segbb(1:3)); [lims_vol, lims_gr] = gtGetVolsIntersectLimits(size(ph_gids), size(gr_seg.seg), gr_seg.segbb(1:3) + sample_shift);
% Getting the subvolumes -> so we operate all the costy % Getting the subvolumes -> so we operate all the costy
% operations on smaller volumes % operations on smaller volumes
...@@ -834,12 +844,20 @@ classdef GtAssembleVol3D < handle ...@@ -834,12 +844,20 @@ classdef GtAssembleVol3D < handle
end end
end end
function [volume, g_info] = placeTwinSubVolume(obj, gauge, volume, phase_id, grain_id, seg_vol, seg_bb) function [volume, g_info] = placeTwinSubVolume(obj, gauge, volume, phase_id, grain_id, seg_vol, seg_bb, sample_shift)
sample = obj.getSample(); sample = obj.getSample();
% Sample translation
sample_shift = obj.localPar.sample_shift;
+ sample_shift_size = size(sample_shift);
+ if sample_shift_size(2)<3
+ sample_shift = [0, 0, 0];
+ end
% the bbox extremes start from 0 ad not from 1 (matlab coords). % the bbox extremes start from 0 ad not from 1 (matlab coords).
% seg_bb(1:3) is a shift (argument 3) that starts from zero! % seg_bb(1:3) is a shift (argument 3) that starts from zero!
[limsVolume, limsGrain] = gtGetVolsIntersectLimits(size(volume), size(seg_vol), seg_bb(1:3)); [limsVolume, limsGrain] = gtGetVolsIntersectLimits(size(volume), size(seg_vol), seg_bb(1:3) + sample_shift);
% Getting the subvolumes -> so we operate all the costy % Getting the subvolumes -> so we operate all the costy
% operations on smaller volumes % operations on smaller volumes
...@@ -945,12 +963,12 @@ classdef GtAssembleVol3D < handle ...@@ -945,12 +963,12 @@ classdef GtAssembleVol3D < handle
% because the might have cropped the volumes, due to grains % because the might have cropped the volumes, due to grains
% falling out of the volume % falling out of the volume
volume = gtPlaceSubVolume(volume, sub_phase_vol, ... volume = gtPlaceSubVolume(volume, sub_phase_vol, ...
(limsVolume(1, :) - 1), 0, 'assign'); (limsVolume(1, :) - 1) + sample_shift, 0, 'assign');
else else
g_info = {}; g_info = {};
% Ok, no conflict or no twin case -> let's treat it as % Ok, no conflict or no twin case -> let's treat it as
% normal case % normal case
volume = gtPlaceSubVolume(volume, seg_vol, seg_bb(1:3), ... volume = gtPlaceSubVolume(volume, seg_vol, seg_bb(1:3) + sample_shift, ...
grain_id, obj.localPar.overlaps); grain_id, obj.localPar.overlaps);
end end
end end
...@@ -1317,8 +1335,12 @@ classdef GtAssembleVol3D < handle ...@@ -1317,8 +1335,12 @@ classdef GtAssembleVol3D < handle
conf.force_only_indexed = false; conf.force_only_indexed = false;
conf.solve_conflict_with_intensity = false; conf.solve_conflict_with_intensity = false;
conf.rotation_axes = zeros(0, 3); conf.rotation_axes = zeros(0, 3);
conf.rotation_angles = zeros(0, 1); conf.rotation_angles = zeros(0, 1);
% add a sample shift after assembling to have it in the field of view
conf.sample_shift = zeros(0, 3);
end end
function [newVol, offset] = convertCombinedVolumeToUIDs(phaseIDs, grainIDs, offset) function [newVol, offset] = convertCombinedVolumeToUIDs(phaseIDs, grainIDs, offset)
...@@ -1352,8 +1374,16 @@ classdef GtAssembleVol3D < handle ...@@ -1352,8 +1374,16 @@ classdef GtAssembleVol3D < handle
phaseIDs(grainIDs == 0) = 0; phaseIDs(grainIDs == 0) = 0;
end end
function dmvol = placeSubDmVol(dmvol, vol6D, seg) function dmvol = placeSubDmVol(dmvol, vol6D, seg, sample_shift)
% GTASSEMBLEVOL3D/placeSubDmVol % GTASSEMBLEVOL3D/placeSubDmVol
if nargin < 4
sample_shift = [0, 0, 0];
end
sample_shift_size = size(sample_shift);
if sample_shift_size(2)<3
sample_shift = [0, 0, 0];
end
seg_bb = [seg.bb(1:3) - vol6D.shift + 1, seg.bb(4:6)]; seg_bb = [seg.bb(1:3) - vol6D.shift + 1, seg.bb(4:6)];
for ii_dim = 1:3 for ii_dim = 1:3
single_dim_dmvol = vol6D.voxels_avg_R_vectors(:, :, :, ii_dim); single_dim_dmvol = vol6D.voxels_avg_R_vectors(:, :, :, ii_dim);
...@@ -1361,7 +1391,7 @@ classdef GtAssembleVol3D < handle ...@@ -1361,7 +1391,7 @@ classdef GtAssembleVol3D < handle
single_dim_dmvol(~seg.vol) = 0; single_dim_dmvol(~seg.vol) = 0;
dmvol = gtPlaceSubVolume( dmvol, single_dim_dmvol, ... dmvol = gtPlaceSubVolume( dmvol, single_dim_dmvol, ...
[seg.bb(1:3), ii_dim-1], [], 'assign'); [seg.bb(1:3), ii_dim-1] + [sample_shift, 0], [], 'assign');
end end
end end
......
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