1 Introduction

In the past decade, miniaturization and cost reduction of semiconductor devices have allowed the design of small, low cost computing and wireless communication devices used as sensors in a variety of popular wireless networking applications and this trend is expected to continue in the next few decades [1]. One of the leading wonders of this wireless networking breakthrough is the emergence of wireless wireless capsule endoscopy (WCE). The technology was introduced by the Given Imaging, Yoqneam, Israel in 2000 [2, 3]. Food and Drug Administration (FDA) approved its clinical usage in 2001. Examination of the Gastrointestinal (GI) tract using WCE is commonly used for a number of diseases such as the inflammatory bowel disease, the ulcerative colitis and the colorectal cancer. WCE uses radio frequency (RF) signals to transmit approximately fifty five thousands clear pictures of inside the GI tract wirelessly to the body-mounted sensor array, therefore, it provides a non-invasive way to visualize the entire small intestine, where traditional endoscopy and colonoscopy visualization techniques can hardly reach. However, physician has no clue on the exact location of the capsule inside the GI tract to associate it with the pictures showing abnormalities such as bleeding or tumors. It is desirable to use the same RF signal for localization of the WCE as it passes through the human GI tract.

In recent years, the feasibility of several technologies for localization of the WCE has been explored. These technologies can be divided into those using magnetic field or inertial systems [4, 5], using image processing techniques [68] and techniques using RF signals [1, 9]. In magnetic sensing based techniques, a magnet is inserted into the WCE and the WCE is located by measuring the magnetic field [4]. This technique increases the weight and size of the WCE and the magnetic field of the WCE used for localization will be interfered by the external magnetic fields used for other applications such as the magnetic resonance imaging (MRI) systems. One can also insert radiation opaque material into the WCE and trace the location of the WCE using X-ray or computed tomography (CT) scan [5]. Continuous imaging using X-ray or CT scan is very expensive and it bears the health risks for the patient. Using the RF signal used for image transmissions for the WCE to also locate the capsule offers itself as a natural and low cost solution that does not add to the capsule complexity and payload. Therefore, it has been chosen for use with the Smartpill capsule [10] in USA and the M2A capsule [11] in Israel. These companies use the received signal strength (RSS) of the waveform for the purpose of localization of the WCE. A more accurate metric for localization is the time of arrival (TOA) or the time of flight of the signal [12].

For RF based localization, a widely known benefit of TOA based techniques is their high accuracy compared to RSS based techniques. The TOA based technique relies on measurements of travel time of signals between the known reference nodes and unknown terminal nodes. As a result, ranging information is calculated by multiplying the propagation velocity of RF signal and the measured TOA value. On the other hand, the human body is formed of various organs with complex structures. Each organ has a unique characteristic of conductivity and relative permittivity. Since propagation velocity inside human body is a function of the relative permittivity, medical implanted devices placed in different positions cause different propagation velocities due to the RF signal traveling through various tissues or organs. This variation in speed is the dominant source of error for TOA-based RF localization inside the human body [13].

In this paper, we address the accuracy limits of RF localization techniques for WCE localization with particular attention to localization inside the small intestine. Fundamentally, RF localization is either based on the RSS or more accurate TOA. The limited existing literature is focused on developing algorithms and mathematical models for solving the triangulation problems. Some preliminary results on performance evaluation of two specific localization algorithms for two dimensional (2D) RSS- and TOA-based techniques inside the human body are reported in Frisch et al. [14] and Kawasaki and Kohno [13] respectively. In our previous work, we have used the Cramer–Rao Lower Bound (CRLB) [15, 16] for performance evaluation of RSS based localization using a single pill inside the major organs in the GI tract: stomach, small-intestine and large intestine [17]. The CRLB has been used traditionally for the analysis of the accuracy of outdoor localization using GPS and for a variety of indoor geolocation applications for the human and robotics applications [18], we have also modeled the 3D statistical ranging error for TOA-based localization inside the torso [19]. This paper provides a unified framework and methodology for calculation of the CRLB for comparative performance evaluation of the RSS- and TOA- based cooperative localization with multiple capsules operating inside the GI tract. We apply this analytical framework to compare the performance of the RSS- and TOA-based cooperative localizations using multiple capsules in the three major organs of the GI tract as well as to assess the accuracy of these techniques as the WCE moves along the complex path of movements inside the small intestine. Analytical results presented here includes the effects of number of external sensors; the external sensor array topology, number of WCE in cooperation and the random variations in transmit power from the capsule.

The rest of the paper is organized as follows. We begin in Sect. 2 by defining a methodology for performance evaluation and introducing the ranging error models for RSS and TOA based localization techniques. We present a GI tract localization scenario inside the organs and the path of movements of the WCE and for that scenario, we introduce an implant to body surface path loss model as well as a TOA ranging error model. In Sect. 3, using the capsule movement and body mounted sensor locations in our scenario and the ranging error models, we derive a universal CRLB for cooperative performance evaluation of cooperative RSS- and TOA-based WCE localization techniques and the localization bound with randomness in the transmitted power. In Sect. 4, we provide results of the localization accuracy in stomach, small intestine and large intestine as well as path of movements inside the small intestine for different number of WCEs and body mounted sensor topologies. We provide our conclusions in the Sect. 5.

2 Performance Evaluation Scenario and RF Behavior Modeling

To calculate the CRLB, we define a performance evaluation scenario and models for the behavior of the localization metrics [20], the RSS and TOA, for RF signaling in between the GI tract and the body-mounted sensors used for localization. In this section we introduce a general scenario for comparative performance evaluation of RSS- and TOA-based localization for capsule endoscopy application. The scenario is designed to reflect the performance in different organs, the path of movement of the WCE inside the small intestine, and the number and pattern of installation of body mounted sensors on the torso. Since the received signal on the body-mounted sensors is distorted with the multipath receptions caused by the refraction at the boundary of organs and tissues inside the human body, models for behavior of the RSS and TOA are fairly complicated. These models are then introduced in the rest of the section.

