Innovative Differential Magnetic Localization Method for Capsule Endoscopy to Prevent Interference Caused by the Geomagnetic Field

. Wireless capsule endoscopy is an established medical application for the examination of the gastrointestinal tract. However, the robust and precise localization of these capsules is still in need of further scientiﬁc investigation. This paper presents an innovative differential magnetic lo- 5 calization method for capsule endoscopy to prevent interference caused by the geomagnetic ﬁeld. The effect of changing the orientation of the capsule on the localization process was also examined. Simulations using COMSOL Multiphysics with the superimposed geomagnetic ﬁeld were performed. 10 The Levenberg–Marquardt algorithm was applied in MATLAB to estimate the position and orientation of the capsule. Comparing the proposed differential method with the absolute magnetic localization method under ideal conditions, the mean position and orientation errors were reduced by three 15 orders in magnitude to less than from 0.1 mm and 0.1 ° re-spectively. Even if sensor non-idealities are considered, the proposed method is competitive with state-of-the-art geomagnetic compensation methods for static magnetic localization of capsule endoscopes. The achieved localization ac- 20 curacy by applying the differential method is not dependent on the rotation of the localization system relative to the geomagnetic ﬂux density under the made assumptions and the impact of the magnet orientation is neglectable. It is concluded that the proposed method is capable of preventing all 25 interference whose components are approximately equal at all sensors with identical orientation.


Introduction
Wireless Capsule Endoscopy (WCE) is a promising medical procedure to aid in the diagnosis of gastrointestinal disor-30 ders. For this purpose, the precise tracking of the position and orientation of the capsule while it moves through the gastrointestinal tract is essential. Although WCE has been a research topic for more than 20 years, there is still no reliable method for the precise localization of endoscopy cap-35 sules (Iddan et al., 2000;Swain et al., 1997).
The most feasible methods for the localization of a capsule endoscope are the radio-frequency-, video-and magneticfield-based methods. The latter method shows the best localization performance and is therefore of particular interest 40 among researchers. (Mateen et al., 2017;Bianchi et al., 2019) Several approaches for the magnetic localization of a capsule endoscope using an integrated permanent magnet and an external sensor array have been proposed by Wang et al. (2019), Shao et al. (2019), Muzaffer and Muhammed (2019), 45 Hu et al. (2016) and Pham and Aziz (2014). In these approaches, the magnetic flux density generated by the magnet is measured at each sensor and the position and orientation of the capsule is reconstructed by solving a non-linear equation system based on the differences between the measured and 50 the analytically predicted values at the sensors.
However, at the body surface, the magnetic flux density of a permanent magnet embedded in a capsule is of the same magnitude as the geomagnetic field, which was confirmed in our previous study (Zeising et al. (2020b)). To 55 compensate this interference in the context of static magnetic localization, there are two different approaches: static and dynamic geomagnetic compensation methods. The former method was investigated by Pham and Aziz (2014) as well as Hu et al. (2016). They concluded that magnetic sen-60 sors used for localization could be calibrated to prevent such interference. However, this holds true only if the orientation of the sensor array, relative to the geomagnetic field, does not change. Since diagnosis with capsule endoscopy takes several hours, it is most likely that the patient will move during the procedure. Therefore, accurate calibration cannot be ensured over the duration of that procedure.
Dynamic geomagnetic compensation approaches for static 5 magnetic localization of capsule endoscopes were proposed by Shao et al. (2019) and Dai et al. (2019). Shao et al. (2019) proposed a localization method for WCE that used two additional sensors. The additional sensors were a known distance from the sensor array, therefore, interference caused by the geomagnetic field could be reduced by subtracting the measured values of the additional sensors from the measured values of the sensor array. However, especially the orientation error varied significantly with the rotation of the setup. Dai et al. (2019) added an inertial sensor to the magnetic 15 sensor array. With this approach, the rotation-variant components of the geomagnetic flux density could be separated from the measured values of the permanent magnet. Inertial sensors are prone to drift error over time, since the average duration of a diagnosis with WCE is around 8 hours, it is very 20 challenging to apply this method on a wearable localization system. To overcome these limitations, this study proposes an innovative differential magnetic method for a wearable localization system for capsule endoscopy that prevents interfer-25 ence from the geomagnetic field, which is not dependent on time and rotation relative to the geomagnetic flux density.

