-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_inversions_c_plus.m
146 lines (116 loc) · 2.9 KB
/
run_inversions_c_plus.m
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
% RUN_INVERSIONS_C_PLUS Shorter implementation with customizable regularization parameters.
% Adds other methods relative to "run_inversions_c".
%
% Author: Timothy Sipkens, 2022-09
%=========================================================================%
tools.textheader('Running inversion suite');
disp(' ');
%%
% Initial guess for iterative schemes
x_init = interp2(grid_b.edges{2}',grid_b.edges{1}',...
reshape(full(b)./(A*ones(size(x0))),grid_b.ne),...
grid_x.elements(:,2),grid_x.elements(:,1));
x_init(isnan(x_init)) = 0;
x_init(isinf(x_init)) = 0;
x_init = sparse(max(0,x_init));
eps.init = norm(x0-x_init);
%%
% Least squares
disp('Running LSQ ...');
x_length = length(A(1,:));
tic;
x_lsq = invert.lsq(Lb*A, Lb*b);
t.lsq = toc;
tools.textdone();
disp(' ');
eps.lsq = norm(x0 - x_lsq);
%%
% Twomey
disp('Running Twomey ...');
tic;
x_two = invert.twomey(A,b,x_init,300,[],[],1);
t.two = toc;
disp(' ');
eps.two = norm(x0-x_two);
%%
% Twomey-Markowski-Buckley
disp('Running Twomey-Markowski-Buckley ...');
tic;
x_two_mh = invert.twomark(A,b,Lb,n_x(1),...
x_init,35,'Buckley');
t.twomark = toc;
eps.twomark = norm(x0-x_two_mh);
%%
% MART, Maximum entropy regularized solution
disp('Running MART ...');
tic;
x_mart = invert.mart(A, b, x_init, 1:300);
t.mart = toc;
tools.textdone();
disp(' ');
eps.mart = norm(x0-x_mart);
%%
% Tikhonov (0th) implementation
disp('Running Tikhonov (0th) ...');
lambda_tk0 = 0.419941123497942;
tic;
[x_tk0,D_tk0,L_tk0,Gpo_tk0] = invert.tikhonov(...
Lb*A,Lb*b,lambda_tk0,0,n_x(1),[],'non-neg');
t.tk0 = toc;
tools.textdone();
disp(' ');
eps.tk0 = norm(x0-x_tk0);
%%
% Tikhonov (1st) implementation
disp('Running Tikhonov (1st) ...');
lambda_tk1 = 0.935436889902617;
tic;
[x_tk1,D_tk1,L_tk1,Gpo_tk1] = invert.tikhonov(...
Lb*A,Lb*b,lambda_tk1,1,n_x(1),[],'non-neg');
t.tk1 = toc;
tools.textdone();
disp(' ');
eps.tk1 = norm(x0-x_tk1);
%%
% Tikhonov (2nd) implementation
disp('Running Tikhonov (2nd) ...');
lambda_tk2 = 1.069019204603001;
tic;
[x_tk2,D_tk2,L_tk2] = invert.tikhonov(...
Lb*A,Lb*b,lambda_tk2,2,n_x(1),[],'non-neg');
t.tk2 = toc;
tools.textdone();
disp(' ');
eps.tk2 = norm(x0-x_tk2);
%%
% Expectation maximization.
disp('Running expectation-maximization (EM) ...');
tic;
x_em = invert.em(Lb*A, Lb*b, x_init, 3);
t.em = toc;
tools.textdone();
disp(' ');
eps.em = norm(x0-x_em);
%%
% Exponential distance
Gd = phantom.Sigma(:,:,1);
if isempty(Gd) % for Phantom 3
[~,Gd] = phantom.p2cov(phantom.p(2),phantom.modes(2));
end
%-- Gd properties -----------------%
l1 = sqrt(Gd(1,1));
l2 = sqrt(Gd(2,2));
R12 = Gd(1,2)/(l1*l2);
Dm = Gd(1,2)/Gd(2,2); % s1*R12/s2
%----------------------------------%
disp('Running exponential distance ...');
lambda_ed = 1.0826; % found using other run_inversion* scripts
tic;
[x_ed] = ...
invert.exp_dist(...
Lb*A,Lb*b,lambda_ed,Gd,...
grid_x,[]);
t.ed = toc;
tools.textdone();
disp(' ');
eps.ed = norm(x_ed-x0);