Fig. 1
figure 1

Anatomy of GI tract. a A schematic of the GI tract. b The digitized major organs in the GI tract

Fig. 2
figure 2

a 3D model for large and small intestine. b 3D path model for large and small intestine

2.1 Performance Evaluation Scenario

Figure 1a shows the relative location and shape of the three major organs in the GI tract, stomach, small intestine and colon or large intestine. In order to emulate a scenario for comparative performance evaluation of RSS- and TOA-based localization systems we first analyses the effects of the shape of the organs by comparing the localization performance in the three major organs. Then, we focus on the analysis of the performance as the WCE moves along the small intestine. To create the environment, we use a three-dimensional (3D) human model from the full-wave electromagnetic field simulation system (Ansoft [21]). This 3D human body model has a spatial resolution of 2 millimeters and includes frequency dependent dielectric properties of more than 300 parts in a male human body. Figure 1b shows the digitized picture of the three major organs in this human body model. For comparative performance evaluation in different organs, we calculate the CRLB for each grid point of an organ and we compare the CDF or these errors for different topologies of the body mounted sensors. Since small intestine is a long curled organ, the WCE takes a path to go through this organ Given the 3D CAD model of the small intestine, we found the path of the movement of the capsule and imported this path into the software simulation tool for RF propagation modeling.

Given a 3D model of the intestinal tract, shown in Fig. 2a, we applied 3D image processing techniques to trace the path of movements inside the intestine. In the case of the large intestine, since it already has a very clear pattern, which looks like a big hook, applied 3D skeletonization technique [22, 23] to extract the path. Since the shape of the small intestine is much more complicated, the same technique does not work well. In this case, we developed an element sliding technique to trace the path. The basic idea behind this technique is to define an element shape with its radius automatically adjustable to the radius of the small intestine. As the element shape goes along the small intestine, the center of the element shape is recorded to define a clear path movement inside the small intestine. The result of the path extracted for large and small intestines from the 3D model is shown in Fig. 2b. For comparative performance evaluation, we determine the CRLB along the path of capsule in the small intestine for different topologies of body-mounted sensors.

Fig. 3
figure 3

A typical 3D pattern of body mounted sensors used as reference points of the performance evaluation scenario for localization of the WCE

To define the topologies of the body-mounted receiver sensors, similar to [14], we assume the receiver arrays are placed on a jacket worn by the patient during the examination. We calculated the CRLB for 8, 16, 32 and 64 body-mounted receiver sensors spread over a rectangular area with a three dimensional range of \(268 \times 323\times 312\) millimeters. Sensor receivers are mounted in grids in equal number in front and on the back of the jacket. An example of a typical network topology for 32 receiver sensors is illustrated in Fig. 3. Using the path loss models as well as the path of movement inside the small intestine for the RSS and the ranging error model for TOA estimations, we determine the CRLB for each of the three major organs as well as path of movement inside the small intestine for different body mounted sensor topologies.

2.2 Path Loss Model for RSS-Based Localization of the WCE

Calculation of the CRLB for performance evaluation of the RSS-based localization need a path-loss model for the RF propagation from the inside of the GI tract, where the WCE travels, to the body mounted sensors used as reference points for localization. The path-loss model we used for the performance evaluation of RSS-based WCE localization inside the human body is the one reported in [24, 25]. The model was developed by National Institute of Standards and Technology (NIST) at 402–405 MHz MICS band using a fully digitized human body with detailed organs and tissues and a 3D fullwave electromagnetic field simulator. This model relates the \(L_p(d)\), the path loss in dB between the WCE and the body-mounted sensors at distance \(d\) by the following equation:

$$\begin{aligned} RSS(d) = P_t-PL(d_0)-10 \alpha {\rm log}_{10}\frac{d}{d_0}+S (d>d_0) \end{aligned}$$
(1)

where \(d_0\) is the reference distance set at 50 mm, \(PL(d_0)\) is the path loss at the reference distance \(d_0, \alpha\) is the path loss gradient and \(S\) is a zero mean log-normally distributed random variable representing the shadow fading effect caused by different human tissues.

The model is developed for the near-surface implants applications with distances less than 10 cm inside the human body from the surface skin as well as deep-tissue implants applications with distances more than 10 cm.

The parameters associated with the two scenarios for the implant to body surface path loss model are summarized in Table 1. In this table, dB is the standard deviation of shadow fading \(S\). In our simulations, 10 cm distance between the WCE and body mounted receiver sensors is used as the threshold for choosing between the two models.

Table 1 Parameters for the statistical implant to body surface pathloss model

2.3 Ranging Error Model for TOA Localization of the WCE

Traditional localization systems such as GPS use the more accurate TOA localization approach. To determine the distance between a terminal and a reference point, the TOA of signal is measured to determine the flight time of the radio wave. The distance is calculated by multiplying the time of flight of the signal with the speed of radio propagation in the medium, which is the same as the speed of light for those applications.

In traditional indoor scenario TOA based localization, the biggest challenge is the appearance of the so called “undetected direct path problem” [26], for TOA based localization of the WCE, the most challenging problem comes from the complexity of the environment where the capsule travels through. Various organs and tissues with different permittivity make it difficult to predict the propagation speed of RF signal traveling through the human body. Since we do not know the speed of the propagation inside the human body, to calculate the distance, we may use the average speed of propagation in different organs [13]. This approach causes ranging error caused by deviations of the actual speed of propagation in different organs from the average speed. This error is much higher than the traditional TOA-based ranging error caused by the bandwidth and power limitations [27] and it dominates the TOA-based localization error [28]. Therefore, we need a TOA ranging error model to account for this error source in TOA ranging process.