Magnetic dipole model and geomagnetic field
A permanent magnet is assumed with length l, radius k and magnetization M 0 in ampere per meter, located at P mag ( Fig.   30 1). At an observer point P obs , the magnet generates a magnetic flux density B mag (P obs ) in tesla. If the (Euclidean) distance R , with R = P obs − P mag , between the magnet and the observer is much larger than the geometry of the magnet (i. e., l and k), the magnetic dipole model can be applied, 35 according to Jackson (1962), Here, H 0 is the normalized orientation vector of the permanent magnet. The magnetic permeability in vacuum is µ 0 = 4π × 10 −7 V s A −1 m −1 and the relative permeability µ r of human tissue is ≈ 1 according to Glaser (2000).
In the proposed simulations, B of the magnet was superimposed by the geomagnetic flux density B geo Erlangen, Germany, with the x-(north), y-(west), and z-(vertical) components approx. (20.2, −1.2, −44.5) µT resulting in an 45 absolute value of 48.8 µT with reference to NOAA National Centers for Environmental Information (Fig. 1). All considerations in this paper are based on this reference coordinate system.
Bgeo y (west) Figure 1. Localization scenario of a permanent magnet; the reference coordinate system is depicted. The geomagnetic field Bgeo is interfering.

Sensor setup and localization method
To estimate position and orientation errors, our previous localization setup (Zeising et al. (2020b)) was used. Three identical, stable and elliptical rings (40 cm × 33 cm) were assumed with four magnetic sensors mounted on each ring 55 (Fig. 2). The distance between one ring to another was 10 cm. The length and diameter of the permanent magnet were both 10 mm. The magnetization of the magnet M 0 was set to 1140 kA/m along the longitudinal axis of the magnet, corresponding to grade N52 neodymium-iron-boron (NdFeB). The localization setup was simulated in COMSOL Multiphysics ® . Fig. 3 depicts the simulation setup for the proposed differential localization method. As computational domain, a sphere with radius 800 mm, filled with air, was set around the sensor setup. As boundary condition of the computational domain, magnetic insulation (B · n = 0) was applied. The size of the computational domain was determined by convergence tests with respect to the position and orientation errors as well as the magnetic field distribution (Zeising et al. (2020c)). The given radius was found to be sufficiently large to avoid distortions as arose in a previous study (Zeising et al. (2020a)). In the following,B and B indicate the measured and analytical magnetic flux density, respectively. 15 To estimate the position (a, b, c) and orientation (m, n, p) of the magnet, for each sensor, the three respective components of the measuredB i were subtracted from those of the analytical B i leading to three non-linear equations per sensor. Thus, a 36 × 6 equation system was derived, which was 20 solved by minimizing the error function

Absolute method
by applying the Levenberg-Marquardt (LM) algorithm in MATLAB based on the work of Levenberg (1944) and Marquardt (1963). The components of the starting vector of the 25 LM algorithm x = (a, b, c, m, n, p) were set to zero.

Differential method
The proposed differential method is derived from the wellestablished approach for common-mode rejection in electromagnetic compatibility. For the differential method, the sen-30 sors were divided into sensor pairs, each consisting of two opposite sensors (e. g. sensors 1, 2 and 3, 4 in Fig. 4). The two measured valuesB i of these pairs were vectorially subtracted before the LM algorithm was applied. In the simulations, it was assumed that the coordinate systems of the individual 35 sensors had the same orientation as the reference coordinate system. This means that sensors, corresponding to a pair, are aligned in such a way that their normal vectors S ni have the same direction and no rotation of the sensors concerning S ni is conducted during the localization process. Consequently, the three components of B geo were equal at two sensors and, by applying the differential method, canceled out. As each sensor yields three non-linear equations, subtracting the equations from those of the respective opposite sensor reduces the dimension of the equation system by 45 a factor of two. This operation is valid because the system is over-determined.

Position and orientation errors
The final solution vector x was used to calculate the position P and orientation O errors which are defined as where P is the distance from the true position P mag of the magnet to the estimated positionP mag . Moreover, O is the angle between H 0 of the magnet and the estimatedĤ 0 .

