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

6D-reconstruction: refactored building of algorithms to be more flexible

parent e8642c6e
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ function par_rec = gtRecGrainsDefaultParameters(algo)
par_6D_rec_opts = struct( ...
'grid_edge', 7, 'super_sampling', 1, 'num_interp', 1, ...
'lambda', 1e-1, 'volume_downscaling', 1, ...
'ospace_oversize', 1.1);
'ospace_oversize', 1.1, 'rspace_oversize', 1.2);
par_rec = struct(...
'algorithm', upper(algo), 'num_iter', 50, 'list', [], ...
'options', par_6D_rec_opts);
......
......@@ -14,13 +14,17 @@ function rec_opts = gtReconstruct6DGetParamenters(parameters)
|| isempty(rec_opts.ospace_oversize))
rec_opts.ospace_oversize = 1.1;
end
if (~isfield(rec_opts, 'rspace_oversize') ...
|| isempty(rec_opts.rspace_oversize))
rec_opts.rspace_oversize = 1.2;
end
else
warning('gtReconstruct6DGetParamenters:wrong_parameters', ...
'The rec.grains structure doesn''t seem to be valid. Falling back to defaults')
rec_opts = struct( ...
'grid_edge', 7, 'num_interp', 1, 'lambda', 1e-1, ...
'super_sampling', 1, 'volume_downscaling', 1, ...
'ospace_oversize', 1.1 );
'ospace_oversize', 1.1, 'rspace_oversize', 1.2 );
end
if (isfield(rec, 'grains'))
rec_opts.num_iter = rec.grains.num_iter;
......
......@@ -3,7 +3,8 @@ function [algo, good_or] = gtReconstruct6DLaunchAlgorithm(sampler, rec_opts, par
%
rec_factory = Gt6DReconstructionAlgorithmFactory(parameters, ...
'volume_downscaling', rec_opts.volume_downscaling);
'volume_downscaling', rec_opts.volume_downscaling, ...
'rspace_oversize', rec_opts.rspace_oversize );
[algo, good_or] = rec_factory.getSubBlobReconstructionAlgo(sampler, rec_opts.num_interp);
mem_cons = [ ...
......
......@@ -7,6 +7,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
det_index = 1;
volume_downscaling = 1;
rspace_oversize = 1.2;
parameters;
end
......@@ -21,6 +22,48 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
end
function [algo, good_orients, blobs] = getSubBlobReconstructionAlgo(self, sampler, num_interp, varargin)
algo_params = self.get_algorithm_params(sampler, num_interp);
% Build Empty volumes
ref_gr = sampler.get_reference_grain();
spacing = mean([ref_gr.proj.vol_size_y, ref_gr.proj.vol_size_x, ref_gr.proj.vol_size_z]) * (self.rspace_oversize - 1);
volume_size = round([ref_gr.proj.vol_size_y, ref_gr.proj.vol_size_x, ref_gr.proj.vol_size_z] + spacing);
if (self.volume_downscaling > 1)
volume_size = ceil(volume_size / self.volume_downscaling);
num_geoms = numel(algo_params.geometries);
for ii = 1:num_geoms
algo_params.geometries{ii}(:, 4:12) = algo_params.geometries{ii}(:, 4:12) / self.volume_downscaling;
end
if (~isempty(algo_params.geometries_ss))
for ii = 1:num_geoms
geom_ss = algo_params.geometries_ss{ii};
for ii_ss = 1:numel(geom_ss)
geom_ss{ii_ss}(:, 4:12) = geom_ss{ii_ss}(:, 4:12) / self.volume_downscaling;
end
algo_params.geometries_ss{ii} = geom_ss;
end
end
end
good_orients = algo_params.good_orients;
blobs = algo_params.blobs;
algo = Gt6DBlobReconstructor(volume_size, blobs, ...
'data_type', self.data_type, ...
'geometries', algo_params.geometries, ...
'offsets', algo_params.offsets, ...
'ss_geometries', algo_params.geometries_ss, ...
'ss_offsets', algo_params.offsets_ss, ...
'use_astra_projectors', true, ...
'volume_ss', self.volume_downscaling, ...
'psf', algo_params.psf, ...
varargin{:} );
end
end
methods (Access = protected)
function algo_params = get_algorithm_params(self, sampler, num_interp)
fprintf('Extracting blobs on detector: ')
c = tic();
sel_bls = sampler.selected;
......@@ -203,33 +246,6 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
offsets_ss = {};
end
% Build Empty volumes
blob_size = size(bl(1).intm);
if (isfield(ref_gr, 'proj'))
spacing = mean([ref_gr.proj.vol_size_y, ref_gr.proj.vol_size_x, ref_gr.proj.vol_size_z]) * 0.2;
volume_size = round([ref_gr.proj.vol_size_y, ref_gr.proj.vol_size_x, ref_gr.proj.vol_size_z] + spacing);
% volume_size = [ref_gr.proj.vol_size_y, ref_gr.proj.vol_size_x, ref_gr.proj.vol_size_z];
% volume_size = self.get_volume_size(ref_gr.center, omegas, bl);
else
volume_size = self.getVolSize(blob_size, self.vol_type);
end
if (self.volume_downscaling > 1)
volume_size = ceil(volume_size / self.volume_downscaling);
for ii = 1:num_geoms
geometries{ii}(:, 4:12) = geometries{ii}(:, 4:12) / self.volume_downscaling;
end
if (~isempty(geometries_ss))
for ii = 1:num_geoms
geom_ss = geometries_ss{ii};
for ii_ss = 1:numel(geom_ss)
geom_ss{ii_ss}(:, 4:12) = geom_ss{ii_ss}(:, 4:12) / self.volume_downscaling;
end
geometries_ss{ii} = geom_ss;
end
end
end
if (isfield(bl, 'psf'))
psf = arrayfun(@(x){ permute(x.psf, [1 3 2]) }, bl);
elseif (isfield(sampler.ref_gr.proj, 'psf'))
......@@ -238,20 +254,16 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
psf = {};
end
algo = Gt6DBlobReconstructor(volume_size, blobs, ...
'data_type', self.data_type, ...
'geometries', geometries, ...
'offsets', offsets, ...
'ss_geometries', geometries_ss, ...
'ss_offsets', offsets_ss, ...
'use_astra_projectors', true, ...
'volume_ss', self.volume_downscaling, ...
'psf', psf, ...
varargin{:} );
algo_params = struct( ...
'blobs', {blobs}, ...
'geometries', {geometries}, ...
'offsets', {offsets}, ...
'geometries_ss', {geometries_ss}, ...
'offsets_ss', {offsets_ss}, ...
'psf', {psf}, ...
'good_orients', {good_orients} );
end
end
methods (Access = protected)
function [sub_blob_slices, proj_coeffs] = get_sub_blobs(self, blobs, slices_interp, padding)
num_blobs = numel(blobs);
sub_blob_slices = cell(num_blobs, 1);
......
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