Abstract
Video Capsule Endoscope (VCE) sends images of abnormalities in the gastrointestinal (GI) tract. While the physicians receive these images, they have little idea of their exact location which is needed for proper treatment. The proposed localization system consists of a 3D antenna array (with 8 receiver sensors) and one transmitter embedded inside the electronic capsule. We propose an adaptive linearized method of localization using Weighted Centroid Localization (WCL) where the position is calculated by averaging the weighted sum of the reference positions. In our proposed system, first we identify the path loss attenuation exponents using linear least square regression of the collected data (RSSI versus distance). Then the path loss model is linearized to minimize the path loss deviation which is mainly caused due to the nonhomogeneous environment of radio propagation. Then the instantaneous path loss (PL) measured by the sensors is attenuated to the above linearized model and considered as the weight of the sensors to find the location of the capsule using WCL. Finally a calibration process is applied using linear least square regression. To assess the performance, we model the path loss and implement the algorithm in Matlab for 2,530 possible positions with a resolution of 1 mm. The results show that the algorithm achieves high localization accuracy compared with other related methods when simulated using a 3D small intestine model.
1. Introduction
Video capsule endoscopes (VCE) are used to diagnose lesions along digestive tracts. They send clear images of abnormalities in the gastrointestinal tract (GI tract). While the physicians receive the clear images of the abnormalities, they have little idea of their exact location [1]. Thus, it is necessary to know the exact location of the endoscopic capsule inside the GI tract for proper diagnosis of the intestinal abnormalities. The current literature is very rich in algorithms designed for localization outside the human body. Very few localization methods [2–4] are available in the literature to localize endoscopic capsule which are based on electromagnetic field and magnetic field strength. As RSSI based techniques are cost-effective and have no adverse health effects, they have also been chosen for use with the Smart pill capsule [5] in USA and the M2A capsule [6] in Israel.
RF localization schemes include both range-based [7–9] and range-free [10–17] algorithms. Within those, range-free positioning schemes, such as Centroid Localization schemes [10, 11], have attracted a lot of interests because of their simplicity and robustness to changes in wireless propagation properties such as path loss. Centroid Localization (CL) [10] localizes the transmitting source of a message to the coordinate obtained from averaging the coordinates of all receiving devices within range. Weighted Centroid Localization (WCL) [12] localizes the active tag as the weighted average of the sensors positions within its range. WCL proposed in [18] assigns a weight to each of the receiver coordinates, inversely proportional to either the known transmitter-receiver (T-R) distance or the link quality indicator available in the ZigBee/IEEE 802.15.4 sensor networks [19]. In [20, 21], the WCL mechanism is extended using normalized values of the link quality indicator and RSSI. The authors in [22] conducted an indoor experiment to determine a set of fixed parameters for an exponential inverse relation between
However, due to the lack of movement position map of the VCE and the channel models to relate the location to RF propagation, all of the above localization algorithms have not been verified for use inside the human body. Most of the available capsule localization systems are based on range-based techniques [24, 25]. Frisch et al. [24] proposed a 2D RF localization system using triangulation method to localize the in vivo signal using wearable external antenna array that measures signal strength of capsule transmissions at multiple points and uses this information to estimate the distance. The average experimental error is reported to be 37.7 mm [25]. In [26], the authors proposed an adaptive linearized method of 2D localization of the moving telemetry capsule using RSS based triangulation method. They reported an average error of about 25%. Based on the statistical implant path loss model developed in [27], the authors in [28, 29] use RSS based triangulation technique to analyze possible capsule localization accuracy at various organs in the GI tract. They reported average localization error 50 mm in all organs and more than 32 sensors on body surface are needed for achieving satisfying localization accuracy. Wang et al. [30] have developed the Cramer-Rao bound (CRB) calculation for single pill situation which quantifies the limits of localization accuracy with certain reference-points topology, implant path loss model, and number of pills in cooperation. In [31], the authors present a novel method and implementation of a high resolution localization system based on UHF band RFID. They propose a location estimation algorithm by calculating center of gravity of antennas which have detected the tag, and the results show a mean localization error of 2 cm.
In this paper, we focus on improving the localization accuracy of VCE localization inside the small intestine using an adaptive linearized method of Weighted Centroid Localization (WCL) algorithm. In our proposed WCL approach, the capsule transmits RF signal which is received by eight body mounted sensors. Then the path loss (PL) is calculated using the measured RSSI of the sensors and the weight of the sensors is calculated. Then finally the position of VCE is calculated using WCL algorithm. A major challenge in this approach lies in the shadow fading effect due to the nonhomogeneous environment inside the human body. Thus the same path loss cannot assure the same distance or the same weight for different surroundings. Therefore it is not appropriate that the weight is calculated using uniform path loss in the nonhomogeneous environment as human body. To address this issue, we calculate the statistics of the path loss model for different scenarios using the experimentally collected data sets (path loss versus distance) so as to identify more rational path loss attenuation exponents where the target stays and models the path loss for different scenarios. We observe that the path loss is scattered around a mean due to the random path loss deviations. To minimize the deviations, we linearize the model considering minimum deviations by fitting a least squares regression line through the scattered path loss such that the root mean square deviation of sample points about the regression line is minimized. Now, we use the attenuated path loss to calculate the weight of the sensors for VCE localization using WCL. As there is a linear relationship observed between the estimated and real positions, finally a calibration process has been applied using the linear relationship to find more accurate location of the VCE. We simulate our proposed adaptive linearized WCL algorithm using Matlab to verify the localization accuracy. The results show significant accuracy improvement in 3D position estimation inside the small intestine. As our path loss model has not been designed for implant communication, we verify the accuracy using the statistics of the implant path loss model [27] used for medical implant communication service (MICS) and observed the same accuracy in 3D location estimation.
2. System Overview
Figure 1 shows the system of localizing a capsule transmitting signal source inside the small intestine with a wearable antenna array of eight RF receivers. The system consists of a RF transmitter, 8 RF receiver modules, RSSI reader, and the data processing and localization tool. As RSSI is location dependent which is affected by factors such as distance from the transmitter and attenuates due to the medium of propagation, we consider the respective RSSI as a measure of the distance between Tx and Rx. The receivers receive the transmitted signal of the capsule and measure the corresponding received signal strength (RSSI). The measured RSSI is then sent to the CPU by the RSSI reader. Finally the RSSI is processed and the three-dimensional position of the capsule is calculated from the known coordinate sets of the receiver antennas.