Comparison between absolute and differential method
To evaluate the localization performance, the position of the magnet was set to (60, 60, 60) mm. To investigate the robustness of the absolute and differential methods, the complete setup was rotated around the x-, yand zaxes of the reference coordinate system by the corresponding angles α, β and γ (Fig. 2). For the initial orientation (α = 0°, β = 0°, γ = 0°) the geomagnetic flux density according to Sec. 2 was considered. To cover various body positions and orientations in daily life, the rotation angles were varied from −90°to 90°in steps of 15°(while the other two angles were 0°) leading to components of B geo , which are dependent on the rotation angles. Furthermore, four different orientations (Tab. 1) of the magnet were applied on each 15 rotation case, leading to 12 different localization scenarios. First, for each scenario, the mean values µ P/O, α/β/γ, i of the where i denotes the four orientations of the magnet and j is the variable for the respective rotation angle. Subsequently, the mean and STD values of the position 25 and orientation errors for the four applied orientation cases were calculated for each of the three rotations according to 3.3 Evaluation of the impact of sensor non-idealities on 30 the differential method The proposed differential static magnetic localization method was evaluated under ideal conditions (sensor proper-ties like gain were not considered). Therefore, sensors which are equally aligned would measure the exact same magnetic 35 flux density. When the differential method is applied on a real localization system, these non-idealities would lead to fluctuation in the measured flux density, which is not equal for different sensors. To investigate the impact of such nonidealities of the sensors and their calibration on the local-40 ization accuracy of the proposed differential method, uniformly distributed random values forB with absolute maximum values ranging from 30 nT to 5000 nT for the x-, yand z-components of the measured values at each sensor were added and the evaluation procedure was the same as 45 described in Sec. 3.2.
4 Results and discussion 4.1 Comparison of absolute and differential static magnetic localization method In Fig. 5, the respective mean values and standard deviation 50 (STD) of P and O for the three different rotations of the whole localization system are shown for the absolute and differential method in logarithmic scale. The first essential finding of this study is that the position and orientation errors were reduced from at least 20 mm 55 and 10°, respectively, with the absolute method to less than 0.1 mm and 0.1°, respectively, with the differential method. Second, the localization accuracy was not dependent on the different rotations for the differential method, which is especially required for a wearable localization system. Further-60 more, the STD of the position and orientation errors were reduced by two orders of magnitude. Therefore, the impact of the magnet orientation on the localization performance was significantly reduced by applying the differential method.
Tab. 2 shows the P and O for the four different orienta-65 tions of the magnet after applying the differential method. The position error was greatest when the magnet was in 1 √ 3 (1, 1, 1) -orientation with 0.14 mm, whereas it was smallest for x-orientation with 0.01 mm. The mean value and STD for the position error were 0.05 ± 0.05 mm. For all four ap-70 plied orientations of the magnet, the orientation errors were not greater than 0.07°. The orientation error was the smallest with 0.01°when the magnet was in z-orientation. The mean value and STD for the orientation error were 0.05 ± 0.02°.
By applying the absolute method, the STD values revealed 75 that the variation of the orientation of the magnet had a significant impact on the position and orientation errors for the respective rotations. This was due to the large difference of 64.7 µT in amplitude between the xand z-components of B geo , compared with the differences for the xand ycomponents and yand z-components which are 21.4 µT and 45.7 µT, respectively. The errors were smallest when the setup was rotated around the body axis γ, whereas they were

Rotations
Mean orientation error in°F igure 5. Comparison of the position and orientation errors by applying the differential and absolute static magnetic localization method on the proposed sensor setup. The y-axis shows the errors in logarithmic scale and the x the three different rotations of the whole sensor setup, respectively. By applying the differential method, the position and orientation errors were reduced by three orders of magnitude and the errors were constant for the different rotations.
greatest for a rotation around β (i. e. in forward/backward di-5 rection). This trend was also observed in the STD values. These results, especially the STD of the errors, demonstrate that the orientation vector H 0 of the magnet affects the localization process. Compared with the results of the absolute method, the impact of H 0 was significantly reduced by 10 applying the differential method and the mean position and orientation errors were reduced by three orders of magnitude.
4.2 Results for applying random values on the measurements of the differential method Fig. 6 shows the mean values and STD for the position and 15 orientation errors after applying random magnetic flux densities on the three components of the measuredB. Here, the y-axis is in logarithmic scale and the x-axis in linear scale. As can be seen, the errors increased with higher ran-dom values in a close-to-exponential way. For random values 20 up to 500 nT (which is the root-mean-square (RMS) noise value of state-of-the-art magnetometers like the LSM303D), the position and orientation errors were less than 1 mm and 1°, respectively. For a random value of 5000 nT, the position and orientation errors reached approximately 10 mm and 25 4,°respectively.

