From f6b6a2f84806a89fe6bacc583e13cb14629fb5dc Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Sat, 20 Jun 2015 00:35:16 +0200 Subject: Actually use the rec_type argument in astra_create_reconstruction_cuda --- matlab/tools/astra_create_reconstruction_cuda.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'matlab/tools') diff --git a/matlab/tools/astra_create_reconstruction_cuda.m b/matlab/tools/astra_create_reconstruction_cuda.m index 7d9e1dd..7d0421c 100644 --- a/matlab/tools/astra_create_reconstruction_cuda.m +++ b/matlab/tools/astra_create_reconstruction_cuda.m @@ -45,7 +45,7 @@ if strcmp(rec_type,'') end % configure -cfg = astra_struct('SIRT_CUDA'); +cfg = astra_struct(rec_type); cfg.ProjectionGeometry = proj_geom; cfg.ReconstructionGeometry = vol_geom; cfg.ProjectionDataId = sinogram_id; -- cgit v1.2.3 From db8587475efd44bc728caa79cd7ae7120eaf045b Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Tue, 21 Jul 2015 15:15:08 +0200 Subject: Add matlab plugin .m file --- matlab/tools/astra_mex_plugin.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 matlab/tools/astra_mex_plugin.m (limited to 'matlab/tools') diff --git a/matlab/tools/astra_mex_plugin.m b/matlab/tools/astra_mex_plugin.m new file mode 100644 index 0000000..4159365 --- /dev/null +++ b/matlab/tools/astra_mex_plugin.m @@ -0,0 +1,24 @@ +function [varargout] = astra_mex_plugin(varargin) +%------------------------------------------------------------------------ +% Reference page in Help browser +% astra_mex_plugin. +%------------------------------------------------------------------------ +%------------------------------------------------------------------------ +% This file is part of the ASTRA Toolbox +% +% Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp +% 2014-2015, CWI, Amsterdam +% License: Open Source under GPLv3 +% Contact: astra@uantwerpen.be +% Website: http://sf.net/projects/astra-toolbox +%------------------------------------------------------------------------ +% $Id$ +if nargout == 0 + astra_mex_plugin_c(varargin{:}); + if exist('ans','var') + varargout{1} = ans; + end +else + varargout = cell(1,nargout); + [varargout{:}] = astra_mex_plugin_c(varargin{:}); +end \ No newline at end of file -- cgit v1.2.3 From 026aa46c5db24ddd687cec0fa6e056a2ee3790c5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 12 Aug 2015 15:45:12 +0200 Subject: Fix algorithm object leak in astra_create_fbp_reconstruction.m --- matlab/tools/astra_create_fbp_reconstruction.m | 1 + 1 file changed, 1 insertion(+) (limited to 'matlab/tools') diff --git a/matlab/tools/astra_create_fbp_reconstruction.m b/matlab/tools/astra_create_fbp_reconstruction.m index 5540f27..a2561b7 100644 --- a/matlab/tools/astra_create_fbp_reconstruction.m +++ b/matlab/tools/astra_create_fbp_reconstruction.m @@ -19,6 +19,7 @@ cfg.ProjectorId = proj_id; cfg.Options.GPUindex = 0; alg_id = astra_mex_algorithm('create', cfg); astra_mex_algorithm('run', alg_id); +astra_mex_algorithm('delete', alg_id); if numel(sinogram) ~= 1 astra_mex_data2d('delete', sinogram_id); -- cgit v1.2.3 From 9cfe943682bd6e02d5fb8493cb9c4c98623cb441 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 4 Sep 2015 14:16:41 +0200 Subject: Fix algorithm leak in opTomo --- matlab/tools/opTomo.m | 2 ++ 1 file changed, 2 insertions(+) (limited to 'matlab/tools') diff --git a/matlab/tools/opTomo.m b/matlab/tools/opTomo.m index 14128d2..71dfb1e 100644 --- a/matlab/tools/opTomo.m +++ b/matlab/tools/opTomo.m @@ -248,6 +248,7 @@ classdef opTomo < opSpot % cleanup astra_mex_data3d('delete', vol_id); astra_mex_data3d('delete', sino_id); + astra_mex_algorithm('delete', alg_id); else % X is passed as a vector, reshape it into projection data x = reshape(x, op.proj_size); @@ -272,6 +273,7 @@ classdef opTomo < opSpot % cleanup astra_mex_data3d('delete', vol_id); astra_mex_data3d('delete', sino_id); + astra_mex_algorithm('delete', alg_id); end end % opTomo_intrnl3D -- cgit v1.2.3 From c39b12fc42a7254bad1e68cbdb948eee0421ad81 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 16 Sep 2015 16:44:10 +0200 Subject: Let astra_create_vol_geom also generate flexible volume geometries --- matlab/tools/astra_create_vol_geom.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'matlab/tools') diff --git a/matlab/tools/astra_create_vol_geom.m b/matlab/tools/astra_create_vol_geom.m index ea975e6..a3ba7de 100644 --- a/matlab/tools/astra_create_vol_geom.m +++ b/matlab/tools/astra_create_vol_geom.m @@ -15,6 +15,7 @@ function vol_geom = astra_create_vol_geom(varargin) % vol_geom: MATLAB struct containing all information of the geometry. %-------------------------------------------------------------------------- % vol_geom = astra_create_vol_geom(row_count, col_count, slice_count); +% vol_geom = astra_create_vol_geom(row_count, col_count, slice_count, min_x, max_x, min_y, max_y, min_z, max_z); % % Create a 3D volume geometry. See the API for more information. % row_count: number of rows. @@ -93,4 +94,18 @@ elseif numel(varargin) == 3 vol_geom.GridRowCount = varargin{1}; vol_geom.GridColCount = varargin{2}; vol_geom.GridSliceCount = varargin{3}; + +% astra_create_vol_geom(row_count, col_count, slice_count, min_x, max_x, min_y, max_y, min_z, max_z) +elseif numel(varargin) == 9 + vol_geom = struct(); + vol_geom.GridRowCount = varargin{1}; + vol_geom.GridColCount = varargin{2}; + vol_geom.GridSliceCount = varargin{3}; + vol_geom.option.WindowMinX = varargin{4}; + vol_geom.option.WindowMaxX = varargin{5}; + vol_geom.option.WindowMinY = varargin{6}; + vol_geom.option.WindowMaxY = varargin{7}; + vol_geom.option.WindowMinZ = varargin{8}; + vol_geom.option.WindowMaxZ = varargin{9}; + end -- cgit v1.2.3 From 1cc67c1e4d9b6b24c096f52d6f086a3f224ece8a Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 7 Oct 2015 17:29:20 +0200 Subject: Add astra_mex_direct('FP3D'/'BP3D', ...) --- matlab/tools/astra_mex_direct.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 matlab/tools/astra_mex_direct.m (limited to 'matlab/tools') diff --git a/matlab/tools/astra_mex_direct.m b/matlab/tools/astra_mex_direct.m new file mode 100644 index 0000000..58c4fd2 --- /dev/null +++ b/matlab/tools/astra_mex_direct.m @@ -0,0 +1,24 @@ +function [varargout] = astra_mex_direct(varargin) +%------------------------------------------------------------------------ +% Reference page in Help browser +% astra_mex_data3d. +%------------------------------------------------------------------------ +%------------------------------------------------------------------------ +% This file is part of the ASTRA Toolbox +% +% Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp +% 2014-2015, CWI, Amsterdam +% License: Open Source under GPLv3 +% Contact: astra@uantwerpen.be +% Website: http://sf.net/projects/astra-toolbox +%------------------------------------------------------------------------ +% $Id$ +if nargout == 0 + astra_mex_direct_c(varargin{:}); + if exist('ans','var') + varargout{1} = ans; + end +else + varargout = cell(1,nargout); + [varargout{:}] = astra_mex_direct_c(varargin{:}); +end -- cgit v1.2.3 From 0ebd8dfe60cc0d1f05d65d3840278defce0da091 Mon Sep 17 00:00:00 2001 From: Nicola Vigano Date: Wed, 7 Oct 2015 17:25:06 +0200 Subject: Add options passing to projectors from matlab Signed-off-by: Nicola Vigano --- matlab/tools/astra_create_projector.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'matlab/tools') diff --git a/matlab/tools/astra_create_projector.m b/matlab/tools/astra_create_projector.m index da9c083..9bbef9e 100644 --- a/matlab/tools/astra_create_projector.m +++ b/matlab/tools/astra_create_projector.m @@ -1,7 +1,7 @@ -function proj_id = astra_create_projector(type, proj_geom, vol_geom) +function proj_id = astra_create_projector(type, proj_geom, vol_geom, options) %-------------------------------------------------------------------------- -% proj_id = astra_create_projector(type, proj_geom, vol_geom) +% proj_id = astra_create_projector(type, proj_geom, vol_geom, options) % % Create a new projector object based on projection and volume geometry. % Used when the default values of each projector are sufficient. @@ -9,6 +9,7 @@ function proj_id = astra_create_projector(type, proj_geom, vol_geom) % type: type of the projector. 'blob', 'line', 'linear' 'strip', ... See API for more information. % proj_geom: MATLAB struct containing the projection geometry. % vol_geom: MATLAB struct containing the volume geometry. +% options: Optional MATLAB struct containing projector options (like: 'GPUindex', 'DetectorSuperSampling', and 'VoxelSuperSampling') % proj_id: identifier of the projector as it is now stored in the astra-library. %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- @@ -38,6 +39,10 @@ if strcmp(type,'blob') cfg_proj.Kernel.KernelValues = blob_values; end +if exist('options', 'var') + cfg_proj.options = options; +end + if strcmp(type,'linear3d') || strcmp(type,'linearcone') || strcmp(type,'cuda3d') proj_id = astra_mex_projector3d('create', cfg_proj); else -- cgit v1.2.3 From 5a81584cb37fe578d5985b8e78b511076fa75b1c Mon Sep 17 00:00:00 2001 From: Folkert Bleichrodt Date: Wed, 2 Mar 2016 16:47:25 +0100 Subject: opTomo: output type matches input type If opTomo is used to do a forward or backprojection, the precision of the output data now matches the precision of the input data. So the output will be single precision only if the input is stored in single precision. --- matlab/tools/opTomo.m | 86 +++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 57 deletions(-) (limited to 'matlab/tools') diff --git a/matlab/tools/opTomo.m b/matlab/tools/opTomo.m index 71dfb1e..33c8565 100644 --- a/matlab/tools/opTomo.m +++ b/matlab/tools/opTomo.m @@ -44,11 +44,9 @@ classdef opTomo < opSpot vol_id fp_alg_id bp_alg_id + proj_id % ASTRA IDs handle astra_handle - % geometries - proj_geom; - vol_geom; end % properties properties ( SetAccess = private, GetAccess = public ) @@ -139,6 +137,17 @@ classdef opTomo < opSpot error(['Only type ' 39 'cuda' 39 ' is supported ' ... 'for 3D geometries.']) end + + % setup projector + cfg = astra_struct('cuda3d'); + cfg.ProjectionGeometry = proj_geom; + cfg.VolumeGeometry = vol_geom; + cfg.option.GPUindex = gpu_index; + + % create projector + op.proj_id = astra_mex_projector3d('create', cfg); + % create handle to ASTRA object, for cleaning up + op.astra_handle = opTomo_helper_handle(op.proj_id); % create a function handle op.funHandle = @opTomo_intrnl3D; @@ -148,8 +157,6 @@ classdef opTomo < opSpot % pass object properties op.proj_size = proj_size; op.vol_size = vol_size; - op.proj_geom = proj_geom; - op.vol_geom = vol_geom; op.cflag = false; op.sweepflag = false; @@ -170,11 +177,6 @@ classdef opTomo < opSpot x = full(x); end - % convert input to single - if isa(x, 'single') == false - x = single(x); - end - % the multiplication y = op.funHandle(op, x, mode); @@ -194,7 +196,7 @@ classdef opTomo < opSpot function y = opTomo_intrnl2D(op,x,mode) if mode == 1 - % X is passed as a vector, reshape it into an image. + % x is passed as a vector, reshape it into an image. x = reshape(x, op.vol_size); % Matlab data copied to ASTRA data @@ -204,9 +206,13 @@ classdef opTomo < opSpot astra_mex_algorithm('iterate', op.fp_alg_id); % retrieve Matlab array - y = astra_mex_data2d('get_single', op.sino_id); + if isa(x, 'single') + y = astra_mex_data2d('get_single', op.sino_id); + else + y = astra_mex_data2d('get', op.sino_id); + end else - % X is passed as a vector, reshape it into a sinogram. + % x is passed as a vector, reshape it into a sinogram. x = reshape(x, op.proj_size); % Matlab data copied to ASTRA data @@ -216,8 +222,13 @@ classdef opTomo < opSpot astra_mex_algorithm('iterate', op.bp_alg_id); % retrieve Matlab array - y = astra_mex_data2d('get_single', op.vol_id); + if isa(x, 'single') + y = astra_mex_data2d('get_single', op.vol_id); + else + y = astra_mex_data2d('get', op.vol_id); + end end + end % opTomo_intrnl2D @@ -225,55 +236,16 @@ classdef opTomo < opSpot function y = opTomo_intrnl3D(op,x,mode) if mode == 1 - % X is passed as a vector, reshape it into an image + % x is passed as a vector, reshape it into an image x = reshape(x, op.vol_size); - % initialize output - y = zeros(op.proj_size, 'single'); - - % link matlab array to ASTRA - vol_id = astra_mex_data3d_c('link', '-vol', op.vol_geom, x, 0); - sino_id = astra_mex_data3d_c('link', '-sino', op.proj_geom, y, 1); - - % initialize fp algorithm - cfg = astra_struct('FP3D_CUDA'); - cfg.ProjectionDataId = sino_id; - cfg.VolumeDataId = vol_id; - - alg_id = astra_mex_algorithm('create', cfg); - % forward projection - astra_mex_algorithm('iterate', alg_id); - - % cleanup - astra_mex_data3d('delete', vol_id); - astra_mex_data3d('delete', sino_id); - astra_mex_algorithm('delete', alg_id); + y = astra_mex_direct('FP3D', op.proj_id, x); else - % X is passed as a vector, reshape it into projection data + % x is passed as a vector, reshape it into projection data x = reshape(x, op.proj_size); - - % initialize output - y = zeros(op.vol_size,'single'); - - % link matlab array to ASTRA - vol_id = astra_mex_data3d_c('link', '-vol', op.vol_geom, y, 1); - sino_id = astra_mex_data3d_c('link', '-sino', op.proj_geom, x, 0); - % initialize bp algorithm - cfg = astra_struct('BP3D_CUDA'); - cfg.ProjectionDataId = sino_id; - cfg.ReconstructionDataId = vol_id; - - alg_id = astra_mex_algorithm('create', cfg); - - % backprojection - astra_mex_algorithm('iterate', alg_id); - - % cleanup - astra_mex_data3d('delete', vol_id); - astra_mex_data3d('delete', sino_id); - astra_mex_algorithm('delete', alg_id); + y = astra_mex_direct('BP3D', op.proj_id, x); end end % opTomo_intrnl3D -- cgit v1.2.3 From 6205f3fcc68be3d49fa5b47a02a65c21ffc53930 Mon Sep 17 00:00:00 2001 From: Folkert Bleichrodt Date: Mon, 14 Mar 2016 13:18:02 +0100 Subject: Removed regression from opTomo --- matlab/tools/opTomo.m | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'matlab/tools') diff --git a/matlab/tools/opTomo.m b/matlab/tools/opTomo.m index 33c8565..04b3634 100644 --- a/matlab/tools/opTomo.m +++ b/matlab/tools/opTomo.m @@ -176,12 +176,23 @@ classdef opTomo < opSpot if issparse(x) x = full(x); end + + if isa(x, 'double') + isdouble = true; + x = single(x); + else + isdouble = false; + end % the multiplication y = op.funHandle(op, x, mode); % make sure output is column vector y = y(:); + + if isdouble + y = double(y); + end end % multiply @@ -206,11 +217,7 @@ classdef opTomo < opSpot astra_mex_algorithm('iterate', op.fp_alg_id); % retrieve Matlab array - if isa(x, 'single') - y = astra_mex_data2d('get_single', op.sino_id); - else - y = astra_mex_data2d('get', op.sino_id); - end + y = astra_mex_data2d('get_single', op.sino_id); else % x is passed as a vector, reshape it into a sinogram. x = reshape(x, op.proj_size); @@ -222,11 +229,7 @@ classdef opTomo < opSpot astra_mex_algorithm('iterate', op.bp_alg_id); % retrieve Matlab array - if isa(x, 'single') - y = astra_mex_data2d('get_single', op.vol_id); - else - y = astra_mex_data2d('get', op.vol_id); - end + y = astra_mex_data2d('get_single', op.vol_id); end end % opTomo_intrnl2D -- cgit v1.2.3