Skip to content

Commit f9a38ed

Browse files
authored
Merge pull request #416 from twhitbread/FixFDKOffsetBug
Use original geometry for FDK redundancy weighting
2 parents ef7d85c + f58fb83 commit f9a38ed

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

MATLAB/Algorithms/FDK.m

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@
4646
if dowang
4747
% Zero-padding to avoid FFT-induced aliasing %TODO: should't this be
4848
% for all cases, not just wang?
49-
[zproj, zgeo] = zeropadding(proj, geo);
5049
% Preweighting using Wang function
51-
proj=zproj.*redundancy_weighting(zgeo);
52-
% Replace original proj and geo
53-
% proj = proj_w;
54-
geo = zgeo;
50+
proj=proj.*redundancy_weighting(geo);
51+
[proj, geo] = zeropadding(proj, geo);
52+
5553
end
5654

5755
if size(geo.offDetector,2)==1

MATLAB/Algorithms/MLEM.m

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
function [res,qualMeasOut]=MLEM(proj,geo,angles,niter,varargin)
2-
%MLEM solves the tomographic problem by using Maximum Likelihood Expection
3-
% Maximitation algorithm.
2+
%MLEM solves the tomographic problem by using Maximum Likelihood Expectation
3+
% Maximisation algorithm.
44
%
55
% MLEM(PROJ,GEO,ALPHA,NITER,opt) solves the reconstruction problem
66
% using the projection data PROJ taken over ALPHA angles, corresponding
7-
% to the geometry descrived in GEO, using NITER iterations.
7+
% to the geometry described in GEO, using NITER iterations.
88
%
9-
% 'verbose': get feedback or not. Default: 1
9+
% 'verbose': Get feedback or not. Default: 1
1010
%
11-
% 'init': Describes diferent initialization techniques.
11+
% 'init': Describes different initialization techniques.
1212
% • 'none' : Initializes the image to ones (default)
13-
% • 'FDK' : intializes image to FDK reconstrucition
13+
% • 'FDK' : Initializes image to FDK reconstruction
1414
%
15-
% 'QualMeas' Asks the algorithm for a set of quality measurement
15+
% 'QualMeas': Asks the algorithm for a set of quality measurement
1616
% parameters. Input should contain a cell array of desired
1717
% quality measurement names. Example: {'CC','RMSE','MSSIM'}
1818
% These will be computed in each iteration.
19-
% 'groundTruth' an image as grounf truth, to be used if quality measures
19+
%
20+
% 'groundTruth': An image as ground truth, to be used if quality measures
2021
% are requested, to plot their change w.r.t. this known
2122
% data.
2223
%--------------------------------------------------------------------------
@@ -43,26 +44,27 @@
4344
clear gt
4445
end
4546
if nargout<2 && measurequality
46-
warning("Image metrics requested but none catched as output. Call the algorithm with 3 outputs to store them")
47+
warning("Image metrics requested but none caught as output. Call the algorithm with 3 outputs to store them")
4748
measurequality=false;
4849
end
4950
qualMeasOut=zeros(length(QualMeasOpts),niter);
5051

5152

5253
res = max(res,0);
53-
% Projection weight, W
54-
W=computeW(geo,angles,gpuids);
54+
% Back-projection weight, V
55+
V = Atb(ones(size(proj),'single'),geo,angles,'matched','gpuids',gpuids);
56+
V(V<=0.) = inf;
5557

5658
for ii=1:niter
5759
if measurequality && ~strcmp(QualMeasOpts,'error_norm')
58-
res_prev = res; % only store if necesary
60+
res_prev = res; % only store if necessary
5961
end
6062
if (ii==1);tic;end
6163

6264
den = Ax(res,geo,angles,'gpuids',gpuids);
6365
den(den<=0.)=inf;
6466

65-
imgupdate = Atb(proj./den, geo,angles,'matched','gpuids',gpuids)./W;
67+
imgupdate = Atb(proj./den, geo,angles,'matched','gpuids',gpuids)./V;
6668
res = max(res.*imgupdate,0.);
6769

6870
if measurequality
@@ -87,7 +89,7 @@
8789
% Check inputs
8890
nVarargs = length(argin);
8991
if mod(nVarargs,2)
90-
error('TIGRE:FISTA:InvalidInput','Invalid number of inputs')
92+
error('TIGRE:MLEM:InvalidInput','Invalid number of inputs')
9193
end
9294

9395
% check if option has been passed as input
@@ -103,7 +105,7 @@
103105
for ii=1:length(opts)
104106
opt=opts{ii};
105107
default=defaults(ii);
106-
% if one option isnot default, then extranc value from input
108+
% if one option is not default, then extract value from input
107109
if default==0
108110
ind=double.empty(0,1);jj=1;
109111
while isempty(ind)

MATLAB/Utilities/Atb.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
end
5555
%% geometry
5656
geo=checkGeo(geo,angles);
57-
assert(isequal([size(projections,2) size(projections,1)],geo.nDetector.'),'TIGRE:checkGeo:BadGeometry','nVoxel does not match with provided image size');
57+
assert(isequal([size(projections,2) size(projections,1)],geo.nDetector.'),'TIGRE:checkGeo:BadGeometry','nDetector does not match with provided image size');
5858

5959
%% Thats it, lets call the mex fucntion
6060

MATLAB/Utilities/redundancy_weighting.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
if ~isfield(geo,'COR')
77
geo.COR=0;
88
end
9+
910
offset = geo.offDetector(1);
1011
offset = offset + (geo.DSD(1) / geo.DSO(1)) * geo.COR(1); % added correction
1112
us = ((-geo.nDetector(1)/2+0.5):1:(geo.nDetector(1)/2-0.5))*geo.dDetector(1) + abs(offset);
1213

1314
us = us * geo.DSO(1)/geo.DSD(1);
14-
theta = (geo.sDetector(1)/2 - abs(offset))...
15-
* sign(offset);
15+
theta = (geo.sDetector(1)/2 - abs(geo.offDetector(1)))...
16+
* sign(geo.offDetector(1));
1617
abstheta = abs(theta * geo.DSO(1)/geo.DSD(1));
1718

1819
w = ones([geo.nDetector(2),geo.nDetector(1)]);

0 commit comments

Comments
 (0)