Skip to content
Snippets Groups Projects
Commit 3d0bda7f authored by Nicola Vigano's avatar Nicola Vigano
Browse files

6D-reconstruction: interface change, to allow for num-interp to reduce the...

6D-reconstruction: interface change, to allow for num-interp to reduce the compuational cose of shape-functions

Signed-off-by: default avatarNicola Vigano <vigano@yoda.esrf.fr>
parent 1d05bdec
No related branches found
No related tags found
No related merge requests found
...@@ -46,9 +46,11 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -46,9 +46,11 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
ref_gr = sampler.get_reference_grain(); ref_gr = sampler.get_reference_grain();
volume_size = self.get_volume_size(ref_gr); volume_size = self.get_volume_size(ref_gr);
shape_funcs = self.get_shape_functions(sampler);
% Deciding the type of num_interp type % Deciding the type of num_interp type
blobs_w_interp = self.compute_num_interp(num_interp, sampler); [blobs_w_interp, num_interp] = self.compute_num_interp(num_interp, sampler);
shape_funcs = self.get_shape_functions(sampler, num_interp, blobs_w_interp);
algo_params = self.get_algorithm_params(sampler, blobs_w_interp, shape_funcs); algo_params = self.get_algorithm_params(sampler, blobs_w_interp, shape_funcs);
blobs = algo_params.blobs; blobs = algo_params.blobs;
...@@ -88,10 +90,10 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -88,10 +90,10 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
gr = sampler(ii_o_reg).get_reference_grain(); gr = sampler(ii_o_reg).get_reference_grain();
fprintf('%d) Grainid %d:\n', ii_o_reg, gr.id) fprintf('%d) Grainid %d:\n', ii_o_reg, gr.id)
shape_funcs = self.get_shape_functions(sampler(ii_o_reg));
% Deciding the type of num_interp type % Deciding the type of num_interp type
blobs_w_interp{ii_o_reg} = self.compute_num_interp(num_interp, sampler(ii_o_reg)); [blobs_w_interp{ii_o_reg}, num_interp] = self.compute_num_interp(num_interp, sampler(ii_o_reg));
shape_funcs = self.get_shape_functions(sampler(ii_o_reg), num_interp, blobs_w_interp{ii_o_reg});
% assigning to the twin the blob_w_interp of the parent for % assigning to the twin the blob_w_interp of the parent for
% the shared reflections % the shared reflections
...@@ -331,20 +333,29 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -331,20 +333,29 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
end end
methods (Access = protected) methods (Access = protected)
function shape_funcs = get_shape_functions(self, sampler) function shape_funcs = get_shape_functions(self, sampler, num_interp, blobs_w_interp)
switch (lower(self.shape_functions_type)) switch (lower(self.shape_functions_type))
case 'none' case 'none'
shape_funcs = {}; shape_funcs = {};
case 'n' case 'n'
% shape_funcs = gtDefShapeFunctionsCreateNW(sampler); % shape_funcs = gtDefShapeFunctionsCreateNW(sampler);
shape_funcs = gtDefShapeFunctionsFwdProj(sampler, 'shape_function_type', 'nw'); shape_funcs = gtDefShapeFunctionsFwdProj(sampler, ...
'shape_function_type', 'nw', ...
'num_interp', num_interp, ...
'blobs_w_interp', blobs_w_interp);
shape_funcs = gtDefShapeFunctionsNW2N(shape_funcs); shape_funcs = gtDefShapeFunctionsNW2N(shape_funcs);
case 'w' case 'w'
% shape_funcs = gtDefShapeFunctionsCreateW(sampler); % shape_funcs = gtDefShapeFunctionsCreateW(sampler);
shape_funcs = gtDefShapeFunctionsFwdProj(sampler, 'shape_function_type', 'w'); shape_funcs = gtDefShapeFunctionsFwdProj(sampler, ...
'shape_function_type', 'w', ...
'num_interp', num_interp, ...
'blobs_w_interp', blobs_w_interp);
case 'nw' case 'nw'
% shape_funcs = gtDefShapeFunctionsCreateNW(sampler); % shape_funcs = gtDefShapeFunctionsCreateNW(sampler);
shape_funcs = gtDefShapeFunctionsFwdProj(sampler, 'shape_function_type', 'nw'); shape_funcs = gtDefShapeFunctionsFwdProj(sampler, ...
'shape_function_type', 'nw', ...
'num_interp', num_interp, ...
'blobs_w_interp', blobs_w_interp);
otherwise otherwise
error('Gt6DReconstructionAlgorithmFactory:wrong_argument', ... error('Gt6DReconstructionAlgorithmFactory:wrong_argument', ...
'Shape functions of type: %s, not supported yet!', ... 'Shape functions of type: %s, not supported yet!', ...
...@@ -482,7 +493,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -482,7 +493,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
end end
end end
function blobs_w_interp = compute_num_interp(self, num_interp, sampler) function [blobs_w_interp, num_interp] = compute_num_interp(self, num_interp, sampler)
ref_gr = sampler.get_reference_grain(); ref_gr = sampler.get_reference_grain();
selected = sampler.ondet(sampler.included(sampler.selected)); selected = sampler.ondet(sampler.included(sampler.selected));
etas = ref_gr.allblobs.eta(selected); etas = ref_gr.allblobs.eta(selected);
...@@ -494,7 +505,12 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -494,7 +505,12 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
end end
if (strcmpi(self.num_interp_type, 'lorentz')) if (strcmpi(self.num_interp_type, 'lorentz'))
blobs_w_interp = self.compute_lorentz_slice_broadening(num_interp, etas); lorentz_factor = 1 ./ abs(sind(etas));
% Let's try to not penalize rounding errors and being a bit
% tollerant with small deviations from integer numbers
% (rounding in [-0.75 0.25), instead of [-0.5 0.5) ), but
% still trying to avoid gaps in the projections
blobs_w_interp = ceil(num_interp .* (lorentz_factor - 0.25));
else else
blobs_w_interp = num_interp(ones(numel(etas), 1), 1); blobs_w_interp = num_interp(ones(numel(etas), 1), 1);
end end
...@@ -938,14 +954,5 @@ classdef Gt6DReconstructionAlgorithmFactory < handle ...@@ -938,14 +954,5 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
cumulative_offs = cumulative_offs + num_projs; cumulative_offs = cumulative_offs + num_projs;
end end
end end
function slices_interp = compute_lorentz_slice_broadening(num_interp, etas)
lorentz_factor = 1 ./ abs(sind(etas));
% Let's try to not penalize rounding errors and being a bit
% tollerant with small deviations from integer numbers
% (rounding in [-0.75 0.25), instead of [-0.5 0.5) ), but
% still trying to avoid gaps in the projections
slices_interp = ceil(num_interp .* (lorentz_factor - 0.25));
end
end end
end end
\ No newline at end of file
...@@ -8,6 +8,8 @@ function shape_funcs = gtDefShapeFunctionsFwdProj(sampler, varargin) ...@@ -8,6 +8,8 @@ function shape_funcs = gtDefShapeFunctionsFwdProj(sampler, varargin)
'rspace_oversampling', 1, ... 'rspace_oversampling', 1, ...
'rspace_voxel_size', [1 1 1], ... 'rspace_voxel_size', [1 1 1], ...
'interpolated_voxel', false, ... 'interpolated_voxel', false, ...
'num_interp', [], ...
'blobs_w_interp', [], ...
'projector', 'nearest'); 'projector', 'nearest');
conf = parse_pv_pairs(conf, varargin); conf = parse_pv_pairs(conf, varargin);
......
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