In this part, we will summarize our work in modeling of the TOA ranging error caused by lack of information of the real propagation velocity inside the human body. The current TOA ranging method calculates the distance by multiplying the TOA with the velocity derived from the average permittivity of the human body. This approach results a ranging error caused by inhomogeneity of body as a medium for radio propagation. We propose a 3D simulation platform to address this issue in details. In RF localization literature [25, 29], the ranging error is defined as:

$$\begin{aligned} DME = d- {\hat{d}} \end{aligned}$$
(2)

where \(d\) is the actual distance and \({\hat{d}}\) is the estimated distance and DME is the distance measurement error. Considering the total distance traveled through the body is added by the distance in each organ or tissue, the total distance can be expressed as:

$$\begin{aligned} d_{total} = d_1 + d_2 + \cdots + d_n \end{aligned}$$
(3)

where \(d_1\) to \(d_n\) are the distances traveled in each organ or tissue. In reality, we use the average permittivity of human body to estimate the average propagation velocity inside human body, which is

$$\begin{aligned} {\bar{v}}=\frac{c}{\sqrt{\bar{\epsilon _r}}} \end{aligned}$$
(4)

where the \(\bar{v}\) is the average velocity and the \(\bar{\epsilon _r}\) is average relative permitivity of the organ/tissues. Therefore, the estimated distance is expressed as:

$$\begin{aligned} {\hat{d}}={\hat{\tau }}{\hat{\bar{v}}}&= ({\hat{\tau }}_1+{\hat{\tau }}_2 + \cdots + {\hat{\tau }}_n)\frac{c}{\sqrt{\bar{\epsilon }_r}} \\&= \sum _{i=1}^{n}\frac{d_ic}{v_i\sqrt{\bar{\epsilon }_r}}= (\frac{d_1}{c/\sqrt{\bar{\epsilon }_1}}+\frac{d_2}{c/ \sqrt{\bar{\epsilon }_2}} \cdots \frac{d_n}{c/ \sqrt{\bar{\epsilon }_n}})\frac{c}{\sqrt{\bar{\epsilon }_r}} \end{aligned}$$
(5)

where \(\tau _1\) to \(\tau _n\) are the time the signal traveled inside each organ or tissue. \(d_i\) and \(\epsilon _i\) are the path length inside each organ/tissue and the relative permitivity of each organ/tissue. The difference between \(d_{total}\) and \({\hat{d}}\) is the ranging error caused by human tissue inhomogeneity that we refer to as DME in Eq. 2. This error between the actual distance and the distance measured by TOA and average velocity of the propagation is caused by using a single velocity rather than multiple velocities. To determine the statistics of this error, we simulated the effect of inhomogeneous tissues on TOA ranging in a 3D torso environment, shown in Fig. 4. We have selected approximately five hundred pairs of random locations on the human body torso and for each pair, we have calculated the DME using Eq. 2. The human organs’ relative permittivities are a function of the operating frequency, we studied the TOA ranging error at MICs band for the center frequency of 405 MHz, which is the reserved band for implant and in body applications. The average permittivity is calculated by weighting the permittivity of each organ according to their volume, the average permittivity is 46.35 in the torso environment. The permittivity and volume of different organs used for this simulation is shown in Table 2.

Fig. 4
figure 4

Simulation scenario for the DME in TOA ranging. The transmitter and receiver pairs are randomly distributed on the surface of body torso. The path length through each organ are marked as different colors in order to calculate the DME caused by tissue non-homogeneity. a Stomach. b Small intestine. c Large intestine. d Large intestine (Color figure online)

Table 2 Organ parameters used for simulation \(\left[ \epsilon _r,v (cm^3) \right]\)
Fig. 5
figure 5

The CDF of DME caused by human tissue inhomogeneity

Figure 5 presents the results of simulation and the best fit Gaussian distribution to the results. The mean value of DME is −3.92 mm, while the standard deviation of DME \(\sigma _T\) is 24.3 mm. The mean value of DME is a negative value because the largest organ in the torso cavity is the lungs, which have a much smaller permittivity value than the average permittivity of human tissues. Hence, the signal propagates faster in the lungs than the average speed of signal propagation inside human body. When we use the average propagation to calculate the estimated distance, the value is smaller than the real distance, because we underestimated the distance signal went through the lungs.

3 CRLB for Cooperative Localization Inside the GI Tract

In this section, based on the performance evaluation scenario, path loss and TOA ranging error models in Sect. 2, we derive a universal 3D CRLB for cooperative localization of the WCE inside the GI tract. We begin by developing performance bounds for RSS-and TOA-based localization for one capsule traveling inside the GI tract the for different patterns of body-mounted array of sensors. We then extend our analysis to cooperative localization using multiple capsules. In the cooperative localization, a patient takes more than one capsule in different times and localization is based on the measured RSS and TOA among the capsules as well as the pattern of body-mounted sensors. The performance of RSS based localization depends on variations of the transmitted power and that power is affected by the variations in the behavior of the batteries. In the latter part of this section, we provide a performance evaluation methodology for analysis of the effects of these variation on the performance of the RSS-based localization techniques.

3.1 CRLB for Single WCE Localization