Illustration of the localization system for VCE used in this work: a virtual 3D box around small intestine with 8 receiver nodes.
Figure 2 shows the system flow block diagram of our proposed system. The system may be subdivided into RF communication, RSSI reader, and data processing and localization subsystems.

System block diagram.
The RF communication system consists of the wireless endoscopic capsule embedded with a microcontroller operated RF transmitter module and eight RF receivers of the receiver array and the microcontrollers (MCUs) to operate and configure the transceivers. The RSSI reader consists of the microcontroller (MCU) and EEPROM. The MCU reads the measured RSSI from the SPI interface of the receivers and sends it to the data processing module (PC) through UART interface. Then the data is processed and the location of the capsule is estimated using the localization tool which may be developed using Matlab.
3. Radio Propagation Path Loss Model
The free space radio propagation model is used to predict received signal strength when the transmitter and receiver have a clear, unobstructed line of sight path between them. This free space power received by a receiver antenna which is separated from a transmitter antenna by a distance d is given by the free space equation
where
The signal propagation path loss for
For Medical Implant Communication Services (MICS), the transmitting antenna is considered to be part of the channel [27]. For the MICS channel, the path loss includes the transmitter antenna gain:
The received power can be expressed as
The received signal strength in dBm can simply be expressed as follows:
The most widely used path loss lognormal shadowing signal propagation model includes the path loss attenuations exponents which are different for different surroundings and varies due to the medium of propagation. The path loss in dB at some distance d can statistically be modeled by the following path loss lognormal shadowing equation:
4. Proposed Localization Algorithm
Weighted Centroid Localization (WCL) calculates the position of the target node using the sum of the weighted average of the reference nodes positions. WCL introduced the quantification of the nodes position depending on their distance to the target node. The aim is to give more influence to those nodes which are nearer to the target. The three-dimensional position of the target is calculated using WCL as follows:
where
4.1. Linear Least Square-WCL (LLS-WCL): A VCE Localization Approach
In our proposed VCE localization approach, we have used WCL algorithm to calculate the three-dimensional position of the VCE using the corresponding weight of the reference nodes and their known positions. Figure 3 demonstrates our proposed approach of WCL to localize the VCE where the red object indicates the target VCE and the blue tags indicate the reference nodes. The VCE is equipped with a RF transmitter tag. As shown in Figure 3, a 3D receiver array of 8 RF receiver (Rx) nodes has been used to localize the mobile VCE at

WCL algorithm.
where
Figure 4 shows the simulation results using WCL for 2530 sample positions of the VCE where we can observe that there occurs a linear relationship between the estimated and real positions. We can express the relation of the estimated and real position by the following equation:
where

