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

6D-Reconstruction: fixed some verbose output and calculation

parent 0827355c
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,15 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -98,7 +98,15 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
otherwise otherwise
iters = numIters; iters = numIters;
end end
tot_iters = numel(iters); tot_iters = numel(iters);
if (self.verbose)
result_slice = eps('single') .* rand(size(self.currentSolution{1}, 1), ...
size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate));
vol_viewer = GtVolView(result_slice);
end
for ii = iters for ii = iters
numchars = fprintf('%03d/%03d (in %f s)', ii-min(iters), tot_iters, toc(c)); numchars = fprintf('%03d/%03d (in %f s)', ii-min(iters), tot_iters, toc(c));
...@@ -136,22 +144,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -136,22 +144,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
fprintf('%s', repmat(sprintf('\b'), 1, numchars)) fprintf('%s', repmat(sprintf('\b'), 1, numchars))
if (self.verbose && (mod(ii, sample_rate) == 0)) if (self.verbose && (mod(ii, sample_rate) == 0))
proj_bls = gtMathsGetSameSizeZeros(self.blobs); [value, summed_vols] = self.compute_functional_value(p, '6DL1', lambda);
for n = 1:numel(self.currentSolution) ind = ii / sample_rate;
proj_bls = self.fwd_project_volumes( ... self.normResiduals(ind) = value;
proj_bls, nextEnhancedSolution{n}, n);
end half_slice = round(size(summed_vols, 3) / 2);
proj_bls = internal_cell_sub_assign(proj_bls, self.blobs); result_slice(:, :, ind) = summed_vols(:, :, half_slice);
self.normResiduals(ii / sample_rate) = ... vol_viewer.changeVol(result_slice);
internal_cell_square_norm(proj_bls) / 2 ... vol_viewer.changeSlice(ind);
+ lambda * gtMathsNorm_l1(self.currentSolution) ...
+ internal_cell_square_norm(p) / 2 ...
+ internal_cell_dot_product(p, self.blobs);
proj_bls = gtMathsSumCellVolumes(self.currentSolution);
ctr_slice = round(size(proj_bls, 3) / 2);
figure, imagesc(proj_bls(:, :, ctr_slice)), ...
title(sprintf('Slice: %d, Iteration: %d', ctr_slice, ii))
end end
drawnow(); drawnow();
end end
...@@ -194,7 +194,15 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -194,7 +194,15 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
otherwise otherwise
iters = numIters; iters = numIters;
end end
tot_iters = numel(iters); tot_iters = numel(iters);
if (self.verbose)
result_slice = eps('single') .* rand(size(self.currentSolution{1}, 1), ...
size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate));
vol_viewer = GtVolView(result_slice);
end
for ii = iters for ii = iters
numchars = fprintf('%03d/%03d (in %f s)', ii-min(iters), tot_iters, toc(c)); numchars = fprintf('%03d/%03d (in %f s)', ii-min(iters), tot_iters, toc(c));
...@@ -228,21 +236,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -228,21 +236,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
fprintf('%s', repmat(sprintf('\b'), 1, numchars)) fprintf('%s', repmat(sprintf('\b'), 1, numchars))
if (self.verbose && (mod(ii, sample_rate) == 0)) if (self.verbose && (mod(ii, sample_rate) == 0))
proj_bls = gtMathsGetSameSizeZeros(self.blobs); [value, summed_vols] = self.compute_functional_value(p, '6DLS');
for n = 1:numel(self.currentSolution) ind = ii / sample_rate;
proj_bls = self.fwd_project_volumes( ... self.normResiduals(ind) = value;
proj_bls, nextEnhancedSolution{n}, n);
end half_slice = round(size(summed_vols, 3) / 2);
proj_bls = internal_cell_sub_assign(proj_bls, self.blobs); result_slice(:, :, ind) = summed_vols(:, :, half_slice);
self.normResiduals(ii / sample_rate) = ... vol_viewer.changeVol(result_slice);
internal_cell_square_norm(proj_bls) / 2 ... vol_viewer.changeSlice(ind);
+ internal_cell_square_norm(p) / 2 ...
+ internal_cell_dot_product(p, self.blobs);
proj_bls = gtMathsSumCellVolumes(self.currentSolution);
ctr_slice = round(size(proj_bls, 3) / 2);
figure, imagesc(proj_bls(:, :, ctr_slice)), ...
title(sprintf('Slice: %d, Iteration: %d', ctr_slice, ii))
end end
drawnow(); drawnow();
end end
...@@ -289,7 +290,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -289,7 +290,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
tot_iters = numel(iters); tot_iters = numel(iters);
if (self.verbose) if (self.verbose)
result_slice = zeros(size(self.currentSolution{1}, 1), ... result_slice = eps('single') .* rand(size(self.currentSolution{1}, 1), ...
size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate)); size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate));
vol_viewer = GtVolView(result_slice); vol_viewer = GtVolView(result_slice);
end end
...@@ -332,16 +333,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -332,16 +333,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
fprintf('%s', repmat(sprintf('\b'), 1, numchars)) fprintf('%s', repmat(sprintf('\b'), 1, numchars))
if (self.verbose && (mod(ii, sample_rate) == 0)) if (self.verbose && (mod(ii, sample_rate) == 0))
l = gtMathsSumCellVolumes(self.currentSolution); [value, summed_vols] = self.compute_functional_value(p, '6DTV');
sES = gtMathsGradient(l / numel(self.currentSolution)); ind = ii / sample_rate;
self.normResiduals(ii / sample_rate) = ... self.normResiduals(ind) = value;
+ gtMathsNorm_l1(sES) ...
+ internal_cell_dot_product(p, self.blobs); half_slice = round(size(summed_vols, 3) / 2);
result_slice(:, :, ind) = summed_vols(:, :, half_slice);
half_slice = round(size(l, 3) / 2);
result_slice(:, :, ii / sample_rate) = l(:, :, half_slice);
vol_viewer.changeVol(result_slice); vol_viewer.changeVol(result_slice);
vol_viewer.changeSlice(ii / sample_rate); vol_viewer.changeSlice(ind);
end end
drawnow(); drawnow();
end end
...@@ -389,7 +388,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -389,7 +388,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
tot_iters = numel(iters); tot_iters = numel(iters);
if (self.verbose) if (self.verbose)
result_slice = zeros(size(self.currentSolution{1}, 1), ... result_slice = eps('single') .* rand(size(self.currentSolution{1}, 1), ...
size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate)); size(self.currentSolution{1}, 2), floor(tot_iters/sample_rate));
vol_viewer = GtVolView(result_slice); vol_viewer = GtVolView(result_slice);
end end
...@@ -437,17 +436,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -437,17 +436,14 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
fprintf('%s', repmat(sprintf('\b'), 1, numchars)) fprintf('%s', repmat(sprintf('\b'), 1, numchars))
if (self.verbose && (mod(ii, sample_rate) == 0)) if (self.verbose && (mod(ii, sample_rate) == 0))
l = gtMathsSumCellVolumes(self.currentSolution); [value, summed_vols] = self.compute_functional_value(p, '6DTVL1', lambda);
sES = gtMathsGradient(l / numel(self.currentSolution)); ind = ii / sample_rate;
self.normResiduals(ii / sample_rate) = ... self.normResiduals(ind) = value;
+ gtMathsNorm_l1(sES) ...
+ internal_cell_dot_product(p, self.blobs) ... half_slice = round(size(summed_vols, 3) / 2);
+ lambda * gtMathsNorm_l1(self.currentSolution); result_slice(:, :, ind) = summed_vols(:, :, half_slice);
half_slice = round(size(l, 3) / 2);
result_slice(:, :, ii / sample_rate) = l(:, :, half_slice);
vol_viewer.changeVol(result_slice); vol_viewer.changeVol(result_slice);
vol_viewer.changeSlice(ii / sample_rate); vol_viewer.changeSlice(ind);
end end
drawnow(); drawnow();
end end
...@@ -570,7 +566,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -570,7 +566,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
end end
end end
function [value, summed_vols] = compute_functional_value(self, algo, lambda) function [value, summed_vols] = compute_functional_value(self, p, algo, lambda)
value = internal_cell_dot_product(p, self.blobs); value = internal_cell_dot_product(p, self.blobs);
if (any(strcmpi(algo, {'6DLS', '6DL1'}))) if (any(strcmpi(algo, {'6DLS', '6DL1'})))
...@@ -585,7 +581,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector ...@@ -585,7 +581,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
summed_vols = gtMathsSumCellVolumes(self.currentSolution); summed_vols = gtMathsSumCellVolumes(self.currentSolution);
if (any(strcmpi(algo, {'6DTV', '6DTVL1'}))) if (any(strcmpi(algo, {'6DTV', '6DTVL1'})))
sES = gtMathsGradient(l / numel(self.currentSolution)); sES = gtMathsGradient(summed_vols / numel(self.currentSolution));
value = value + gtMathsNorm_l1(sES); value = value + gtMathsNorm_l1(sES);
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