Package: py-dbar
pyDbar for Electrical Impedance TomographyThank you for the interest in pyDbar! This package implements the Dbar method for Electrical impedance tomography and follows up on the pyEIT presented inhttps://github.com/liubenyuan/pyEIT.1. OverviewThe D-bar method can be used for Electrical Impedance Tomography in a 2D framework. This method is based on the theoretical reconstruction procedure of Nachman and a regularizing strategy that was established by Siltanen and provides a natural framework for numerical implementation There is an implementation in Matlab available athttps://wiki.helsinki.fi/display/mathstatHenkilokunta/EIT+with+the+D-bar+method%3A+discontinuous+heart-and-lungs+phantom.For now we will keep things simple and a proper documentation will follow.2. InstalationTo install this package it is enough to use pip:pip install py-dbar.Moreover, dependencies are handled by pip.3. To start off:Test cases are present in the tests folder. Soon, there will be a presentation here of the output.4. Algorithm ReviewHere we explain the main steps of the Dbar algorithm with either direct numerical implementation or with theoretical motivation.Dirichlet-to-Neumann mapThe first step in EIT is to apply currents on a finite set of electrodes around the boundary and measure the corresponding voltages obtained thereafter. LetLbe the number of electrodes, then we can apply at mostL-1linearly independent current patterns (by current pattern we designate a vector of lenghtLthat describes the values of current applied in the electrodes). We designate byCnthe n-th current pattern. There are a few choices that can be considered for current patterns, but for now we fix our focus in two. Forn=1,..., L-1we have:Adjacent current patterns:Trignometric current patterns:The corresponding voltages are denoted byVnand each of them is a vector of dimensionL(corresponding to the set of electrodes). One of the required assumptions is that for each current pattern the sum of the measured voltages equals zero.
We assume that an EIT device provides the data in this manner.For our algorithm we create a mapping from this data: Dirichlet-to-Neumman map, which establishes a relation between the Dirichlet boundary conditions (voltages) and the Neumann boundary conditions (currents) in conductivity model.How to obtain the Dirichlet-to-Neumann map (DtoN map)?Normalize the measurements:cn= Cn/||Cn||2andvn= Vn/||Cn||2Define the Neumann-to-Dirichlet map (inverse of DtoN map), which is a L-1 x L-1 matrix:Compute the matrix approximation of Dirichlet-to-Neumann map for electrodes of AreaAand a body of radiusr:This mapping is the matrix approximation of the continuum operator for a body with conductivity γ.Furthermore, the Dbar algorthm requires either the DtoN map of a body with the same geometry but with conductivity 1 or a reference DtoN map that corresponds to the same body with a different physiology (e.g. expiration and inspiration). This last case is designated bytdEITand is very useful when monitoring health conditions that change with time like air ventilation in the lungs. With this in mind, theread_data classwas constructed to compute one DtoN map from one set of current patterns and corresponding measured voltages.Scattering TransformThe second step of the algorithm is to compute the scattering transform. This transform is of non-physical nature, i.e. has no physical explanation, but is tightly connect with the the conductivity and can be determined by the Dirichlet-to-Neumann map. It is given in the new spectral parameterkin the following manner:Now due to the ill-posedness of the inverse problem, the noise in the measurements highly affects the values oftfor large|k|. The regularization strategy proven by Siltanen shows that we only need to compute the following approximation for the scattering transform:The beauty of this regularization strategy lies in a finite discretization ofkinside a disk of radiusRbeing required. The choice ofRdependends in an estimate of the noise present in the measurements.To completely understand the computation of the scattering transform we need to obtainψat the boundary. Nachman's was able to prove that the values of ψ at the boundary can be determined by the solution of a boundary integral equation fork ∈ ℂ \ {0}:However, this equation takes a lot of time to solve, thus for speedup purposes we choose an approximate solution. We can have two approaches:Solve the boundary integral equation withS0substitutingSkand with the following definition:This approach is present in [2].Takeψ≃ eikz, since this is the leading behavior and do not solve any integral equation.
This is the fastest way, but its triviality leads to more errors.Now the last step is to solve the Dbar equation, which gives the name to the algorithm.D-bar equationNow, having computed the scattering transform or an approximation of it, we are able to solve the following PDE in thekvariable:Afterwards, we can determine the conductivity by:.By substituting the scattering transform by its approximations and solving the equation with respect to it we obtain respective approximations to the conductivity.5. Numerical ImplementationAbove, we present an immediate numerical implementation of the Dirichlet-to-Neumann map that trivially translates to code and a theoretical implementation of the regularization strategy for the D-bar and corresponding determination of the conductivity. Accordingly, we present the numerical implementation for both versions of the scattering transform and the solution to the Dbar equation.t-exp Scattering transform:The t-exp scattering transform corresponds to take the exponential approximation of ψ, which has the following form:Let us consider that we have equally distributed electrodes around the boundary. By our assumption of Ω being a disc we define, without loss of generality, the positions of the electrodes to bewhere.From this, we can take an approximation of the exponentials in these set points as an expansion in the orthonormal basis of current pattern (L-1degrees of freedom):.By immediate substitution and approximation of the integral at the electrode points this leads too:.t-B Scattering Transform:Here the first step is to solve the boundary integral equation withS0. For such we consider an initial vector approximationψBof the solution of the (continuous) boundary integral equation and take the expansion in terms of the orthonormal current patterns:.Further, we also take aLxLmatrix approximation ofG0that defines theS0operator as:.Through this matrix approximation, we can translate the boundary integral equation into a linear system of equations. DefiningΦto be the current pattern matrix (L x L-1) leads us too:,To compute the scattering transform we need to solve the last system of equations for eachkin a disk of radiusR. Afterwards, we compute it by:,where δL is the difference between Lγand L1.A more in depth look at the details can be found in [1] with respect to the solution of the boundary integral equation withSk.D-bar Equation:Now we have to solve the D-bar equation in thek-variable. This is the essence of this new spectral parameter, it allows for the reconstruction of the conductivity without iterative solutions of an FEM model of conductivity.
Although, we do not solve the PDE directly... we pass it to an integral equation and use Fourier Transform after discretization to solve the linear system of equations.Integral Equation:Solve for each z∈Ω:Recall that, the regularization procedure establishes that for|k|>Rthe scattering transform is0, in both cases. Hence, the integral can be taken in the disk of radiusR. To practically solve this equation we need to deal with the singularity properly. A fast approach to solve the equation is to transform it into a periodic setting (initial idea was by Vainikko, [3], and adapted to the Dbar equation in [4]). Letbe the fundamental solution of the D-bar operator. First, we write the integral equation in convolution terms:The periodization is done by tiling thek-planewith a square Q=[-2R-3ε, 2R + 3ε]2for some ε>0, in this manner, Q containes the disk of radius 2R. Now, we take a smooth cut-off function η which fulfils η(k)=1 for |k|<2R+ε and η(k)=0 for |k|>2R+2ε. With this we define the periodic approximate green function.In this framework we have the periodic version of the integral D-bar equation given by:where ⋆ denotes periodic convolution and TRis the defined as T for |k|<R and 0 otherwise. The interesting part is that the solution of this equation and of the full equation coincide in |k|<R, which is what we desire.By discretizing thek-planeinto an equally spaced grid with steph, the periodic convolution can be computed efficiently by Fast Fourier transforms and we obtain the following system of equations:where the boldface notation represents the matrices formed by evaluation of the functions in thek-gridand ⋅ represents matrix multiplication. This equation can be written in a simpler form, which will be helpful to describe our code below:.Since μRis inside the Fourier transform, we can not describe this system through the simple form Ax=b. Hence, the system of equations lends itself well to a solution by a matrix-free iterative solver like theGMRES.Due to conjugation on μRthe equation is ℝ-linear and separation of the real and imaginary parts, which is done by justposition of the real and imaginary parts into a vector. Further details, can be seen in [1].This is what we need for implementation and it provides a framework for the code we present in this package. A description of each class and function and its role is presented next.6. Documentation:Here, we provide an overview of each class and examples of usage. Our package possesses three classes:sim, read_data, k_grid, scattering, dBar.The first three classes are independent and concern the input information and framework. The fourth connects the gather data into a single operator, which is transmitted to thedBarclass. This class is dependent of both the scattering and k_grid and performs the solver.sim classclass sim(anomaly, L)This class is a simulator of voltages obtained through the FEM-solution of the Direct problem. We can create the conductivity of a body in a disk and then solve the direct problem for this conductivity by applying pair-wise adjacent current patterns (as described above). Thereafter, we can determine the voltage at the electrode positions and hence create the necessary data to apply an inversion procedure.This class is based solely on pyEIT.Parameters:anomaly: listBy assumption we have that the background conductivity is equal to 1. Then we can create disk anomalies by selecting the center, radius and the conductivity of the region.L: intNumber of electrodes.Attributes:Current: (L-1, L)Matrix with the currents patterns applied to the body.Voltage: (L-1, L)Matrix with the "measured" voltages obtained to sucessive FEM-solutions of the direct problem.Methods:simulate():This function uses each of the adjacent pair current patterns, solves the direct problem by FEM, and determines the voltages at the electrodes.read_data classclass read_data(Object, r, AE, L)Defines the Dirichlet-to-Neumann matrix approximation from the experimental data: electrical measurements, radius of the body, area of electrode and number of electrodes.
The current version only holds for circular domains and for objects which have conductivity equal to 1 near the boundary.Parameters:Current: (L-1, L) 2darrayMatrix of current patterns. Each line is a current pattern.Voltage: (L-1, L) 2darrayMatrix of voltage measurements. Each line corresponds to the current pattern on the same line of the current matrix.r: floatRadius of the body;AE: floatArea of one electrode;L: intNumber of electrodes;Attributes:Current: (L, L-1) 2darrayMatrix of the normalized current patterns, each column represents one normalized current pattern;Voltage: (L, L-1) 2darrayMatrix of the normalized voltages, where the i-th column represents the voltages measured for the i-th current pattern;DNmap: (L-1, L-1) 2darrayMatrix approximation of Dirichlet-to-Neumann map for the measured data.Methods:load():This function starts by performing the normalization of the current and voltage measurements and thereafter computes the Dirichlet-to-Neumann as described above. It is called directly from the constructor and the user does need to use it directly.Examples:k_grid classclass k_grid(R, m)Definition of the grid discretization of thek-planewith respect to the parametersRandm. As required by the periodic discrete convolution, the grid is defined in [-2.3R, 2.3R]^2 with step size h=2(2.3R)/2m.Parameters:R: floatDefines the size of the k gridm: intDefines the step size.Attributes:R: floatAs the parameter.m: intAs the parameter.s: floatIt is defined as 2.3R, to simplify definitions further ahead.h: floatStep size of the k grid.N: intIt is defined as 2m. Therefore, it is the number of elements on each line of the grid.k: (N, N) complex 2darrayComplex values of the k_grid. Essential for complex-valued computations. This grid contains the value0.pos_x, pos_y: array_likeArrays that store the indexes of the elements ofkwhich are inside the disk of radiusR.index: intRepresents the position of zero.FG: (N, N) complex 1darrayThe fundamental solutionof the D-bar operator, with the same structure ofk.Methods:generate():Defines the complex k-gridkand determines the positions inside the disk of radius R.Green_FS():Defines the FFT of fundamental solutionFG. Recall that we perform a periodization of the convolution equation and therefore we need to establish a smooth decay to 0 close to the square limits of the grid.scattering classclass scattering(scat_type, k_grid, Now, Ref):Parameters:scat_type: stringAllows to choose between the approximations of the scattering transform. Choices: "partial", "exp"!.k_grid: ObjectAn object of k_grid type.Now, Ref: ObjectsObjects of read_data type (we require the DN map for our body of choice and an homogeneous/reference body).Attributes:tK: (k_grid.N, k_grid.N) complex 2darrayMatrix containing the values of an intermediare operator containing information about the DN map of our body of choice. Essential for the Dbar method.Methods:load_scattering(scat_type, k_grid, Now, Ref):Given the choice of approximation for the scattering transform this function selects between two functions: one compute the exponential aproximation, another computes the partial approximation;exp_scattering(Now, Ref, k_grid):Computes the exponential approximation of the scattering transform.partial_scattering(Now, Ref, k_grid):Computes the partial approximation of the scattering transform.dBar classclass dBar(R_z, m_z)Parameters:R_z: floatDefines the size of the z-grid.m_z: intDefines the step size of the z-grid.Attributes:Z: (2m_z, 2m_z) complex 2darrayPlanar region of the body.sigma: (2m_z, 2m_z) complex 2darrayConductivity values at the points of the Z-plane grid.Methods:load_mesh(R, m):Defines the complex z-gridZ.dBar(mu, k_grid, tK, zz):Defines the operator [I +P] for azzelement of the z-grid, which is the left-hand side of the Dbar system. It takes as input the vector μ which is a 1darray that contains the real part concatenated with the imaginary part. We assume μ is 0 outside the disk of radius R, for speed-up purposes, however this is not a constraint since the scattering transform would cut-off this terms when defining the operator.solve(k_grid, tK):Solve for eachzon the z-grid the Dbar system withGMRES. We use thedBarfunction to define the [I+P] operator for eachzand use the initial approximation ofmubeing close to1to start off. After solving the system, we store the value of the conductivity throughγ(z)=(μ(z,0))^2.plot():Plot the obtained conductivity on the respective Z grid.6. Bibliography:[1] Mueller, J. L., & Siltanen, S. (2020). The d-bar method for electrical impedance tomographyâ€”demystified. Inverse problems, 36(9), 093001.[2] El Arwadi, T., & Sayah, T. (2021). A new regularization of the D-bar method with complex conductivity. Complex Variables and Elliptic Equations, 66(5), 826-842.[3] Vainikko, G. (2000). Fast solvers of the Lippmann-Schwinger equation. In Direct and inverse problems of mathematical physics (pp. 423-440). Springer, Boston, MA.[4] Knudsen, K., Mueller, J., & Siltanen, S. (2004). Numerical solution method for the dbar-equation in the plane. Journal of Computational Physics, 198(2), 500-517.