Comparison to existing methods
Shao et al. (2019) proposed a method for preventing interference caused by the geomagnetic flux density. Here, two additional sensors were added to the localization system and 30 mounted on the chest and back of a patient. By subtracting the measured values at the additional sensors from those of the sensor array, geomagnetic compensation was achieved.
In their experiments, the mean position and orientation errors were 10 mm and 12°, respectively. However, additional 35 sensors that are not part of the localization setup make the system more prone to sensor misalignment and displacement of the sensors because they are mounted on the chest and back of a subject. Thus, the relative position regarding the coordinate system of the sensor array is not stable, and the 40 orientation of the additional sensors can vary significantly (e. g. during breathing) from those of the sensor array. In addition, in their study, the orientation error varied significantly for several degrees for different rotations of the localization system.

5
Another dynamic approach for localization of capsule endoscopes with geomagnetic compensation was proposed by Dai et al. (2019). A magnetic sensor array with a mounted in- ertial sensor was established to localize a permanent magnet. The localization system was rotated during the localization 10 procedure and due to the additional measurements of the inertial sensor, the components of the geomagnetic flux density were separated for each rotation from the measured magnetic flux density generated by the permanent magnet. In their study, mean position and orientation errors of 3.89 mm and 15 5.5°, respectively, were experimentally achieved. A stability evaluation, in which the whole system was rotated while the permanent magnet position was fixed, of their proposed dynamic geomagnetic compensation method showed that a localization accuracy of approx. ±3 mm within a time pe-20 riod of 90 s was reached. They declared that the localization error would increase over time due to the drift error of the inertial sensor. By considering the average time interval of approx. 8 hours of a diagnosis procedure with WCE, this method should be tested within a longer time interval.

25
Without considering fluctuations in measured values due to sensor non-idealities, the mean position and orientation errors of the differential method proposed in this simulationbased study were significantly better with less than 0.1 mm and 0.1°, respectively. For a wearable localization system for 30 the WCE application, it is essential that the localization performance is invariant from the rotation of the system. Our results revealed that the localization performance is not dependent on time and the rotation of the localization system in case that sensors corresponding to a pair are equally aligned. 35 This highlights that the proposed system is a more favorable choice than state-of-the-art geomagnetic compensation methods for the localization of capsule endoscopes.
By applying random magnetic flux densities on the three components of the measured flux density, the position and 40 orientation errors increased. For a random value of 500 nT (RMS noise of LSM303D), the position and orientation errors were still below 1 mm and 1°. For a random value of 5000 nT, the position and orientation errors were approx. 10 mm and 4°, respectively. Therefore, our proposed differential static magnetic localization method is competitive with the methods proposed by Shao et al. (2019) and Dai et al. 5 (2019) also for non-ideal conditions.

Limitations and challenges of the proposed differential method
To ensure highly accurate and rotation-invariant localization of capsule endoscopes with the proposed differential static magnetic localization method, the sensor rings need to be mechanically stable to minimize possible displacement and misalignment of the magnetic sensors. Moreover, the sensor calibration for hard-and soft-magnetic distortion must be optimized in order to keep the fluctuation in the measured 15 magnetic flux density with respect to the orientation of the localization system as small as possible.

Conclusion
This paper introduced an innovative differential localization method for WCE to make the localization robust against in-20 terference of the geomagnetic flux density. Under the assumptions made, the geomagnetic flux density had no impact on the proposed method. Compared to the absolute magnetic localization method, the position and orientation errors were reduced by three orders of magnitude to less 25 than 0.1 mm and 0.1°under ideal conditions. When the rootmean-square noise of state-of-the-art magnetometers like the LSM303D was considered, the position and orientation errors were below 1 mm and 1°, respectively. Therefore, the proposed method is competitive with state-of-the-art geo-30 magnetic compensation methods, even under non-ideal conditions. Furthermore, the impact of the orientation of the magnet was significantly reduced as suggested by the values of the standard deviation concerning the four different orientations of the magnet. For a realization of the proposed 35 method, the sensor rings should be mechanically stable and sensors corresponding to a pair aligned in order to ensure appropriate localization accuracy with respect to the rotation of the system relative to the geomagnetic flux density. The impact of misalignment and displacement of sensors as well as 40 the impact of ferromagnetic material on the proposed method requires further investigations. Moreover, the sensor calibration for hard-and soft-magnetic distortion must be optimized to achieve accurate localization with the proposed differential method. In the future, the localization system will be 45 tested by means of experimental measurements.
Code and data availability. The simulation data and MATLABcode are available from the corresponding author upon request.
Author contributions. DA, GF and JK initiated the research project. SZ developed the method. SZ and AT carried out the simulations 50 and interpreted the results. All authors were involved in writing and reviewing the manuscript.
Competing interests. The authors declare that they have no conflict of interest.
Disclaimer. The responsibility for the content of this publication is 55 with the authors.