Professional Documents
Culture Documents
Project B - Inverse Problem: BMEN 5401 - Biomedical Imaging
Project B - Inverse Problem: BMEN 5401 - Biomedical Imaging
By
Thomas Boerstad
University of Minnesota
Contents I
Contents
1 Mathematical equations - Inverse problem 1
1.1 Defining the model . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Governing equations . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Field generated using transfer matrix description . . . . . . . 2
4 Tikhonov regularization 10
5 Discussion 13
5.1 M = 8 compared to M = 12 . . . . . . . . . . . . . . . . . . . 13
5.2 Interpretation of results . . . . . . . . . . . . . . . . . . . . . 13
6 Matlab code 16
6.1 Main script . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.2 gen tf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.3 Plot src . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1 Mathematical equations - Inverse problem 1
1 X r − r0 i
Φ(r) = Pi · (1.1)
4πσ |r − r0 i |3
i
1 X r − r0 i
H(r) = Pi × (1.2)
4π |r − r0 i |3
i
where Φ is the electric potential, H is the magnetic field and σ is the electric
conductivity of the medium. Pi is the dipole moment associated with dipole
number i, and ri is the location of dipole i. This project report focuses only
on the magnetic field strength.
Now consider a N xN grid of sensors, equivalent with N 2 points in space.
The magnetic field at each sensor can be mapped to a sensor vector y with
3N 2 elements. There are 3 degrees of freedom (the magnetic field is a three
dimensional vector quantity) associated with each sensor. In the same way
the dipole sources can be mapped to a source vector g with 3M 2 elements,
since each dipole is described by a dipole moment vector. Equation (1.2)
1 Mathematical equations - Inverse problem 2
y = Fg (1.3)
y = Fg (2.1)
T T
F y = F Fg (2.2)
T −1 T
(F F) F y=g (2.3)
The top half of figure 3 shows the source magnitudes, and the bottom
half plots all the values of gest compared to the true value g. As we can see
the reconstructed solution matches the actual solution perfectly. Although
this seems like a good result, it is important to have in mind that these
are not realisitic conditions. First of all the model sources and sensors are
too simple, and more importantly in real life conditions there will always be
2 Inverse solutions with N = 10 and M = 8 5
some noise present. As will be shown, even low amounts of noise can render
eq 2.3 useless.
F = UΣVT (2.5)
This basically means that the algorithm searches for the lowest norm solution
gest that satisfies eq (1.3) the best. The singular values of F are shown in
figure 5, and only the 47 (t = 47) first singular values are kept to solve the
inverse problem. Deciding on how many singular values to keep is important
to the quality of the inverse solution, and will be discussed in more detail
later. However from figure 5 it is seen that singular values 48 and above
are fairly low, and it seems reasonable that we have captured most of the
dynamics present in F.
The solution using the TSVD algorithm is shown in figure 6. The recon-
structed solution with 10% additive noise is far from perfect, but we are at
least now able to see that there probably is one source in the top right and
one in the bottom left corner. The estimated sources are now distributed
over more locations in space than what is actually the case. While the ideal
solution has two distinct sources with large amplitudes, they are now recon-
structed as several distributed sources with smaller amplitudes. The spatial
resolution of the estimated solution gest is not good enough to distinguish
the two sources from their neighbours. However compared to the noisy re-
sult generated with the pseudoinverse, the TSVD result is clearly superior.
After all we are now getting two areas of activity, centered at the positions
of the true sources.
2 Inverse solutions with N = 10 and M = 8 7
It is seen that the reconstructed solution without noise is still very good.
The solution is no longer perfect as it was when we had more measurements
than unknowns, so the number of unknowns clearly affects the possibility
we have to find a good estimate gest . Basically we are now trying to solve a
problem with more degrees of freedom with the same amount of information,
so there is no surprise that the solution has worsened. All in all however,
the result is very good.
results have gone from being near perfect to moderatly inaccurate. When
compared to the noisy results with M = 8, the amplitudes of the true
sources are now lower compared to the “false” sources being generated. It
has become more difficult to distinguish between areas with high and low
activity.
4 Tikhonov regularization 10
4 Tikhonov regularization
So far, the only method used to solve the inverse problem has been the
truncated singular value decomposition. Another commonly used method
is called Tikhonov regularization. The Tikhonov regularization algorithm
solves the following optimization problem:
This λ0 value was used to create the reconstructed sources of figure 10.
4 Tikhonov regularization 11
The results are quite similar to the TSVD results in figure 6, however the
Tikhonov solution does a slightly better job of supressing sources that are
not there.
5 Discussion
5.1 M = 8 compared to M = 12
With M = 8 the linear system consists of 300 equations and 192 unknown
parameters. This means that the equation system (if there is no noise)
contains redundant information. This is referred to as a overdetermined
problem. With M = 12 we have still have a system of 300 equations, but
432 parameters. This means that there exists infinitly many solutions. This
makes it harder to generate good results since we do not have sufficient
information to solve the problem exactly. This is also seen in this project,
as even in the noiseless case we are not able to reconstruct the sources
perfectly in the underdetermined case. The more information we have the
better are the chances of generating good solutions to the inverse problem.
This is specially important when noise is present. However in a clinical
setting there is only room for a finite number of electrodes, this naturally
limits the number of equations in our system.
References
[1] Per Christian Hansen. Regularization tools manual book.
http://www2.imm.dtu.dk/ pch/Regutools/RTv4manual.pdf.
6 Matlab code 16
6 Matlab code
Note that the functions gen tf and gen tf inc are identical, except that M =
8 in gen tf and M = 12 in gen tf inc.
close all
clear all
[F,y,g,Src x,Src y,Src z]=gen tf();
%% Noiseless case
figure(3)
g noiseless = inv(F'*F)*F'*y;
subplot(2,1,1)
plot src(Src x,Src y,Src z,g noiseless);
title(['Reconstructed magnitude of source dipoles (no noise)']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g noiseless,'r');
legend('True source vector', 'Estimated source vector (pseudoinverse)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f3', ['figures/1b rec ideal'])
%% 10% noise
close all
y noisy=y+0.1.*y.*randn(size(y));
[U,s,V]=csvd(F);
figure(4);
plot(s,'r');
hold on;
title(['Singular values of F−matrix']);
xlabel('Singular value number');ylabel('Singular value');
line(47*ones(1,20),linspace(0.2,0,20))
text(20,0.3,'Cutoff at singular value number 47')
print('−depsc2','−zbuffer','−f4', ['figures/1c F'])
figure(5);
g tenp=tsvd(U,s,V,y noisy,47);
subplot(2,1,1)
plot src(Src x,Src y,Src z,g tenp);
title(['Reconstructed magnitude of source dipoles (10% noise, TSVD)']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g tenp,'r');
legend('True source vector', 'Estimated source vector (TSVD)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f5', ['figures/1c rec n'])
figure(10)
g inv = inv(F'*F)*F'* y noisy;
subplot(2,1,1)
plot src(Src x,Src y,Src z,g inv);
title(['Reconstructed magnitude of source dipoles (10% noise, pseudoinverse)']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g inv,'r');
legend('True source vector', 'Estimated source vector (pseudoinverse)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f10', ['figures/1c inv'])
%% Tikhonov
figure(6);
lambda=l curve(U,s,y noisy);
print('−depsc2','−zbuffer','−f6', ['figures/l curve'])
figure(7);
g tik=tikhonov(U,s,V,y noisy,lambda);
subplot(2,1,1)
plot src(Src x,Src y,Src z,g tik);
title(['Reconstructed magnitude of source dipoles (10% noise, tikhonov (corner value))']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g tik,'r');
legend('True source vector', 'Tikohnov (corner value)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f7', ['figures/tikh cor'])
figure(8);
g tik=tikhonov(U,s,V,y noisy,lambda*10);
subplot(2,1,1)
plot src(Src x,Src y,Src z,g tik);
title(['Reconstructed magnitude of source dipoles (10% noise, tikhonov (10 x corner value))']);
6 Matlab code 17
%% Noiseless case
figure(3)
[U,s,V]=csvd(F);
g noiseless=tsvd(U,s,V,y,298);
subplot(2,1,1)
plot src(Src x,Src y,Src z,g noiseless);
title(['Reconstructed magnitude of source dipoles M=12 (no noise, TSVD)']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g noiseless,'r');
legend('True source vector', 'Estimated source vector (TSVD)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f3', ['figures/1d rec ideal'])
%% 10% noise
close all
y noisy=y+0.1.*y.*randn(size(y));
figure(5);
g tenp=tsvd(U,s,V,y noisy,39);
subplot(2,1,1)
plot src(Src x,Src y,Src z,g tenp);
title(['Reconstructed magnitude of source dipoles (10% noise, TSVD)']);
xlabel('X−axis − Lateral');ylabel('Y−axis − Caudal');
subplot(2,1,2); plot(g,'−'); hold on; plot(g tenp,'r');
legend('True source vector', 'Estimated source vector (TSVD)')
ylabel('Dipole source vector values g(i)')
xlabel('i'); print('−depsc2','−zbuffer','−f5', ['figures/1d est'])
6.2 gen tf
clear all
z sensor=4; % Sensors 4 units superior to dipole sources
N=10;
M=8;
addpath('regu');
close all;
for i=1:3:size(F,1)
[v,u]=ind2sub(N,ceil(i/3));
x=Sen x(u,v);
y=Sen y(u,v);
z=Sen z(u,v);
for j=1:3:size(F,2)
src nmb=ceil(j/3);
[q,w]=ind2sub(M,src nmb);
R=sqrt((x−Src x(w,q))ˆ2+(y−Src y(w,q))ˆ2+(z−Src z(w,q))ˆ2);
d x=x−Src x(w,q);
d y=y−Src y(w,q);
d z=z−Src z(w,q);
F(i,j)=0;
F(i,j+1)=d z/Rˆ3;
F(i,j+2)=−d y/Rˆ3;
F(i+1,j)=−d z/Rˆ3;
F(i+1,j+1)=0;
F(i+1,j+2)=d x/Rˆ3;
F(i+2,j)=d y/Rˆ3;
F(i+2,j+1)=−d x/Rˆ3;
F(i+2,j+2)=0;
end
end
F=(1/4*pi)*F;
figure(1)
surf(Sen x,Sen y,Sen z,field)
hold on; grid on
quiver3(Src x,Src y,Src z,M x,M y,M z,2,'r');
plot3(Src x,Src y,Src z,'bo','MarkerSize',5);
[v,u]=ind2sub(M,Dipole1);
plot3(Src x(u,v),Src y(u,v),Src z(u,v),'r.','MarkerSize',17);
[v,u]=ind2sub(M,Dipole2);
plot3(Src x(u,v),Src y(u,v),Src z(u,v),'r.','MarkerSize',17);
title(['Magnetic field strength, generated by matrix equation: h=Fg']);
xlabel('X−axis − Lateral');zlabel('Z−axis − Anterior');
ylabel('Y−axis − Caudal');
view(37.5, 30);
print('−depsc2','−zbuffer','−f1', ['figures/1a pot']);
figure(2)
plot src(Src x,Src y,Src z,g);
title(['True magnitude of source dipoles']);
xlabel('X−axis − Lateral');zlabel('Z−axis − Anterior');
print('−depsc2','−zbuffer','−f2', ['figures/1a src mag']);
end