Consider the WCE whose location is being estimated is indexed \(1\), and \(m\) body mounted receiver sensors denoted with indexes \(2 \ldots m + 1\). Each receiver sensor \(i\) is capable of measuring the TOA \(t_i\) or RSS \(r_i\) from the WCE. The observation vector is \(X = [t_2, \ldots , t_{m+1}]\) for the TOA case or \(X = [r_2, \ldots r_{m+1}]\) for the RSS case. Assume he location coordinate of the WCE is \(\theta _1 = [x_1, y_1, z_1]\), then our objective here is to estimate the location of the WCE \({\hat{\theta_1}}\). The \(t_i\) observations are modeled as normal random variables \(f_{t_i/\theta _1,\theta _i} \sim N(d_{i,1},/\bar{v},\sigma ^2_T)\), where \(d_{i,1}\) is the distance between the WCE and receiver sensor \(i\). \(\bar{v}\) is the average propagation speed of RF signal inside the human GI tract, and \(\sigma _T\) is the parameter describing the TOA ranging error caused by human tissue non-homogeneity. The \(r_i\) measurements are lognormally distributed \(f_{r_i{\rm dB}/\theta _1,\theta _i} \sim N(P_r({\rm dB}),\sigma ^2_{sh})\), with \(P_r({\rm dB}) = P_0({\rm dB})-10\alpha {\rm log}10(d_1,i)\). \(P_0({\rm dB})\) is the RSS at the reference distance (i.e. 50 mm) from the WCE. \(\alpha\) is the path loss gradient and \(\sigma _sh\) is the variance of the log normal shadowing.

The CRLB of \({\hat{\theta_1}}\) is \(cov({\hat{\theta_1}})\ge I(\theta _1)^{-1}\) where \(I(\theta _1)\) is the Fisher information matrix (FIM).

$$\begin{aligned} I_{\theta _1}=-E\triangledown _{\theta _1}(\triangledown _{\theta _1}\ln \iota (X|\theta _1,\theta )) = \left[ \begin{array}{lll} I_{xx}&I_{xy}&I_{xz}\\ I_{xy}&I_{yy}&I_{yz}\\ I_{xz}&I_{yz}&I_{zz} \end{array} \right] \end{aligned}$$
(6)

where \(\iota (X|\theta _1,\theta )\) is the logarithm of the joint conditional probability density function:

$$\begin{aligned} \iota (X|\theta _1,\theta )&= \sum _{i=2}^{m+1}{\rm log} f_{\tau _1|\theta _1,\theta _i}\;\;\;(for\; TOA)\end{aligned}$$
(7)
$$\begin{aligned} \iota (X|\theta _1,\theta )&= \sum _{i=2}^{m+1}{\rm log} f_{r_1|\theta _1,\theta _i}\;\;\;(for\; RSS) \end{aligned}$$
(8)

and

$$\begin{aligned} I_{xx}&= -\sum _{i=2}^{m+1}E[\frac{\partial ^2{\rm log}f_{\tau _i|\theta _1,\theta _i} }{\partial ^2x^2_1}] \;\;\;(for\; TOA)\end{aligned}$$
(9)
$$\begin{aligned} I_{xx}&= -\sum _{i=2}^{m+1}E[\frac{\partial ^2{\rm log}f_{r_i|\theta _1,\theta _i} }{\partial ^2x^2_1}] \;\;\;(for\; RSS) \end{aligned}$$
(10)

Similar expressions can be extend to \(I_{yy},I_{zz},I_{xy},I_{xz}\) and \(I_{yz}\). The CRLB on the variance of the TOA/RSS location estimation is