Position estimation and calibration using LLS-WCL.
A major challenge in this approach of VCE localization is that the weight calculated using uniform path loss cannot assure the same distance for different surroundings in the nonhomogeneous environment as human body. As we can see from (6) the path loss attenuation exponents (
4.2. Adaptive Linearized LLS-WCL: An Improved Method of VCE Localization
The adaptive linearized LLS-WCL includes the following steps of improvements.
(1) Statistical Path Loss Modeling. The statistics of the path loss model for specific surroundings is adaptively identified using linear least square regression of the experimentally collected data sets.
(2) Path Loss Linearization. This step is to minimize the path loss deviations by linearizing the path loss model considering minimum deviations.
(3) Weight Calculation and Position Estimation. In this step, the weight of the sensors is calculated from the linearized path loss and the position is estimated using WCL algorithm.
(4) Position Calibration. The final step is to identify the calibration coefficient (C) using the linear relationship of the estimated and real locations and then to calibrate the estimated positions using C to improve the localization accuracy.
The steps are briefly explained below.
4.2.1. Statistical Path Loss Modeling
We use the lognormal shadowing signal propagation model (as shown in (6)) to model the path loss for two different scenarios assuming
The path loss may be modelled using two different methods. The first method requires experimental data sets (path loss for variable
Hence we follow the first method to model the path loss using our experimentally collected data sets (path loss versus distance) for two scenarios. We have also modelled the path loss using the statistics available in [27] for the MICS. The statistics (
We consider the signal propagation model of (11) as a linear system of equation in matrix form as follows:
where
Minimizing the sum of the squares of the residuals leads to a normal equation as follows:
Thus, we can calculate the path loss attenuation exponents (
4.2.2. Path Loss Linearization
Using the adaptively identified statistics (
where
4.2.3. Weight Calculation and Position Estimation
The scattered path loss is attenuated to the adaptively linearized path loss and then used to calculate the weight of the sensors using (16). Consider
where
Using the weight of the sensors and their reference positions, the VCE is localized using WCL as follows using (17) where the weight is calculated using adaptively linearized path loss. Consider
4.2.4. Estimated Position Calibration
We can observe from the simulation results of adative linearized WCL that there is a linear relationship between the estimated and real positions as shown in Figure 5 which can be written as a linear system of equation as in (18). Consider
where

Linear relationship between real and estimated position across x-y-z-axis (simulated 2,530 samples positions).
We can calculate C using linear least square regression of all estimated and real positions if (18) is considered as a linear system of equation in matrix form,
where
As
Thus, the coefficient C is calculated using all the estimated and real positions using (22) and then a calibration process is applied using (23) to find more accurate location of the VCE using adaptive linearized LLS-WCL. Consider
5. Experimental Methodologies and System Development
The methodology is divided into the following steps.
5.1. Development of the Test System
The test system has been developed to collect data using two different scenarios. By weight, human body constitutes of 45%–65% water [32–34]. As air and water have completely different properties of radio propagation, we have chosen to perform the radio propagation test for Air to Air and for Air to Water interface scenarios to confirm that different scenarios have influence on the path loss.
The measurement setup for data collection using scenarios 1 and 2 has been shown in Figures 6 and 7. For scenario 1, both the transmitter and receiver have been placed in air. For scenario 2, the transmitter has been placed in air and the receiver has been placed inside the water. The test system may be divided into RF communication and data collection subsystems. The RF communication part is similar to the RF communication part in Figure 2. To develop the RF communication part, we have used 2.4 GHz ISM band Transceiver Module (RFM70) and ARM Coxtex-M4 microcontrollers. Tranceivers are used to transmit and receive radio signals; and the MCU has been used to configure the transceivers and to read-write data. The data collection part consists of the UART interface of MCU and the PuTTY terminal software of PC.

Scenario 1: measurement setup for data collection using Air to Air interface.

Scenario 2: measurement setup for data collection using Air to Water interface.
The radio signal transmitted by the transmitter is received by the receiver and the RSSI is measured. If the transmitter position is changed, the RSSI thresholds change accordingly. For both scenarios, we have collected the RSSI data for variable
5.2. Data Collection
We collect the measured RSSI of the receivers for variable
Path loss versus Tx-Rx separation distances [for selected points].

Distance based path loss model obtained from the measured data (path loss versus distance).
5.3. Path Loss Modelling
The statistics of the path loss have been extracted in Table 2 using linear least square regression of the measured data using (14).
Extracted parameters using linear least square regression of the measured data.
As we can see from the extracted statistics, the parameters are different for different scenarios which is due to the radio propagation property of different mediums. As the radio propagation property of air and water is different, much higher value of the path loss exponent and path loss deviations has been observed for the Air to Water scenario. Higher value of path loss exponent is observed due to the lossy characteristics of water. The path loss is also more scattered due to the shadow fading effects of the Air to Water scenario which is caused due to the nonhomogeneous medium of propagation.
As the radio propagation parameters are different for different mediums, we can model the path loss statistically using the extracted parameters. By considering the normal distribution of the path loss deviations

Statistical model and path loss linearization.
Human body is a nonhomogeneous environment for radio propagation. Therefore, the path loss is not uniform. Thus, different values of the path loss attenuation exponents and deviations are expected for different scenarios. By adaptively identifying the statistics for different scenario or environment, we can model the path loss for different locations inside the human body. The extracted statistics for two different scenarios of MICS are available in [27] where a 3D visualization system for medical implants has been used to calculate the statistics of the path loss model. The main components of their simulation system include a three-dimensional virtual human body model, the propagation engine which is a three-dimensional full-wave electromagnetic field simulator (i.e., HFSS 1), the 3D immersive and visualization platform, and finally an implantable (or body surface) antenna. The 3D human body model includes frequency dependent dielectric properties of 300+ parts in a male human body which has a resolution of 2 mm. Table 3 summarizes the extracted parameters of their model. As we can see, the statistics are different for different scenarios and much higher values of the parameters are observed.
Extracted parameters of the statistical implant path loss model for two different scenarios.
Small intestine is a deep-tissue organ and its standard size is 140 mm

(a) Path loss versus distance for deep tissue implant to body surface scenario. (b) Normal distribution of the path loss deviation due to shadow fading effects of deep tissue implant to body surface.
5.4. Path Loss Linearization and Weight Calculation
The path loss is linearized by finding the linear least squares regression line through the scattered path loss that best fits the collected data. In Figures 9(a), 9(b), and 10, the straight line through the scattered path loss indicates the linearized path loss for Air to Air, Air to Water, and the deep tissue implant scenarios. To analyze the performance of adaptively linearized WCL, we find the straight line by replacing the extracted value of
Path loss linearization using the statistics of the path loss.
The weight of the sensors is calculated from the linearized path loss using (16). The relation of the weight factor (W) to the distance has been shown in Figure 11 where we can see that the weight decreases as a function of distance and it is not scattered as it has been calculated using linearized path loss where the deviations are minimized.

Weight versus distance for different scenarios.
5.5. Position Estimation and Calibration
Finally, the position of the target is calculated using WCL as shown in (17) and then calibrated using (23). We have used the calculated weights of the sensors and their reference positions to find the estimated position using WCL. As we can see in Figure 5 if we simulate the WCL algortithm to find the position of several points of small intestine in 1 mm resolution, then it is found that there is a linear relationship between the real and estimated positions. As there occurs a linear relationship, a calibration process may be applied where the calibration coefficient (C) is calcultaed using linear least square regression of the real and estimated positions using (22). The estimated position is then calibrated using (23) to find more accurate position. The calibration coefficient for different scenario has been summarized in Table 5. The results of position calibration have been shown in Figure 12 where the relationship of the real, estimated, and calibrated positions is presented. Thus, it is essential to extract the value of C for any specific scenario before localization. The blue scattered lines in the figure indicate the relation of the estimated position to the real positions whereas the red straight line indicates the calibrated location. We observe that the calibrated positions using adaptive linearized LLS-WCL are absolutely linear to the real position indicating the minimized location error.
Calibration coefficient calculated using linear least square regression.

Location estimation and calibration using adaptive linearized LLS-WCL and their relationships.
6. Simulation System
Due to practical limitations, as it is difficult to verify the accuracy of the proposed algorithm using a real human body, we have developed a simulation system using Matlab to verify the accuracy. The system includes a 3D virtual small intestine model, 8 receiver sensors, implanted transmitter, and the propagation engine. Figure 13 shows the overview of the 3D simulation system which includes the small intestine model of 140 mm

Simulation system overview.
The overall system flow of the simulation system as discussed above has been shown in the block diagram in Figure 14.

System flow block diagram.
7. Simulation Results and Analysis
To verify the accuracy of localization, we have simulated 2530 sample positions (1 mm resolution) of the capsule to find the estimated position using our proposed adaptive linearized LLS-WCL algorithm. The simulation system has been developed using Matlab. The estimated positions of selected seven sample positions are shown in Figure 15.

Localization results using adaptive linearized LLS-WCL.
The localization accuracy can be verified using the performance indices as localization error (LE), root mean square error (RMSE), and the standard deviation of error (STD) which are calculated as follows. Localization error (LE) is defined as the difference between estimated and real position as follows:
The standard deviation of error is expressed as
From Figure 14, it can be observed that the difference between the estimated and real position is very small. Table 6 summarizes the location estimation results for 2,530 simulated points and verifies the accuracy by finding the performance indices. As we can see from the results the root mean square error (RMSE) of localization is as low as 5.106 mm with standard deviation 3.5 mm.
Adaptive linearized LLS-WCL simulation results.
We have also simulated the proposed algorithm using different scenarios and compared the results. Table 7 presents the results of different optimization stages and summarizes the accuracy improvement. It is observed that localization accuracy significantly improves using the adaptively linearized method of LLS-WCL algorithm. As we can see from the different stages of optimization in Table 7, the mean localization error (RMSE) is as high as 157.3 mm using RSSI based WCL algorithm without considering any optimization levels. If we estimate the position using scattered path loss based LLS-WCL using linear least square calibration where the deviations have not been minimized
Different stage of optimization and performance comparison of the adaptively linearized LLS-WCL algorithm.

Comparison of the localization accuracy of adaptive linearized LLS-WCL in different stage of optimizations (plotted using the simulated results for 2530 sample target positions in 1 mm resolution).
Table 8 compares our path loss based LLS-WCL approach with other previously proposed approaches. The authors in [24] proposed a 2D RF localization system using RSSI based triangulation method where 8 sensors were used to measure signal strengths which was later used to estimate the distance. The average experimental error was reported to be 37.7 mm [25] using a maximum of 92 samples. In [26], the authors proposed an adaptive linearized method of 2D localization of the moving telemetry capsule using RSS based triangulation method. They reported an average error of about 25% using 3 sensors. Based on the statistical implant path loss model developed in [27], the authors in [28, 29] used RSS based triangulation technique to analyze possible capsule localization accuracy in 3D location estimation using maximum 1000 samples and reported average localization error of 50 mm in all organs where more than 32 sensors on body surface are needed for achieving satisfactory localization accuracy. In [31], the authors present a localization system based on UHF band RFID. They propose a location estimation algorithm by calculating center of gravity of antennas which have detected the tag, and the results show a mean localization error of 2 cm. Using our proposed adaptively linearized method of path loss based WCL, average localization error of 5.106 mm is achievable in 3D position estimation in 1 mm spatial resolution (2,530 samples) using only 8 sensors. After comparing the results, it can be said that the proposed algorithm significantly improves the localization accuracy in 3D location estimation using only eight sensors with higher space resolution.
Comparison of the algorithms of wireless endoscopic capsule localization.
8. Conclusion
Path loss based WCL is a simple localization algorithm to determine the three-dimensional location of the wireless capsule endoscope inside the small intestine. A major challenge in this approach is the path loss attenuation exponents and the shadow fading effects which is caused due to the nonhomogeneous environment for radio propagation inside the human body resulting in certain level of path loss deviations S and different value of path loss attenuation exponents for different surroundings. The localization accuracy using path loss based WCL heavily depends on the path loss attenuation exponents and the path loss deviations. As we observed the mean localization error increases by 8-9 mm for each 1 dBm path loss deviation. In this paper, we propose an adaptive linearized method of WCL algorithm for VCE localization which includes four steps of optimizations to improve the localization accuracy. First we identify the path loss attenuation exponents or path loss statistics for different scenarios/surroundings using linear least square regression of the collected data set. Then we linearize the path loss model to minimize path loss deviations. Then we calculate the weights of the sensors using the linearized path loss and then estimate the VCE location using adaptively linearized WCL. Finally we calibrate the location using linear least square regression. We simulate our proposed adaptively linearized LLS-WCL algorithm using Matlab for 2530 possible sample positions inside the small intestine. The simulation results show significant accuracy improvement in 3D localization of the VCE inside the small intestine with root mean square error of 5.15 mm with standard deviation 3.5 mm using only 8 RF receiver sensors.
Footnotes
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Acknowledgments
The work was conducted at the University of Saskatchewan under the Canadian Commonwealth Scholarship Program. Umma Hany would like to thank Lutfa Akter of Bangladesh University of Engineering and Technology for her support and encouragement in accepting the scholarship program and her assistance in developing prior knowledge to conduct the research work. The authors would like to acknowledge Natural Science and Engineering Research Council of Canada (NSERC), Grand Chellenges Canada (GCC), and Canada Foundation for Innovation (CFI) for their support in part to conduct this research work. The authors would like to thank Shahed Khan Mohammed for his help and suggestions in proofreading and revising the manuscript.
