summaryrefslogtreecommitdiffstats
path: root/matlab/tools/createOrderART.m
blob: 5a206e6db3eb05727a0a39dd3bb6c1c0d6fb0941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function rayOrder = createOrderART(proj_geom, mode)

%------------------------------------------------------------------------
% rayOrder = createOrderART(proj_geom, mode)
% 
% Creates an array defining the order in which ART will iterate over the
% projections and projection rays 
%
% proj_geom: MATLAB struct containing the projection geometry.
% mode: string defining the wanted ray order, can be either 'sequential',
% 'randomray' or 'randomproj'.
% rayOrder: array of two columns of length angle_count * det_count, with
% the first column being the index of the projection and the second column 
% the index of the ray.
%------------------------------------------------------------------------
%------------------------------------------------------------------------
% This file is part of the ASTRA Toolbox
% 
% Copyright: 2010-2021, imec Vision Lab, University of Antwerp
%            2014-2021, CWI, Amsterdam
% License: Open Source under GPLv3
% Contact: astra@astra-toolbox.com
% Website: http://www.astra-toolbox.com/
%------------------------------------------------------------------------

angle_count = length(proj_geom.projection_angles);
det_count = proj_geom.detector_count;

% create order
rayOrder = zeros(angle_count * det_count, 2);
if strcmp(mode,'sequential') == 1
	index = 1;
	for i = 1:angle_count
		for j = 1:det_count
			rayOrder(index,1) = i;
			rayOrder(index,2) = j;			
			index = index + 1;
		end
	end
elseif strcmp(mode,'randomray') == 1
	index = 1;
	for i = 1:angle_count
		for j = 1:det_count
			rayOrder(index,1) = i;
			rayOrder(index,2) = j;			
			index = index + 1;
		end
	end
	r = randperm(angle_count * det_count);
	rayOrder(:,1) = rayOrder(r,1);
	rayOrder(:,2) = rayOrder(r,2);	
elseif strcmp(mode,'randomproj') == 1
	index = 1;
	r = randperm(angle_count);
	for i = 1:angle_count
		for j = 1:det_count
			rayOrder(index,1) = r(i);
			rayOrder(index,2) = j;			
			index = index + 1;
		end
	end
else
	disp('mode not known');
end