$$\begin{aligned} \sigma ^2_1&= tr\left\{ cov_{\theta }({\hat{x}}_1,{\hat{y}}_1,{\hat{z}}_1) \right\} \\&= Var_{\theta }({\hat{x_1}})+Var_{\theta }({\hat{y_1}})+Var_{\theta }({\hat{z_1}}) \\&= min\;tr(cov({\hat{\theta }}_1))=tr(I(\theta _1)^{-1}) \\&\quad (-I_{xx}(I_{yy}+I_{zz}) + I_{xy}I_{xy}+I_{xz}I_{xz}+\cdots \\&\quad + I_{yz}I_{yz}/(-I_{xx}I_{yy}I_{zz}+I_{xx}I_{yz}I_{yz}+\cdots \\&\quad + I_{xy}I_{xy}I_{zz}-I_{xy}I_{yz}I_{xz}-I_{xz}I_{xy}I_{xx}+I_{xz}I_{yy}I_{xz} \end{aligned}$$
(11)

The derivations of the likelihood function for the TOA and RSS case was originally derived in [15] for 2D case. Here, we extended the work to 3D scenario for WCE applications. The details are given in the appendix.

3.2 CRLB for Multiple WCEs Cooperative Localization

The localization problem is formulated as follows, \(N\) wireless endoscopic capsules are distributed in the GI tract with locations given by \(\theta _c=[p_1,p_2 , \ldots , p_N]\). These pills are blindfolded devices but they can measure the RSS from each other and transmit the information out to the receiver array for further processing. \(M\) receiver sensors are placed on the surface of the human body with location given by \(\theta _r=[p_{N+1},\ldots ,p_{N+M}]\). The vector of device parameters is \(\theta =[\theta _c,\theta _r]\). For this three dimensional system, \(p_i=[x_i,y_i,z_i]^{\rm T}\), where \(i\in [1,N+M]\)and T is the transpose operation. The unknown parameters to be estimated can be represented by a \(3\times N\) coordinates matrix.

$$\begin{aligned} \theta _c=[p_1,p_2 , \ldots ,p_N]= \left[ \begin{array}{llll} x_1&x_2&\ldots&x_N\\ y_1&y_2&\ldots&y_N\\ z_1&z_2&\ldots&z_N \end{array} \right] \end{aligned}$$
(12)

Consider devices (devices include capsules and receivers) \(i\) and \(j\) make pair-wise observations \(X_{i,j}\) . We assume each receiver sensor can measure the RSS from all the capsules inside the body, but the path loss parameters for different links varies as the distance between the receiver sensor and capsule inside the body changes. Therefore, Let \(H(i)=\) \(j\): device \(j\) makes pair-wise observations with device \(i\). \(H\left\{ i \right\} = \left\{ 1,\ldots ,i-1,i+1,\ldots ,N+M \right\}\) for \(i\in [1,N]\) and \(H\left\{ i \right\} =\left\{ 1,\ldots ,N \right\}\) for \(i\in [N+1,N+M]\) because a device cannot make pairwise observation with itself and the receivers do not make observations with receivers either. Therefore the length of the observation vector \(X\) is \(N\times (N+M-1)+M\times N\).

By reciprocity,we assume \(X_{i,j}=X_{j,i}\). Thus, it is sufficient to consider only the lower triangle of the observation matrix \(X\) when formulating the joint likelihood function [15]. The CRLB on the covariance matrix of any unbiased estimator \({\hat{\theta }}\) is given by [30]:

$$\begin{aligned} cov({\hat{\theta }})=E[({\hat{\theta }}-\theta )({\hat{\theta }}-\theta )^{\rm T}]\ge F^{-1}_{\theta } \end{aligned}$$
(13)

where \(E[.]\) is the expectation operation and \(F\) is the FIM defined as:

$$\begin{aligned} F_{\theta }&= -E\triangledown _{\theta }(\triangledown _{\theta }\ln f(X|\theta ))^{\rm T} \\&= E_{\theta }[\frac{\partial }{\partial \theta }\ln f(X|\theta ){\frac{\partial }{\partial \theta }}\ln f(X|\theta )^{\rm T}] \\&= \left[ \begin{array}{llll} F_{Rxx}&F_{Rxy}&F_{Rxz}\\ F^T_{Rxy}&F_{Ryy}&F_{Ryz}\\ F^T_{Rxz}&F^T_{Ryz}&F_{Rzz} \end{array} \right] \end{aligned}$$
(14)

where \(f(X|\theta )\) is the joint probability distribution function (PDF) of the observation vector \(X\) conditioned on \(\theta\). Then the logarithm of the joint condition PDF is:

$$\begin{aligned} \iota (X|\theta )=\sum _{i=1}^{N+M}\sum _{j\in H,j < i}{\rm log} f_{X|\theta }(X_{i,j}|p_i,p_j) \end{aligned}$$
(15)

It is shown in [15] The elements of \(F_{\theta }\) are:

$$\begin{aligned}{}[F_{R_{xx}}]_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(x_k-x_i)^2}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(x_k-x_l)^2}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(16)
$$\begin{aligned} {[}F_{R_{xy}}{]}_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(x_k-x_i)(y_k-y_i)}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(x_k-x_l)(y_k-y_l)}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(17)
$$\begin{aligned} {[}F_{R_{xz}}]_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(x_k-x_i)(z_k-z_i)}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(x_k-x_l)(z_k-z_l)}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(18)
$$\begin{aligned} {[}F_{R_{yy}}]_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(y_k-y_i)^2}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(y_k-y_l)^2}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(19)
$$\begin{aligned} {[}F_{R_{yz}}]_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(y_k-y_i)(z_k-z_i)}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(y_k-y_l)(z_k-z_l)}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(20)
$$\begin{aligned} {[}F_{R_{zz}}]_{k,l}&= \left\{ \begin{matrix} \gamma \sum _{i\in H(k)}\frac{(z_k-z_i)^2}{d^s_{ki}} \,\,\,k=l\\ -\gamma I_{H(k)}(l)\frac{(z_k-z_l)^2}{d^s_{kl}} \,\,\,k\ne l \end{matrix}\right. \end{aligned}$$
(21)

Here, \(\gamma\) is a channel constant and s is an exponent, both of which are functions of the measurement type and are given in Table 3.

Table 3 Differences in parameters for TOA and RSS

where for TOA based localization technique, \(v_p\) is the propagation speed of the signal and \(\sigma _T\) is the standard deviation of the ranging error. for RSS based localization technique, \(\alpha\) is the path loss gradient and \(\sigma _{{\rm dB}}\) is the standard deviation of the shadow fading.

Let \({\hat{x}}_i, {\hat{y}}_i, {\hat{z}}_i\) be the unbiased estimation of \(x_i, y_i, z_i\), the trace of the covariance of the \(i\)th location estimate is given by:

$$\begin{aligned} \sigma ^2_i&= tr\left\{ cov_{\theta }({\hat{x}}_i,{\hat{y}}_i,{\hat{z}}_i) \right\} \\&= Var_{\theta }({\hat{x_i}})+Var_{\theta }({\hat{y_i}}) +Var_{\theta }({\hat{z_i}}) \\&\ge \left[ \begin{array}{llll} F_{R_{xx}}-(F_{R_{xy}}F_{R_{xz}}) \left( \begin{array}{ll} F_{R_{yy}} &{} F_{R_{yz}}\\ F_{R_{yz}} &{} F_{R_{zz}} \end{array}^{-1} \right) \left( \begin{array}{ll} F_{R_{xy}}\\ F_{R_{xz}} \end{array} \right) \end{array}^{-1}_{i,i} \right] \\& \quad + \left[ \begin{array}{ll} F_{R_{yy}}-(F_{R_{xy}}F_{R_{yz}}) \left( \begin{array}{ll} F_{R_{xx}} &{} F_{R_{xz}}\\ F_{R_{xz}} &{} F_{R_{zz}} \end{array}^{-1} \right) \left( \begin{array}{ll} F_{R_{xy}}\\ F_{R_{yz}} \end{array} \right) \end{array}^{-1}_{i,i} \right] \\& \quad + \left[ \begin{array}{llll} F_{R_{zz}}-(F_{R_{xz}}F_{R_{yz}}) \left( \begin{array}{llll} F_{R_{xx}} &{} F_{R_{xy}}\\ F_{R_{xy}} &{} F_{R_{yy}} \end{array}^{-1} \right) \left( \begin{array}{llll} F_{R_{xz}}\\ F_{R_{yz}} \end{array} \right) \end{array}^{-1}_{i,i} \right] \end{aligned}$$
(22)

3.3 CRLB When Randomness Exists in Transmitted Power

Until now, we assume the sensors have perfect knowledge of their transmit power,if none of the \(N\) sensors have perfect knowledge of their transmit power. The Bayesian CRLB [30] also called as Vantrees inequality states that any estimator \(\theta\) must have error correlation matrix \(R_{\in }\) satisfying

$$\begin{aligned} R_{\in }>F^{-1}=[F_{\theta }+F_{p}] \end{aligned}$$
(23)

where \(R_{\in } = E[({\hat{\theta }}-\theta )({\hat{\theta }}-\theta )^{\rm T}]\), with \(F_{\theta }\) and \(F_p\) are the fisher information matrix and prior information matrix respectively and are given by Eq. 24.

$$\begin{aligned} F_{\theta }&= -E[\triangledown _{\theta }(\triangledown _{\theta }\ln f(p_{i,j|\theta }))^{\rm T}]\end{aligned}$$
(24)
$$\begin{aligned} F_{p}&= -E[\triangledown _{\theta }(\triangledown _{\theta }\ln f(\theta )^{\rm T}] \end{aligned}$$
(25)

where \(p_{i,j}\) is the bi-directional measurement vector. The prior information matrix \(F_p\) is given in Eq. 26.

$$\begin{aligned} F_{p}=diag[0^{\rm T}_n, 0^{\rm T}_n, 0^{\rm T}_n, 1^{\rm T}_N/\sigma ^2_{\pi }] \end{aligned}$$
(26)

where \(0_n\) is a length-\(n\) vector of zeros and \(1_n\) is an \(N\) length vector of ones and \(\sigma ^2_{\pi }\) is the variance of the random variable \(\pi _{0i}\)(the power at 1 cm distance from transmitter \(i\)), which is assumed to have an i.i.d Gaussian prior for every sensor \(i\).

We model the bi-directional measurements \(P_{i,j}\) and \(P_{j,i}\) using vector \(p_{i,j}=[P_{i,j}P_{j,i}]\) as a bi-variate Gaussian with mean \(u_{i,j}\) and variance \(C_{i,j}\) , where

$$\begin{aligned} u_{i,j}&= \left[ \begin{array}{l} \pi _{0,j}-10\alpha \log 10 \frac{|ri-rj|^2}{\Delta ^2_0 }\\ \pi _{0,i}-10\alpha \log 10 \frac{|ri-rj|^2}{\Delta ^2_0 } \end{array} \right] \end{aligned}$$
(27)
$$\begin{aligned} C_{i,j}&= \sigma ^2_{{\rm dB}} \left[ \begin{array}{ll} 1&\rho \\ \rho&1 \end{array} \right] \end{aligned}$$
(28)

where \(\alpha\) is the path loss exponent, and \(\rho\) is the correlation coefficient between the bidirectional measurements, \(0\le \rho \le 1\) . For the purpose of discussion we transform the bidirectional measurement vector \(p_{i,j}\) by an orthogonal matrix \(A\) as:

$$\begin{aligned} {\hat{p}}_{i,j}=Ap_{i,j}, \,\, A= \left[ \begin{array}{ll} 1&1\\ 1&-1 \end{array} \right] \end{aligned}$$
(29)

such a full rank transformation of measurement does not change the Fisher information. For simplicity of notation, we denote \({\hat{p}}_{i,j}=[\bar{p}_{i,j}p^{\Delta }_{i,j}]^{\rm T}\), where \(\bar{p}_{i,j}\) corresponds to the average of the two measurements and \(p^{\Delta }_{i,j}\) corresponds to the difference between the two measurements. After some mathematical analysis, it is seen that \(\bar{p}_{i,j}\) has a mean \(\bar{u}_{i,j}\) and covariance \(\bar{C}\) and \(p^{\Delta }_{i,j}\) has a mean \(u^{\Delta }_{i,j}\) and covariance \(C^{\Delta }\) as given below:

$$\begin{aligned} \bar{u}_{i,j}&= \pi _{0,j}+\pi _{0,i}-10\alpha \log 10 \frac{|ri-rj|^2}{\Delta ^2_0}\end{aligned}$$
(30)
$$\begin{aligned} \bar{C}&= \frac{(1+\rho )\sigma ^2_{{\rm dB}}}{2}I_{3n+N}\end{aligned}$$
(31)
$$\begin{aligned} u^{\Delta }_{i,j}&= \frac{\pi _{0j}-\pi _{0i}}{2}\end{aligned}$$
(32)
$$\begin{aligned} C^{\Delta }&= \frac{(1-\rho )\sigma ^2_{{\rm dB}}}{2}I_{3n+N} \end{aligned}$$
(33)

where \(I_{3n+N}\) is \(3n+N\times 3n +N\) identity matrix and \(\bar{u}\) and \(u^{\Delta }\) are the mean values of the sum and difference of measurements respectively for all measurement pairs,

$$\begin{aligned} \bar{u}&= [\bar{u}_{i_1, j_1},\ldots ,\bar{u}_{i_s, j_s}]^{\rm T} \end{aligned}$$
(34)
$$\begin{aligned} \bar{u}&= [\bar{u}_{i_1, j_1},\ldots ,\bar{u}_{i_s, j_s}]^{\rm T} \end{aligned}$$
(35)

where \(i_1,j_1,\ldots ,i_s,j_s\) corresponds to each unique pair. A pair makes measurement if they are in the measurement range of each other. Here we assume that the measurement range is infinite (i.e., every sensor can do measurements with every other sensor.) The Fisher information matrix \(F_{\theta }\) given in Eq. 17 can be split into two sub matrices \(\bar{F}_{\theta }\) and \(F^\Delta _{\theta }\) corresponding to sum and difference measurements due to their independence.

$$\begin{aligned} F_{\theta }=\bar{F}_{\theta }+F^\Delta _{\theta } \end{aligned}$$
(36)

The Fisher information matrix of a vector of multivariate Gaussian measurements with mean \(\mu _{\theta }\) and covariance \(C\) is given by [31] and shown in the appendix. The derivation of the individual elements of the matrix are given in [32].

4 Performance Evaluation Results

In this section, we present the results of our analysis of the accuracy for localization of the WCE as it travels inside the human GI tract. We compare the performance of RSS and TOA based localization techniques in the major digestive organs in the GI tract as well as the path of movements of the WCE inside the small intestine. We study the effects of the number of receiver sensors on body surface and their topology on the localization accuracy. We also analyze the influence of number of transmitter sensors in cooperation and the randomness in their transmitted power on the localization accuracy. As shown in Fig. 8, \(M\) receiver sensors are distributed evenly on the surface of the body torso and \(N\) capsule pills are distributed inside the GI tract environment. Connectivity is assumed between the WCEs and the body mounted sensors and among the WCEs. The path loss parameters are determined by the length of each connection as mentioned in Sect. 2.

For the analysis of the experiments, we compute the average Root Mean Square Error (RMSE) of the location error of each situation. For the case of \(N\) different capsule locations, the average RMSE is computed by:

$$\begin{aligned} RMSE_{avg}=\sqrt{\frac{\sum _{i=1}^{N}\sigma ^2_{x_i}+\sigma ^2_{y_i}+\sigma ^2_{z_i}}{N}} \end{aligned}$$
(37)

where \(\sigma ^2_{x_i}, \sigma ^2_{y_i} and \sigma ^2_{z_i}\) are the variance of each coordinate value of the \(i\)th pill location, given by Eq. 15.

4.1 Effect of Organ Shape and Location

To evaluate the impact of the organ shape and location on localization accuracy. We fixed the number of receiver sensors to 32 and assumed only one single capsule in each organ. We calculated the 3D-CRLB for all the possible location points inside each organ (634 points for stomach, 1926 points for small intestine and 3334 points for large intestine). Figure 6 shows the CDF comparison of location error bound in different organs for RSS and TOA based localization.

The localization error for capsule in small intestine and stomach is apparently smaller than that in large intestine for both RSS and TOA based localization techniques. The average value of \(\sigma _i\) for RSS based localization technique is four times larger than that of TOA based techniques which confirms that TOA based ranging is better for high resolution requirement when the multipath problem is not severe. The localization error for capsule in stomach has the lowest average value but distributed in a wider range compared to the errors in other two environments. These observations can be explained by the geometric relationship between the sensor array and the organs. As we can see from Fig. 2a, stomach is located in the upper part of the receiver sensor array system, and its volume is the smallest among the three organs. Therefore, the localization error varies more in the stomach environment. The points located in the upper part of stomach have larger localization error value as they are far from the center of the receiver array system, the points in the lower part of stomach have smaller localization error value. The small intestine is located in the center part of human abdomen cavity and the lumen is more centralized compared to large intestine. Therefore, the localization error inside small intestine is smaller than that in large intestine. Considering the physicians are expecting localization accuracy less than several centimeters. The TOA ranging based system provides a more promising results.

Fig. 6
figure 6

The CDF of location error bounds in stomach, small intestine and large intestine for a single capsule. a RSS based localization. b TOA based localization

4.2 Effect of Number of Receiver Sensors

In this section, we investigate the impact of number of receiver sensors on localization accuracy. In this experiment, 12000 Monte Carlo simulations (3 different organs, 4 different number of receiver sensors and 1000 simulations per organ) were carried out with the number of receiver sensors varied from 8 64. During each simulation, we assume one capsule is located randomly inside the human digestive system. The results show that the number of receivers has significant influence on the accuracy of localization when the number of receivers is smaller than 32 especially for RSS based localization technique. Finally, notice that for all the three organs, at least 32 receiver sensors are needed to guarantee the performance of 50mm average RMSE (Fig. 7).

4.3 Effect of Sensor Configuration

In this experiment, three different placement for receiver sensors are considered, which represents the potential sensor arrangement in practice, as shown in Fig. 8.

Fig. 7
figure 7

Performances of RSS- and TOA-based localization as a function of number of receiver sensors

Fig. 8
figure 8

Three patterns for sensor configuration considered for analysis of the bounds. a Topology1: square configuration. b Topology2: parallel line configuration. c Topology3: grid configuration

Half of the sensors are on the front plane of the jacket and, the other half are located in the rear plane of the jacket. These sensor configurations can be seen to have three distinct configurations namely, (1): Sensors concentrated at the borders of the jacket, (2): Sensors uniformly distributed in both the planes of the jacket, (3): Sensors concentrated at the center of the jacket. Figure 9 shows the RMSE of the three different sensor population for the three distinct configurations. Better performance is achieved when the sensors are concentrated near the center of the jacket for RSS based localization technique, while sensors distributed around the border of the jacket achieves higher accuracy for TOA based localization technique. Arranging all the sensors according to the technique employed is important to achieve the optimal performance for the localization system.

4.4 Effects of the Shape of the Path in the Small Intestine

Since the small intestine is a curled and folded long tube in the GI tract, it is the most complex part in the digestive system. We specifically analyzed the accuracy limit when the capsule moves along its path in the small intestine because the location of abnormalities found in this organ attracts the physicians mostly. Our analysis is based on the same RSS path loss and, TOA ranging models, but along the small intestine path shown in Fig. 2b. The length of this typical 3D intestine path model is 8 meters and we have used 32 body-mounted sensors for localization. The results of RSS- and TOA-based localization accuracy bounds along the small intestine path are shown in Fig. 10. The mean of localization error bounds for the RSS- and TOA based localizations are 48 and 13 mm. In addition, the accuracy limit of RSS based localization technique fluctuates much more higher than the TOA based localization technique. The accuracy limit of RSS based technique varies more than 10 mm along the small intestine path, while the accuracy limit of TOA based technique only exhibits less than 0.5 mm of variation along the small intestine path. However, both techniques show similarities in performance influenced by the geometric relationship between the capsule transmitter and the receiver array on the body surface. For example, the localization error bound for both techniques reaches the local maximums at 4 and 6 m from the beginning of the small intestine.

4.5 Effect of Number of Pills in Cooperation

For this experiment, we fixed the number of receivers on body surface to 32 and increased the number of pills from 1 to 5. The pills are assumed to be randomly distributed inside the digestive system and they can measure the RSS or TOA from each other. We studied the effect of cooperation among pills using 15000 different situations for cooperative WCE localization.

The results are presented in Fig. 11 as the number of pills increase from 1 to 5. Localization error decreased by 5 mm for RSS based technique while it remains almost the same for TOA based technique. Compared to the impact of number of receiver sensors, the number of pills in cooperation has less influence on the accuracy of localization. Therefore, our results indicate that increasing the number of receiver sensors on body surface is a more effective way to improve the overall localization performance than increasing the number of pills in cooperation for RSS or TOA based capsule localization.

Fig. 9
figure 9

Three sensor configuration considered for analysis of the bounds for 64 sensors. a TOA, b RSS

Fig. 10
figure 10

The accuracy limit of localization along the small intestine path. a RSS-based localization. b TOA-based localization

Fig. 11
figure 11

Performances as a function of number of pills in cooperation for RSS-and TOA-based localization

4.6 Effect of Random Power on the Bounds in Different Organs

In this section, we calculate the bounds for different organs when theres randomness in the transmitted power. We plot the lower bound on the \(1-\sigma\) uncertainty ellipse for \({\hat{r}}_i\), the estimate of the \(i\)th capsule sensor coordinate. In this example, we use \(\sigma _{{\rm dB}}=7.85\) and \(\alpha =4.26\) based on the path loss model discussed in previous sections. For the simulation, we consider \(\rho =0.704\). The bounds behaves similar at different values of \(\rho\). We also found the bounds as a function of \(\rho\). Finally, in these examples, the prior knowledge of transmit power is \(\sigma _{\pi }=10 \, {\rm dB}\). We also consider the case when \(\sigma _{\pi }=0 \, {\rm dB}\) for comparison purpose.

For perfectly known transmit power (i.e. \(\sigma _{\pi }=0 \, {\rm dB}\)), the uncertainty ellipse is shown by solid lines whereas for \(\sigma _{\pi }=10 \, {\rm dB}\), it is shown by dotted lines. As we can see in Table 4, the increase in the RMSE for all three organs when, randomness in the transmit power exist.

Table 4 Percentage increase in the RMSE (mm) of the capsule in three different organs of the GI track

Figure 4 shows corresponding bound in each organ individually. It is observed with given configuration of anchor nodes capsules in large intestine suffered the largest localization error when there was variance in transmitting power. For small intestine, the value of RMSE for \(\sigma _{\pi }=0 \, {\rm dB}\) was 22.1399 mm and for \(\sigma _{\pi }=10 \, {\rm dB}\) was 22.4024 mm, i.e. an increase in error of about 0.2625 mm.

Next, we calculate the bound over the entire range of correlation coefficient values. Here, we have used a grid of 64 sensors with configuration number 3. The rest of the parameters are kept the same as the previous simulations. In this experiment, the capsule is assumed to be in any one of the three organs and the average performance bounds as a function of \(\rho\) is calculated. As seen in Fig. 12, as \(p\) approaches 0, the lower bounds are not affected with randomness in transmitted power as much as it is affected at lower value of \(\rho\). Also, at lower values of \(\rho\), the RMSE is lower than that at the higher values.

Fig. 12
figure 12

The CRLB versus correlation coefficient \(\rho\), for two different \(\sigma _{\pi }\) with 64 sensors in parallel configuration. Th path loss model parameters are \(\sigma _{{\rm dB}} = 7.85\) and \(\alpha = 4.26\)

5 Conclusion

We investigated the potential accuracy limits for RSS and TOA based RF localization for the wireless WCE as it travels inside the human GI tract using the CRLB. Results of our analysis showed the possibility of achieving average localization error 5 cm in the digestive organs for RSS based localization technique and average localization error of 1.5 cm for TOA based localization technique. To achieve these levels of accuracy, we showed that more than 32 sensors mounted on the body surface is needed. Our results demonstrate that increasing the number of sensors mounted on body surface has more influence on the overall localization performance than increasing the number of pills inside the GI tract. We also analyzed the effect of randomness in transmit power on the localization accuracy in different organs and found that large intestine suffers more inaccuracies due to this effect and that can increase the error by \(7.1 \, \%\). Since physicaians require accuracies of up to 10 cm for the WCE localization, results of this study suggests that designing RF localization techniques for the WCE is practical.