Two-stage cylindrical magnetic localization with neural network calibration for wearable capsule endoscopy Authors: Omid Yaghoobian, Mokarrameh Einlou, Khan A. Wahid Published: 2026 ABSTRACT Accurate localization of wireless capsule endoscopy is essential for reliable gastrointestinal diagnosis, yet magnetic tracking systems are often degraded by sensor distortions, misalignment, and patient motion in wearable settings. This study presents a magnetic localization framework that combines cylindrical magnetic field modelling with neural network–based sensor calibration to improve robustness under wearable operating conditions. By exploiting the structural properties of cylindrical magnetic field representations, the proposed approach decouples axial and transverse components of the magnetic field, enabling staged estimation of magnetic capsule position and orientation with improved numerical stability. A data-driven calibration model is employed to compensate for nonlinear sensor distortions arising from hard-iron effects, soft-iron effects, and dynamic misalignment. Experimental validation using a four-sensor wearable array demonstrates a mean static localization error of 0.12 cm and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1.1^{\circ }$$\end{document}, and a dynamic localization error of 0.20 cm and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2.1^{\circ }$$\end{document}, indicating improved performance under both stable and motion-affected conditions. These results suggest that accurate and robust magnetic capsule localization can be achieved with a minimal sensor configuration, supporting practical implementation in wearable capsule endoscopy systems. Introduction Capsule endoscopy has revolutionized gastrointestinal (GI) diagnostics by enabling minimally invasive visualization of the entire GI tract1. A wireless capsule equipped with an onboard camera is swallowed by the patient and acquires high-resolution images as it naturally traverses the digestive system2. While this technology provides comprehensive visual inspection, accurately localizing the capsule within the GI tract remains a critical challenge3. Reliable localization is essential for associating visual findings with anatomical landmarks, enabling precise diagnosis, and supporting targeted clinical interventions4. Numerous localization techniques have been investigated for wireless capsule endoscopy, including radio-frequency-based methods5, image- and video-based approaches6, hybrid techniques7, and magnetic sensing systems8. Among these, magnetic sensor-based localization has attracted significant interest due to its non-invasive nature, practical capability, and compatibility with the confined and tortuous geometry of the GI tract9. However, practical magnetic localization accuracy is strongly influenced by both the formulation of the localization algorithm and the quality of sensor calibration, particularly in wearable configurations10,11. Most magnetic localization systems model the magnetic capsule using Cartesian-coordinate magnetic dipole formulations12–14. Although mathematically general, Cartesian models do not explicitly exploit the cylindrical geometry of the human torso or the belt-like sensor arrangements commonly adopted in wearable systems. Consequently, position and orientation parameters are typically estimated simultaneously within a highly coupled nonlinear optimization problem, increasing sensitivity to noise and often requiring a larger number of sensors to achieve robust performance. In contrast, expressing the magnetic dipole field in cylindrical coordinates naturally aligns with wearable belt geometries and reveals structural dependencies that reduce coupling between axial and transverse components. This property enables a reformulation of the inverse localization problem that reduces parameter coupling and improves estimation robustness under sparse sensing conditions. Existing magnetic localization approaches for capsule endoscopy predominantly rely on Cartesian dipole models or cylindrical formulations solved via fully coupled nonlinear optimization. In these methods, all spatial and orientation parameters are estimated simultaneously, leading to strong parameter coupling and sensitivity to initialization, particularly under sparse sensor configurations. While cylindrical coordinate representations have been explored to better align with the physical geometry of wearable systems, they are typically used as an alternative parameterization rather than as a means to restructure the estimation problem. In contrast, the proposed approach leverages a rotated local cylindrical frame to reveal a structural property of the magnetic field model, namely the decoupling of axial measurements from azimuthal parameters. This insight enables the formulation of a two-stage estimation strategy that separates position and orientation components into sequential subproblems. By explicitly exploiting this structure, the proposed method reduces parameter coupling, improves numerical conditioning, and enhances robustness to noise and initialization errors in practical wearable scenarios. Accurate sensor calibration is equally critical for reliable magnetic localization. In practice, magnetic measurements are distorted by hard-iron and soft-iron effects, environmental magnetic interference, and intrinsic sensor imperfections15. In wearable systems, these distortions are further exacerbated by patient motion, which introduces time-varying sensor misalignment and orientation changes16. Without effective calibration, such effects lead to substantial discrepancies between measured and theoretical magnetic fields, significantly degrading localization accuracy17. Existing calibration approaches for magnetic sensor arrays largely rely on model-based optimization using predefined magnet trajectories and controlled experimental conditions18. Representative methods include rigid sensor mounting with controlled magnet motion19, extensions to dense cubic sensor arrays20, and joint calibration or calibration–localization schemes21,22. While effective under laboratory conditions, these approaches often involve high computational cost or require carefully controlled setups, limiting their practicality in practical and wearable clinical environments23–25. More recently, learning-based calibration methods, particularly those based on neural networks, have demonstrated strong potential for compensating nonlinear magnetic distortions in aerospace and geomagnetic applications26–29. By leveraging the nonlinear function approximation capability of neural networks, these approaches can model complex sensor errors and environmental disturbances that are difficult to capture analytically. However, despite these advantages, their adoption in wearable magnetic localization for wireless capsule endoscopy remains limited, particularly under dynamic operating conditions, where integration with physics-based localization models is essential for maintaining robustness and interpretability. In parallel, neural network (NN)-based approaches have been increasingly explored for magnetic sensing, localization, and calibration tasks due to their ability to approximate complex nonlinear mappings between magnetic field measurements and underlying system parameters. In particular, recent studies have investigated data-driven and hybrid magnetic localization frameworks that combine analytical models with learning-based components to improve robustness and estimation accuracy30. While these approaches demonstrate improved performance under complex conditions, they often rely on large training datasets and lack physical interpretability. In contrast, the proposed framework adopts a hybrid strategy in which a neural network is used as a residual calibration module within a physics-guided cylindrical localization model, enabling the integration of data-driven correction with analytical consistency. In the proposed framework, the neural network is designed as a lightweight residual calibration module rather than a standalone localization model. The selected architecture balances model capacity and generalization, enabling the network to capture nonlinear sensor distortions while avoiding overfitting to specific trajectories or environmental conditions. Simpler linear or affine calibration models are insufficient to compensate for higher-order distortions arising from soft-iron effects and dynamic misalignment, whereas deeper or more complex architectures were found to provide diminishing returns in performance relative to increased computational cost. Importantly, the network is trained to map distorted measurements to a physically consistent magnetic field representation defined by the analytical dipole model. As a result, the learned mapping is constrained by the underlying physics, improving generalization to unseen configurations and motion conditions. This hybrid formulation ensures that the neural network enhances calibration accuracy without replacing the interpretability and robustness of the physics-based localization model. Beyond calibration, sensor array configuration and wearability impose practical constraints on magnetic localization systems. Although increasing the number of sensors can improve accuracy, the resulting gains diminish beyond a certain point while system complexity and computational cost increase20. Sensor spacing also affects coverage and signal strength; overly dense placement may introduce interference, whereas excessive spacing can lead to weak magnetic signals and loss of identifiability31. Wearable designs must therefore balance localization performance with patient comfort and mobility32,33. While recent studies have explored wearable magnetic sensor arrays for capsule endoscopy localization34,35, robustness to motion-induced calibration drift remains an unresolved challenge in clinical settings. In this work, we propose a magnetic localization framework that integrates cylindrical magnetic field modeling, staged estimation, and neural network–based sensor calibration within a unified pipeline. The approach is specifically designed for wearable configurations with limited sensor counts, where robustness to noise, initialization, and motion-induced disturbances is critical. In parallel, a data-driven calibration model compensates for nonlinear sensor distortions arising from hard-iron effects, soft-iron effects, and dynamic misalignment. Experimental validation using a four-sensor wearable belt demonstrates accurate magnetic capsule localization under both static and motion-affected conditions. Contributions: The main contributions of this work are as follows: (i)a two-stage magnetic localization framework that exploits a cylindrical-coordinate representation of the dipole field in local sensor-centered frames, enabling partial decoupling of axial and radial parameters from azimuthal parameters and thereby reducing parameter coupling relative to conventional Cartesian formulations;(ii)a neural network-based residual calibration strategy that augments affine hard-iron and soft-iron compensation to address nonlinear and time-varying distortions in wearable operation;(iii)an experimentally validated four-sensor wearable magnetic localization system demonstrating accurate position and orientation estimation under both quasi-static and dynamic disturbance conditions; and(iv)a comparative evaluation against Cartesian localization and model-based calibration baselines, showing that the proposed framework achieves improved accuracy with a compact sensor configuration. (i)a two-stage magnetic localization framework that exploits a cylindrical-coordinate representation of the dipole field in local sensor-centered frames, enabling partial decoupling of axial and radial parameters from azimuthal parameters and thereby reducing parameter coupling relative to conventional Cartesian formulations; a two-stage magnetic localization framework that exploits a cylindrical-coordinate representation of the dipole field in local sensor-centered frames, enabling partial decoupling of axial and radial parameters from azimuthal parameters and thereby reducing parameter coupling relative to conventional Cartesian formulations; (ii)a neural network-based residual calibration strategy that augments affine hard-iron and soft-iron compensation to address nonlinear and time-varying distortions in wearable operation; a neural network-based residual calibration strategy that augments affine hard-iron and soft-iron compensation to address nonlinear and time-varying distortions in wearable operation; (iii)an experimentally validated four-sensor wearable magnetic localization system demonstrating accurate position and orientation estimation under both quasi-static and dynamic disturbance conditions; and an experimentally validated four-sensor wearable magnetic localization system demonstrating accurate position and orientation estimation under both quasi-static and dynamic disturbance conditions; and (iv)a comparative evaluation against Cartesian localization and model-based calibration baselines, showing that the proposed framework achieves improved accuracy with a compact sensor configuration. a comparative evaluation against Cartesian localization and model-based calibration baselines, showing that the proposed framework achieves improved accuracy with a compact sensor configuration. Methods This section outlines the fundamental components of the proposed magnetic-based localization framework. First, we present the magnetic dipole modelling and the two-stage cylindrical localization algorithm to accurately estimate the magnet’s position and orientation using a minimal number of sensors (four). Then, the calibration strategies employed to mitigate sensor distortions and environmental magnetic interference are described. Both model-based and neural network-based calibration methods are detailed, highlighting their roles in enhancing the accuracy and robustness of the localization process. Finally, we formulate a constrained search to select four sensor locations that minimize mean localization error under the simulated trajectories. Dipole modelling and two-stage magnetic localization Figure 1 illustrates the wearable magnetic localization configuration considered in this work. Four magnetic sensors are mounted on the surface of a belt with an elliptical cross-section to conform to the human abdomen. A permanent magnet embedded inside the capsule endoscope generates a magnetic field as the capsule traverses the gastrointestinal (GI) tract. Each sensor measures three orthogonal magnetic field components along the global Cartesian axes (X, Y, Z). Although the sensor belt geometry is elliptical, the magnetic field model is formulated in a cylindrical coordinate framework centered at the sensor array reference frame, as this choice enables a structured decomposition of the dipole field.Fig. 1Wearable four-sensor magnetic array mounted on an elliptical geometry belt, with the global cylindrical reference frame used for dipole modelling. Wearable four-sensor magnetic array mounted on an elliptical geometry belt, with the global cylindrical reference frame used for dipole modelling. The magnetic field generated by the magnetic capsule and sensed at sensor i is modeled using the standard magnetic dipole formulation1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{B}_i = B_T\left( \frac{3(\textbf{m}\cdot \textbf{r}_i)\textbf{r}_i}{\Vert \textbf{r}_i\Vert ^{5}} - \frac{\textbf{m}}{\Vert \textbf{r}_i\Vert ^{3}} \right) , \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}_i$$\end{document} denotes the displacement vector from the magnetic capsule to sensor i, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{m}$$\end{document} is the magnetic dipole moment of the magnet, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_T$$\end{document} is a constant determined by the magnet volume and magnetization intensity. Let the capsule position be parameterized in cylindrical coordinates as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m,\theta _m,z_m)$$\end{document} and the position of sensor i as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_{s_i},\theta _{s_i},z_{s_i})$$\end{document}. The corresponding Cartesian coordinates are2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} (x_m,y_m,z_m)=(r_m\cos \theta _m,r_m\sin \theta _m,z_m), \quad (x_{s_i},y_{s_i},z_{s_i})=(r_{s_i}\cos \theta _{s_i},r_{s_i}\sin \theta _{s_i},z_{s_i}). \end{aligned}$$\end{document} The displacement vector is therefore3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{r}_i= \begin{bmatrix} \Delta x_i\\ \Delta y_i\\ z_i \end{bmatrix} = \begin{bmatrix} x_{s_i}-x_m\\ y_{s_i}-y_m\\ z_{s_i}-z_m \end{bmatrix}, \qquad R_i=\Vert \textbf{r}_i\Vert =\sqrt{\Delta x_i^2+\Delta y_i^2+z_i^2}. \end{aligned}$$\end{document} To expose the structural properties of the dipole field, we define the transverse magnitude and bearing of the displacement vector as4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \rho _i=\sqrt{\Delta x_i^2+\Delta y_i^2}, \qquad \alpha _i=\operatorname {atan2}(\Delta y_i,\Delta x_i), \end{aligned}$$\end{document}so that \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}_i$$\end{document} can be equivalently expressed as5\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{r}_i= \begin{bmatrix} \rho _i\cos \alpha _i\\ \rho _i\sin \alpha _i\\ z_i \end{bmatrix}. \end{aligned}$$\end{document} Here, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m,\theta _m,z_m)$$\end{document} denote the global cylindrical coordinates of the magnet, while \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\rho _i$$\end{document} denotes the sensor-dependent transverse distance defined in Eq. (4). For each sensor, a local cylindrical frame is constructed by rotating the transverse plane about the global Z-axis by \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$-\alpha _i$$\end{document}, such that the local radial axis aligns with the transverse displacement direction. The corresponding rotation matrix is6\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{R}_z(-\alpha _i)= \begin{bmatrix} \cos \alpha _i & \sin \alpha _i & 0\\ -\sin \alpha _i & \cos \alpha _i & 0\\ 0 & 0 & 1 \end{bmatrix}. \end{aligned}$$\end{document} Applying this rotation yields7\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf{r}_i' = \textbf{R}_z(-\alpha_i)\,\mathbf{r}_i = [\rho_i, 0, z_i]^{\mathrm{T}}$$\end{document}and the dipole moment expressed in the same rotated frame becomes8\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf{m}'_i = R_z(-\alpha_i) \mathbf{m} = [m_{\rho, i}, m_{\theta, i}, m_{z, i}]^\top.$$\end{document} Substituting \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf{r}'_i$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\\mathbf{m}'_i$$\end{document} into (1) and projecting onto the global Cartesian axes yields the analytic expressions9\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \left\{ \begin{aligned} B_{x,i}&= \frac{B_T}{(\rho _i^{2}+z_i^{2})^{5/2}} \Big [ 3\rho _i\cos \alpha _i\,(m_{\rho ,i}\rho _i+m_{z,i}z_i) -(\rho _i^{2}+z_i^{2})\big (m_{\rho ,i}\cos \alpha _i-m_{\theta ,i}\sin \alpha _i\big ) \Big ],\\ B_{y,i}&= \frac{B_T}{(\rho _i^{2}+z_i^{2})^{5/2}} \Big [ 3\rho _i\sin \alpha _i\,(m_{\rho ,i}\rho _i+m_{z,i}z_i) -(\rho _i^{2}+z_i^{2})\big (m_{\rho ,i}\sin \alpha _i+m_{\theta ,i}\cos \alpha _i\big ) \Big ],\\ B_{z,i}&= \frac{B_T}{(\rho _i^{2}+z_i^{2})^{5/2}} \Big [ 3z_i\,(m_{\rho ,i}\rho _i+m_{z,i}z_i) -(\rho _i^{2}+z_i^{2})m_{z,i} \Big ]. \end{aligned} \right. \end{aligned}$$\end{document} In the rotated local frame defined by Eq. (9), the axial component \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_{z,i}$$\end{document} is independent of the bearing angle \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha _i$$\end{document} and the tangential dipole component \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_{\theta ,i}$$\end{document}. This follows directly from the analytical expression of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_{z,i}$$\end{document}, which depends only on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\rho _i$$\end{document}, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$z_i$$\end{document}, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_{\rho ,i}$$\end{document}, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_{z,i}$$\end{document}, and does not explicitly include \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha _i$$\end{document} or \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_{\theta ,i}$$\end{document}. Accordingly, the following relations hold in the local frame:10\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \frac{\partial B_{z,i}}{\partial \alpha _i}=0, \qquad \frac{\partial B_{z,i}}{\partial m_{\theta ,i}}=0. \end{aligned}$$\end{document} Although \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha _i$$\end{document} is a function of the global magnet position, its influence is eliminated in the rotated local frame representation, resulting in the observed invariance of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_{z,i}$$\end{document} with respect to azimuthal parameters. This structural invariance implies that, in the rotated cylindrical representation, the axial magnetic field component is decoupled from azimuthal variables. As a result, the Jacobian of the measurement model with respect to the parameter vector exhibits a partially block-diagonal structure, where the sensitivity of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\{B_{z,i}\}$$\end{document} is confined to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m, z_m, m_{\rho }, m_z)$$\end{document} and does not depend on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(\theta _m, m_{\theta })$$\end{document}. Accordingly, the Jacobian of the measurement model admits a structured form in which the axial measurements depend only on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m, z_m, m_{\rho }, m_z)$$\end{document}, while the transverse components depend on both axial and azimuthal parameters. This property enables the formulation of a staged estimation strategy in which axial measurements are first used to estimate \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m, z_m, m_{\rho }, m_z)$$\end{document} independently, followed by azimuthal refinement using transverse components \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(B_{x,i}, B_{y,i})$$\end{document}. By reducing parameter coupling, this decomposition improves numerical conditioning and stabilizes the optimization process under sparse sensor configurations. It should be noted that this decoupling holds exactly under the ideal dipole model in the rotated local frame. In practical settings, residual coupling may arise due to measurement noise, sensor misalignment, and model mismatch. However, as demonstrated in the experimental results, the proposed staged formulation remains robust and yields consistent improvements in localization accuracy. Algorithm 1Two-stage cylindrical localization algorithm. Two-stage cylindrical localization algorithm. In the first stage, only the axial measurements \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\{B_{z,i}\}$$\end{document} are used to estimate the radial and axial magnet position \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m,z_m)$$\end{document} together with the corresponding dipole components \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(m_{\rho },m_z)$$\end{document}. In the second stage, the azimuthal position \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\theta _m$$\end{document} and tangential dipole component \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_{\theta }$$\end{document} are refined using the transverse measurements \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\{B_{x,i},B_{y,i}\}$$\end{document} while keeping the stage-1 estimates fixed. The full magnet state is defined as11\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{x}=[r_m,\theta _m,z_m,m_{\rho },m_{\theta },m_{z}]^\top , \end{aligned}$$\end{document}representing the magnet position and magnetic dipole moment parameters in cylindrical form. NN-based calibration process Model-based calibration methods typically rely on optimization algorithms to minimize error functions defined over sensor and system parameters. These methods commonly account for hard-iron effects, constant magnetic disturbances, and soft-iron effects, which introduce field-dependent distortions. The conventional calibration model for sensor i is expressed as12\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \begin{bmatrix} B_{i,cx}\\ B_{i,cy}\\ B_{i,cz} \end{bmatrix} = \textbf{S}_i \begin{bmatrix} B_{i,mx}\\ B_{i,my}\\ B_{i,mz} \end{bmatrix} + \textbf{H}_i, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{S}_i \in \mathbb {R}^{3\times 3}$$\end{document} is the soft-iron distortion matrix for sensor i, accounting for scaling and shearing effects caused by nearby ferromagnetic materials, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{H}_i \in \mathbb {R}^{3}$$\end{document} is the hard-iron bias vector, which also captures constant offsets such as the Earth’s magnetic field contribution. The calibration parameters \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{S}_i$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{H}_i$$\end{document} are estimated by minimizing the discrepancy between measured magnetic fields and theoretical values derived from the dipole model using the Levenberg–Marquardt (LM) algorithm. The calibration problem is formulated as a nonlinear least-squares optimization with the objective function13\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} E(\textbf{S},\textbf{H}) = \sum _{i=1}^{4} \left\| \textbf{S}_i \textbf{B}_{i,m} + \textbf{H}_i - \textbf{B}_{i,\text {true}} \right\| ^{2}, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}_{i,\text {true}}$$\end{document} denotes the theoretical magnetic field generated by the magnet along a predefined trajectory at sensor i. Minimization of (13) yields the optimal calibration parameters, which are subsequently applied to correct new sensor measurements.Fig. 2Neural network-based multi-sensor calibration framework. Neural network-based multi-sensor calibration framework. While model-based calibration methods perform reliably under controlled and static conditions, they assume fixed sensor configurations and stationary magnetic environments. In wearable capsule endoscopy systems, patient motion, belt deformation, and sensor reorientation introduce time-varying and nonlinear distortions that cannot be fully compensated by affine calibration alone. To address these limitations, a neural network (NN)-based calibration approach, illustrated in Fig. 2, is employed to learn a residual correction mapping directly from measured magnetic field data. In this work, calibration is formulated as learning a mapping from distorted measurements to dipole-consistent magnetic fields, rather than explicitly estimating physical sensor parameters. For a wearable array consisting of four tri-axial sensors, the concatenated input vector at sample k is defined as14\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{x}_k = \begin{bmatrix} \textbf{B}_{m,1,k}^\top&\textbf{B}_{m,2,k}^\top&\textbf{B}_{m,3,k}^\top&\textbf{B}_{m,4,k}^\top \end{bmatrix}^\top \in \mathbb {R}^{12}, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}_{m,i,k} \in \mathbb {R}^{3}$$\end{document} denotes the measured magnetic field of sensor i at sample k. In the multi-sensor formulation, the single-sensor calibration parameters are extended as15\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{M} = \textrm{blkdiag}(\textbf{S}_1,\textbf{S}_2,\textbf{S}_3,\textbf{S}_4), \qquad \textbf{o} = \begin{bmatrix} \textbf{H}_1^\top&\textbf{H}_2^\top&\textbf{H}_3^\top&\textbf{H}_4^\top \end{bmatrix}^\top , \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textrm{blkdiag}(\cdot )$$\end{document} constructs a block-diagonal matrix applying each soft-iron correction independently. The calibrated output is computed as16\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{y}_k = \textbf{M}\textbf{x}_k + \textbf{o} + \textbf{r}(\tilde{\textbf{x}}_k), \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\tilde{\textbf{x}}_k$$\end{document} denotes the normalized input vector and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}(\cdot )$$\end{document} represents a neural network-based residual correction term. The output \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{y}_k \in \mathbb {R}^{12}$$\end{document} represents the calibrated magnetic field vector obtained by correcting the raw multi-sensor measurements, and serves as the input to the subsequent localization stage. This formulation preserves the physical affine calibration model while allowing the neural network to compensate for residual nonlinear and time-varying distortions. The residual network \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}(\cdot )$$\end{document} is implemented as a fully connected feedforward neural network with three hidden layers comprising \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\{64, 64, 32\}$$\end{document} neurons, respectively. Rectified linear unit (ReLU) activations are used in all hidden layers. Both input and output layers have dimension 12, corresponding to the concatenated tri-axial measurements of the four sensors. Prior to training, each input channel is normalized to zero mean and unit variance to improve numerical stability. Normalization statistics are computed per input channel using the training dataset and are applied consistently to validation and test samples. The selected network architecture (64-64-32) was determined empirically based on validation performance and generalization behavior. To justify this choice, we evaluated simpler network configurations with reduced capacity. Smaller architectures (e.g., 32-32 and 64-32) resulted in higher validation error, indicating insufficient model capacity to capture nonlinear sensor distortions. In contrast, larger networks (e.g., 128-128-64) did not provide significant performance improvement while increasing the risk of overfitting and computational cost. Therefore, the chosen architecture provides a balanced trade-off between accuracy, generalization, and computational efficiency for the considered dataset and wearable setting. The network is trained offline using reference magnetic field values generated from known magnet poses via the analytical dipole model. Training minimizes the mean squared error between the network output and the reference magnetic field using backpropagation with the Adam optimizer. Early stopping based on validation loss is employed to mitigate overfitting. Once trained, the network introduces negligible inference overhead relative to the overall localization pipeline and is applied as a deterministic correction during online localization. The neural network is trained using the Adam optimizer with a learning rate of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$10^{-3}$$\end{document} and a batch size of 128. Training is performed for a maximum of 300 epochs, with early stopping applied if the validation loss does not improve for 20 consecutive epochs. No explicit weight decay or dropout is used, as overfitting was effectively mitigated through input normalization and early stopping. Optimal sensor layout design To ensure robust magnetic localization with minimal sensor redundancy, a constraint-based algorithm is developed to optimize sensor placement on an ellipse-based cylindrical array surrounding the human body. The placement region is defined as a cylinder of height h and major and minor axes a and b, respectively, with sensor positions restricted to integer-coordinate locations to reflect hardware limitations and reduce the search space. The objective is to select four sensor positions that minimize localization error while satisfying physical and geometric constraints. The ellipse-based cylindrical sensor array is divided into four equal surface quarters (Q1–Q4), each assigned a distinct region, as illustrated in Fig. 3. Figure 3a shows the three-dimensional cylinder with height h and elliptical cross-section defined by a and b, while Fig. 3b presents the unwrapped surface, where each quarter forms a rectangular region of height h and width \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi (a+b)/4$$\end{document}. These regions define the allowable zones for sensor placement, ensuring one sensor per quarter in accordance with the spatial constraints of the placement algorithm.Fig. 3(a) Ellipse-based cylindrical sensor array with height h and major and minor axes a and b, divided into four surface quarters (Q1–Q4). (b) Unwrapped surface representation, where each quarter forms a rectangle of size \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi (a+b)/4 \times h$$\end{document}. (a) Ellipse-based cylindrical sensor array with height h and major and minor axes a and b, divided into four surface quarters (Q1–Q4). (b) Unwrapped surface representation, where each quarter forms a rectangle of size \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi (a+b)/4 \times h$$\end{document}. The algorithm begins by enumerating all valid sensor positions on the elliptical cylindrical surface that satisfy17\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \frac{4(x-x_c)^2}{a^2} + \frac{4(y-y_c)^2}{b^2} = 1, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(x_c,y_c)$$\end{document} denotes the center of the elliptical cross-section and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$z\in [0,h]$$\end{document} spans the cylinder height. From this candidate set, all possible four-sensor combinations are generated. To eliminate impractical configurations, only those satisfying the following constraints are retained: (i) the Euclidean distance between any pair of sensors must be at least \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d_{\min }=5$$\end{document} cm to avoid magnetic interference 20; (ii) the vertical separation between any two sensors must be at least 5 cm to ensure coverage along the z-axis 20; and (iii) each sensor must lie in a distinct surface quarter (Q1–Q4), ensuring full \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$360^{\circ }$$\end{document} angular coverage around the magnetic capsule trajectory. Each valid configuration is evaluated using the dipole localization framework. For every candidate layout, a predefined set of magnet trajectories is used to simulate sensor measurements, followed by the two-stage localization algorithm described in Algorithm 1 to estimate the magnet position and orientation. Localization performance is quantified as the mean Euclidean distance between the true and estimated magnet positions over all trajectory points. The configuration yielding the minimum average localization error is selected as the optimal sensor layout. To reduce computational complexity, the symmetry of the cylindrical surface is exploited by fixing the position of the first sensor in quadrant Q1, thereby reducing the combinatorial search space while preserving full angular coverage. Since abdominal dimensions vary across individuals 36,37, simulations are conducted for multiple values of a and b. Figure 4 shows the resulting optimal sensor layouts for different elliptical cross-sections, with position error reported as the mean over all evaluated magnet trajectories. Algorithm 2Optimal sensor array configuration Fig. 4Optimal sensor layouts for different elliptical cross-sections. Sensor layouts projected onto the ellipse for the evaluated (a, b) combinations. Red markers denote sensors \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S_1$$\end{document}–\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S_4$$\end{document}. Optimal sensor array configuration Optimal sensor layouts for different elliptical cross-sections. Sensor layouts projected onto the ellipse for the evaluated (a, b) combinations. Red markers denote sensors \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S_1$$\end{document}–\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S_4$$\end{document}. Hardware and experimental setup As illustrated in Fig. 5, the proposed system consists of a wearable platform developed for magnetic localization in wireless capsule endoscopy. Four LIS3MDL magnetometers are mounted on an elastic belt structure and positioned at four key locations around the abdomen, namely the front, back, left, and right sides of the torso. The sensors are interfaced through a SparkFun I2C multiplexer, which communicates with an Arduino Nano 33 BLE Sense via a shared I2C bus. The Arduino controller is placed at the back of the belt to minimize obstruction and wiring complexity. This wearable configuration enables high-resolution magnetic field measurements surrounding the torso and serves as the experimental platform for validating the proposed localization framework.Fig. 5Wearable experimental setup for magnetic capsule localization. (a) Front view. (b) Back view. Wearable experimental setup for magnetic capsule localization. (a) Front view. (b) Back view. Magnet pose specification and ground truth All experimental data were collected using a robotic-arm-assisted measurement setup that provides precise and repeatable control of the magnet pose relative to the wearable sensor array. At each time index t, the magnet pose is defined by its position \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}_m(t)=[x_m(t),y_m(t),z_m(t)]^\top$$\end{document} and magnetic dipole moment orientation \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{m}(t)$$\end{document}. Robotic positioning: The magnetic capsule was rigidly mounted to the end-effector of a robotic arm, which executed predefined three-dimensional trajectories within the sensing volume of the wearable belt. The robot’s forward kinematics (from joint encoders) provide the end-effector pose. The resulting Cartesian poses were converted to the cylindrical parameterization \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(r_m,\theta _m,z_m)$$\end{document} used in the localization model. Ground-truth reference accuracy: The robotic arm used in the experiments is a low-cost, educational 6-DOF manipulator actuated by MG996R analog servo motors, for which the manufacturer does not provide formal specifications on end-effector positional or angular accuracy. Accordingly, the arm was used as a relative positioning device, and its repeatability was empirically characterized through repeated returns to taught poses. Based on these trials, the resulting pose uncertainty was on the order of a few millimeters in position and within approximately one degree in orientation. These values are treated as conservative bounds on the reference pose uncertainty for all reported localization errors. Any residual uncertainty introduced by the magnet mounting fixture is negligible relative to this empirically assessed repeatability. This level of uncertainty introduces a practical lower bound on the achievable localization accuracy. Consequently, reported errors that approach this scale should be interpreted in the context of the ground-truth resolution, rather than as strictly absolute physical accuracy. In particular, localization errors on the order of a few millimeters are inherently influenced by the reference system uncertainty, and therefore represent performance approaching the measurement resolution of the experimental setup. Reference magnetic field generation: For each recorded robotic pose, the corresponding dipole-consistent reference magnetic field \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}^{\textrm{true}}(t)$$\end{document} was computed using the analytical dipole model in Eq. (1) with known sensor locations. These reference fields serve as supervised targets for NN-based calibration and as the basis for quantitative localization error evaluation in Eq. (19) In this work, localization error is evaluated under two distinct operating conditions, referred to as static and dynamic scenarios. Static localization error corresponds to experiments in which the sensor array and reference frame remain fixed, and the magnet follows controlled trajectories without relative motion between the wearable belt and the body. In this case, the error primarily reflects sensor noise, calibration accuracy, and model mismatch. In contrast, dynamic localization error refers to scenarios in which time-varying disturbances are introduced due to relative motion between the sensor array and the magnet, such as belt deformation, sensor reorientation, and environmental magnetic variations. Under these conditions, the measured magnetic field deviates from the nominal dipole model, and the resulting error captures the robustness of the calibration and localization framework to such disturbances. Results This section presents a comprehensive evaluation of the proposed magnetic localization framework, with emphasis on calibration accuracy, localization performance, robustness, and computational efficiency. The experimental study includes validation of the proposed two-stage localization algorithm, analysis of neural network-based calibration under both static and dynamic conditions, and optimization of sensor placement on the wearable platform. The performance of the calibration methods is evaluated using two primary metrics: validation loss and downstream localization accuracy. The validation loss quantifies the network’s ability to map raw magnetic sensor measurements to their corresponding calibrated magnetic field values. It is computed as the mean \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\ell _2$$\end{document} norm between the predicted and ground-truth magnetic field vectors over a held-out validation dataset. This metric is defined as18\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \mathscr {L}_{\textrm{val}} = \frac{1}{N} \sum _{i=1}^{N} \left\Vert \hat{\textbf{B}}_{i} - \textbf{B}^{\textrm{true}}_{i} \right\Vert _{2}, \end{aligned}$$\end{document}where N denotes the number of validation samples, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\hat{\textbf{B}}_{i}$$\end{document} represents the calibrated magnetic field vector predicted by the network for the ith sample, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}^{\textrm{true}}_{i}$$\end{document} denotes the corresponding ground-truth magnetic field obtained from the analytical dipole model. Since the primary objective of calibration is to improve localization accuracy, performance is further evaluated using position and orientation errors computed over a complete magnet trajectory. The localization error is defined as19\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \begin{aligned} \mathscr {E}_{\textrm{loc}} = {\left\{ \begin{array}{ll} \displaystyle \frac{1}{T} \sum _{t=1}^{T} \left\Vert \hat{\textbf{r}}_{m}^{(t)} - \textbf{r}_{m}^{(t)} \right\Vert _{2}, & \text {(Position)} \\ \displaystyle \frac{1}{T} \sum _{t=1}^{T} \cos ^{-1} \left( \frac{ \hat{\textbf{m}}^{(t)} \cdot \textbf{m}^{(t)} }{ \left\Vert \hat{\textbf{m}}^{(t)} \right\Vert \left\Vert \textbf{m}^{(t)} \right\Vert } \right) , & \text {(Orientation)} \end{array}\right. } \end{aligned} \end{aligned}$$\end{document}where T denotes the number of time steps in the evaluated magnet trajectory, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\hat{\textbf{r}}_{m}^{(t)}$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\hat{\textbf{m}}^{(t)}$$\end{document} represent the estimated magnet position and magnetic moment orientation at time step t, respectively, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{r}_{m}^{(t)}$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{m}^{(t)}$$\end{document} denote the corresponding ground-truth position and orientation. Neural network training data generation The neural network used for calibration is trained using experimentally acquired magnetic field measurements collected with the wearable four-sensor setup described in Section “Hardware and experimental setup”. Data are recorded while the magnet is moved through predefined three-dimensional trajectories within the sensing volume. For each time sample, the tri-axial measurements from the four sensors are concatenated to form a 12-dimensional input vector. Reference targets for supervised training are computed from the analytical dipole model in Section “Dipole modelling and two-stage magnetic localization” using the known sensor locations and the magnet pose associated with each recorded sample. The magnet pose for each sample is obtained directly from the robotic arm end-effector measurements, providing ground-truth position and orientation for reference field generation. The measured signals are therefore mapped to dipole-consistent magnetic fields, enabling the network to learn residual corrections that compensate sensor distortion and misalignment effects observed in the experimental setup. The neural network is trained to project measured magnetic fields onto the dipole-consistent field manifold, rather than to estimate magnet pose or physical sensor parameters directly. It is important to note that, although the reference targets are generated using the analytical dipole model, the input data consist of experimentally acquired magnetic field measurements that include real sensor noise, bias, and misalignment effects. As a result, the neural network does not simply learn the dipole model, but instead learns to project distorted measurements onto a dipole-consistent field representation. This formulation enables the model to compensate for practical distortions while preserving the physical structure of the magnetic field. Furthermore, generalization is promoted through trajectory-level data partitioning and the use of unseen motion patterns and disturbance conditions during testing. The experimental results under dynamic disturbances demonstrate that the trained network maintains performance in the presence of time-varying noise and misalignment, indicating its ability to generalize beyond the training conditions. The dataset consists of approximately 20,000 samples and is partitioned into training, validation, and test sets using a 70%/15%/15% split at the trajectory level. Entire magnet trajectories are assigned exclusively to one subset, such that no trajectory contributes samples to more than one set. This strategy prevents temporal correlation leakage and enforces generalization to unseen motion patterns. Magnet trajectories used for testing are distinct from those used during training. During training, mild random perturbations are applied to the sensor measurements to improve robustness, while stronger and time-varying disturbances are reserved exclusively for testing. All normalization statistics are computed using the training set only and applied unchanged to validation and test data. To justify the selected network architecture, a comparison with simpler and larger models is provided in Table 1.Table 1Comparison of neural network architectures for calibration.ArchitectureValidation error (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)32-325.864-324.664-64-32 (proposed)3.5128-128-643.4 Table 1Comparison of neural network architectures for calibration.ArchitectureValidation error (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)32-325.864-324.664-64-32 (proposed)3.5128-128-643.4 Comparison of neural network architectures for calibration. The results confirm that the proposed architecture achieves near-optimal performance while maintaining lower model complexity compared to larger networks. Two-stage magnet localization The sensor array consists of four LIS3MDL magnetic sensors mounted on an elastic belt, as illustrated in Fig. 5. This configuration enables magnetic field measurements to be collected from multiple angular and axial locations surrounding the magnet trajectory. Table 2 compares the localization accuracy of two localization strategies, namely Cartesian and cylindrical formulations, both operating under model-based calibration. The Cartesian baseline estimates the magnet position and orientation parameters \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(x_m, y_m, z_m, m_x, m_y, m_z)$$\end{document} using a Levenberg–Marquardt (LM) optimizer applied to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(B_x, B_y, B_z)$$\end{document} measurements from all sensors. The same parameter bounds and termination criteria are used for both methods to ensure a fair comparison. While the Cartesian approach achieves a mean localization error of 0.35 cm, it incurs relatively high computational complexity due to the fully coupled six-dimensional optimization problem. In contrast, the proposed cylindrical localization algorithm achieves a lower localization error of 0.25 cm with reduced computational complexity. This improvement arises from the structural decoupling enabled by the \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_z$$\end{document} component in Eq. (9), which allows the radial and axial parameters to be estimated independently during the first optimization stage, thereby reducing the number of jointly estimated variables. Unless otherwise stated, all results reported in this subsection assume a fixed wearable belt and a controlled magnet trajectory, with no relative motion between the belt and the torso.Table 2Localization accuracy comparison between Cartesian and cylindrical algorithms.AlgorithmCalibration# SensorsAccuracy (cm)ComplexityCartesianModel-based calibration40.35HighCylindricalModel-based calibration40.25Low Table 2Localization accuracy comparison between Cartesian and cylindrical algorithms.AlgorithmCalibration# SensorsAccuracy (cm)ComplexityCartesianModel-based calibration40.35HighCylindricalModel-based calibration40.25Low Localization accuracy comparison between Cartesian and cylindrical algorithms. These results are obtained under controlled quasi-static conditions with no relative motion between the wearable belt and the sensor array reference frame. The reported complexity levels reflect relative computational cost based on the dimensionality of the optimization problem and the number of jointly estimated parameters, rather than asymptotic complexity. Figure 6 illustrates the estimated and ground-truth values of key localization parameters obtained using the proposed two-stage cylindrical algorithm. The estimated radial distance \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$r_m$$\end{document}, axial position \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$z_m$$\end{document}, angular position \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\theta _m$$\end{document}, and magnetic moment components \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(m_{\rho }, m_{\theta }, m_{z})$$\end{document} closely follow their corresponding ground-truth values, demonstrating accurate and stable localization performance under noisy measurement conditions.Fig. 6Estimated (blue) versus ground-truth (red) values of position and magnetic moment components along the magnet trajectory using the proposed two-stage cylindrical localization algorithm. Estimated (blue) versus ground-truth (red) values of position and magnetic moment components along the magnet trajectory using the proposed two-stage cylindrical localization algorithm. Although localization accuracy can be further improved by increasing the number of sensors, this work intentionally restricts the system to four sensors to maintain low computational complexity and wearable feasibility. Owing to the wearable nature of the sensor belt, the system is inherently susceptible to magnetic distortions and measurement noise, which can degrade localization accuracy, particularly along the axial (z) direction. To address these challenges, a neural network–based calibration framework is employed to enhance robustness and ensure reliable localization under realistic operating conditions. The following subsection presents experimental results demonstrating the effectiveness of the proposed NN-based calibration in comparison with model-based calibration approaches. Quasi-static magnetic capsule motion (fixed sensor frame) This subsection investigates quasi-static operating conditions, defined as a fixed sensor frame with controlled magnetic capsule motion and no relative movement between the patient and the wearable belt. Under this assumption, the proposed neural network (NN)–based calibration framework is evaluated and compared with model-based calibration methods using validation loss and localization error as the primary performance metrics. Figure 7 illustrates a baseline experimental scenario in which the magnet follows a straight trajectory with a fixed axial (z) position, emulating a resting patient condition. The validation error is defined as the mean absolute deviation between the calibrated magnetic sensor measurements and the corresponding theoretical magnetic field values generated by the analytical dipole model.Fig. 7Test setup for quasi-static magnetic capsule motion inside the cylindrical magnetic sensor configuration. Test setup for quasi-static magnetic capsule motion inside the cylindrical magnetic sensor configuration. Calibration results for sensor S1 are shown in Fig. 8, comparing model-based and NN-based calibration methods. Sensor S1 is presented as a representative example, as similar trends were consistently observed across the remaining sensors. The NN-based approach effectively suppresses measurement noise and improves alignment with the theoretical magnetic field across all three components \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(B_x, B_y, B_z)$$\end{document}. The trained network achieved a validation error of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2~\mu \text {T}$$\end{document} on the training set and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$3.5~\mu \text {T}$$\end{document} on the test set. Following calibration, the mean localization error was reduced to 0.12 cm, demonstrating the effectiveness of the proposed method in enhancing both signal quality and localization accuracy. It is important to interpret the reported localization accuracy in the context of the ground-truth uncertainty introduced by the robotic positioning system. As detailed in Section Hardware and Experimental Setup, the reference pose accuracy is on the order of a few millimeters in position and approximately \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1^\circ$$\end{document} in orientation. Consequently, localization errors approaching this scale are inherently influenced by the uncertainty of the reference system. In particular, the measured localization error \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_{\text {meas}}$$\end{document} can be interpreted as a combination of the true estimation error and the reference uncertainty. Therefore, the reported accuracy should be viewed as approaching the resolution limit of the experimental setup rather than absolute physical accuracy. Despite this limitation, the relative performance improvements observed between model-based and NN-based calibration methods remain significantly larger than the estimated ground-truth uncertainty, confirming that the reported gains are consistent and not dominated by measurement noise or reference inaccuracies.Fig. 8Calibration results for sensor S1 using model-based and NN-based methods on training (left) and test (right) datasets. Blue curves represent theoretical magnetic fields; green curves indicate raw measurements; black and red markers denote traditionally calibrated and NN-calibrated outputs, respectively. Calibration results for sensor S1 using model-based and NN-based methods on training (left) and test (right) datasets. Blue curves represent theoretical magnetic fields; green curves indicate raw measurements; black and red markers denote traditionally calibrated and NN-calibrated outputs, respectively. The experiment depicted in Fig. 7 was repeated for multiple magnet heights along the axial direction. The corresponding quantitative results are summarized in Table 3. As shown, the NN-based calibration consistently reduces both validation error and localization error (positional and orientational) across all evaluated magnet heights, confirming its robustness under quasi-static conditions.Table 3Validation and localization error comparison between model-based and NN-based calibration at different magnet heights.Height (cm)Valid. error trad. (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)Loc. error trad. (cm, deg)Valid. error NN (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)Loc. error NN (cm, deg)09.7(0.48, 3.5)7.0(0.12, 2.1)511.4(0.55, 3.2)7.8(0.11, 2.0)108.4(0.44, 3.2)6.4(0.11, 2.0)157.5(0.41, 3.1)6.1(0.10, 1.9)208.9(0.46, 3.2)6.4(0.11, 1.9)258.9(0.46, 3.2)6.5(0.11, 2.0)3011.5(0.56, 3.4)7.9(0.12, 2.1) Table 3Validation and localization error comparison between model-based and NN-based calibration at different magnet heights.Height (cm)Valid. error trad. (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)Loc. error trad. (cm, deg)Valid. error NN (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\upmu$$\end{document}T)Loc. error NN (cm, deg)09.7(0.48, 3.5)7.0(0.12, 2.1)511.4(0.55, 3.2)7.8(0.11, 2.0)108.4(0.44, 3.2)6.4(0.11, 2.0)157.5(0.41, 3.1)6.1(0.10, 1.9)208.9(0.46, 3.2)6.4(0.11, 1.9)258.9(0.46, 3.2)6.5(0.11, 2.0)3011.5(0.56, 3.4)7.9(0.12, 2.1) Validation and localization error comparison between model-based and NN-based calibration at different magnet heights. NN-based calibration under dynamic measurement conditions Magnetic capsule localization is highly sensitive to dynamic measurement disturbances arising during realistic operation, including magnetic capsule’s motion, changes in sensor-magnet alignment, and variations in the surrounding magnetic environment. These effects introduce additional distortions and noise into the measured magnetic field, which can substantially degrade localization accuracy if not properly compensated. Dynamic disturbance modelling: To emulate realistic wearable conditions, dynamic measurement disturbances are introduced to represent relative motion between the sensor belt and the magnetic capsule. These disturbances model belt deformation, posture-induced sensor reorientation, and slowly varying magnetic bias effects commonly observed in wearable magnetic localization systems. Specifically, each sensor measurement is subjected to a time-varying rigid-body rotation \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{R}_i(t)$$\end{document} applied to the nominal magnetic field vector, where the rotation angles about the global axes are bounded within \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pm 3^\circ$$\end{document}. This range is consistent with moderate belt slippage and torso motion during normal patient activity. In addition, a slowly varying bias drift with magnitude up to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pm 5~\upmu \textrm{T}$$\end{document} is added to each magnetic field component, together with zero-mean Gaussian measurement noise with standard deviation \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1~\upmu \textrm{T}$$\end{document}. These dynamic disturbances are applied exclusively during testing and evaluation and are not included in the neural network training data, ensuring that performance gains reflect true robustness rather than memorization of disturbance patterns. Unless otherwise stated, the dynamic disturbance results presented in this section are obtained by numerically applying the disturbance model described above to experimentally acquired magnetic measurements, while retaining robotic-arm ground-truth magnet poses. The selected disturbance ranges are conservative and are intended to represent typical wearable motion rather than extreme failure cases. Figure 9 illustrates a representative dynamic scenario. While the magnetic capsule follows a smooth trajectory, the wearable sensor array may undergo orientation changes due to belt deformation or patient posture variation. These effects perturb the relative dipole—sensor geometry, causing the measurements to deviate from the dipole-model-consistent fields assumed during localization.Fig. 9Measurement disturbances induced by relative motion between the capsule trajectory and the wearable magnetic sensor array, resulting in misalignment between measured and theoretical magnetic fields. Measurement disturbances induced by relative motion between the capsule trajectory and the wearable magnetic sensor array, resulting in misalignment between measured and theoretical magnetic fields. Figure 10 summarizes results under dynamic disturbances. The disturbance index is defined as20\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} DI(t)=\frac{\left\Vert \textbf{B}_{\textrm{dist}}^{m}(t)-\textbf{B}_{\textrm{nom}}^{m}(t)\right\Vert _2}{\left\Vert \textbf{B}_{\textrm{nom}}^{m}(t)\right\Vert _2}, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}_{\textrm{dist}}^{m}(t)$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{B}_{\textrm{nom}}^{m}(t)$$\end{document} denote the concatenated 12-dimensional magnetic measurement vectors from all four sensors under disturbed and nominal conditions, respectively. The disturbance index is used solely to characterize disturbance severity and is not provided to the calibration or localization algorithms. Figure 10a shows the disturbance index along the trajectory. Figure 10b compares a representative magnetic-field component among the theoretical field, disturbed measurements, and calibrated outputs. Model-based calibration reduces systematic bias but leaves disturbance-correlated residual errors, whereas NN-based calibration better compensates disturbance-induced nonlinearities, producing measurements that more closely follow the dipole-consistent field. Consequently, Fig. 10c shows a clear reduction in localization error with NN-based calibration, improving both the mean error and its variability.Fig. 10Experimental evaluation under dynamic measurement disturbances: (a) disturbance index, (b) magnetic field alignment after calibration, and (c) localization error comparison. Experimental evaluation under dynamic measurement disturbances: (a) disturbance index, (b) magnetic field alignment after calibration, and (c) localization error comparison. Table 4 reports average performance across both quasi-static and dynamic disturbance scenarios as described in “Quasi-static magnetic capsule motion (fixed sensor frame)” and “NN-based calibration under dynamic measurement conditions”. To further assess performance, NN-based calibration is compared with the model-based calibration approach in (13) for different numbers of sensors. Both calibration methods are combined with Cartesian and cylindrical localization algorithms.Table 4Comparison of localization algorithms in terms of accuracy and complexity. Errors are reported as mean ± standard deviation. The table also serves as an ablation-style analysis illustrating the contribution of calibration method, localization strategy, and sensor count.Loc. Alg.Cal. Alg.#Sens.Static Err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Dynamic Err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Loc. Comp.Cal. Comp.CartesianModel-based4(0.65 ± 0.25, 8.0 ± 2.1)(0.98 ± 0.45, 13.5 ± 2.7)ModerateLowCartesianModel-based8(0.41 ± 0.2, 6.5 ± 2.01)(0.75 ± 0.24, 10.5 ± 3.4)Mod.–HighLowCylindricalModel-based4(0.35 ± 0.18, 6.1 ± 1.8)(0.70 ± 0.33, 9.4 ± 2.1)ModerateLowCylindricalModel-based8(0.38 ± 0.11, 5.7 ± 1.54)(0.54 ± 0.33, 7.5 ± 1.87)Mod.–HighLowCartesianNN-based4(0.55 ± 0.15, 6.2 ± 1.01)(0.82 ± 0.24, 9.1 ± 1.95)ModerateModerateCylindricalNN-based4(0.12 ± 0.05, 1.1 ± 0.54)(0.20 ± 0.09, 2.1 ± 0.87)ModerateModerate Table 4Comparison of localization algorithms in terms of accuracy and complexity. Errors are reported as mean ± standard deviation. The table also serves as an ablation-style analysis illustrating the contribution of calibration method, localization strategy, and sensor count.Loc. Alg.Cal. Alg.#Sens.Static Err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Dynamic Err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Loc. Comp.Cal. Comp.CartesianModel-based4(0.65 ± 0.25, 8.0 ± 2.1)(0.98 ± 0.45, 13.5 ± 2.7)ModerateLowCartesianModel-based8(0.41 ± 0.2, 6.5 ± 2.01)(0.75 ± 0.24, 10.5 ± 3.4)Mod.–HighLowCylindricalModel-based4(0.35 ± 0.18, 6.1 ± 1.8)(0.70 ± 0.33, 9.4 ± 2.1)ModerateLowCylindricalModel-based8(0.38 ± 0.11, 5.7 ± 1.54)(0.54 ± 0.33, 7.5 ± 1.87)Mod.–HighLowCartesianNN-based4(0.55 ± 0.15, 6.2 ± 1.01)(0.82 ± 0.24, 9.1 ± 1.95)ModerateModerateCylindricalNN-based4(0.12 ± 0.05, 1.1 ± 0.54)(0.20 ± 0.09, 2.1 ± 0.87)ModerateModerate Comparison of localization algorithms in terms of accuracy and complexity. Errors are reported as mean ± standard deviation. The table also serves as an ablation-style analysis illustrating the contribution of calibration method, localization strategy, and sensor count. Ablation analysis To evaluate the contribution of the main components of the proposed framework, an ablation-style analysis is performed based on the comparative results in Table 4. Specifically, three factors are examined: (i) the effect of NN-based calibration, (ii) the effect of the two-stage cylindrical decoupling strategy, and (iii) the influence of the number of sensors. Standard deviations are reported together with mean errors to quantify variability and assess result stability. First, comparing model-based and NN-based calibration under the same localization algorithm and sensor configuration shows that NN-based calibration consistently reduces both static and dynamic localization errors, demonstrating its effectiveness in compensating nonlinear and time-varying distortions beyond affine correction. Second, comparing Cartesian and cylindrical localization under the same calibration method highlights the contribution of the proposed two-stage decoupling strategy. The cylindrical formulation achieves lower localization error with lower effective optimization complexity, indicating that the decoupled structure improves estimation stability. Third, increasing the number of sensors from 4 to 8 improves localization accuracy for both calibration methods, as expected. However, the proposed cylindrical localization with NN-based calibration achieves the best overall performance using only four sensors, demonstrating the efficiency of the framework for compact wearable implementations. Overall, NN-based calibration consistently outperforms model-based calibration under both static and dynamic conditions across all evaluated configurations. When combined with cylindrical localization, the proposed approach achieves the lowest errors, reaching 0.12 cm and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1.1^\circ$$\end{document} (static) and 0.20 cm and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2.1^\circ$$\end{document} (dynamic) using only four sensors, demonstrating that comparable localization accuracy can be achieved with a compact wearable array. Across configurations, cylindrical localization generally yields higher accuracy than Cartesian localization regardless of calibration method, with the advantage becoming more pronounced as the sensor count increases. Although NN-based calibration introduces moderate additional computational cost compared with affine calibration, the gain in robustness under dynamic disturbances justifies this overhead. Importantly, the localization pipeline remains of moderate complexity, supporting practical deployment in wearable magnetic localization systems. Discussion Experimental results demonstrate that the proposed magnetic capsule localization system achieves low localization error under both static and dynamic measurement conditions while maintaining moderate algorithmic complexity. As summarized in Table 4, the combination of NN-based calibration and LM-based cylindrical localization achieves the lowest static localization error (0.12 cm, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1.1^\circ$$\end{document}) and significantly reduces dynamic error (0.20 cm, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2.1^\circ$$\end{document}) using only four sensors. This performance is achieved with a substantially more compact sensor configuration than those required by many existing high-accuracy systems. Table 5 compares the proposed method with representative existing approaches. Compared to prior work, the proposed system achieves comparable or superior localization accuracy with significantly fewer sensors and lower overall computational requirements. It is important to note that the comparisons presented in Table 5 are indicative rather than strictly quantitative, as the referenced works are evaluated under different experimental conditions, sensor types, and environmental settings. Factors such as sensor sensitivity, array geometry, magnetic interference, and testing protocols vary across studies and can significantly influence reported performance. Accordingly, the comparison is intended to provide a general perspective on achievable localization accuracy and system complexity, rather than a direct one-to-one benchmark. Despite these differences, the proposed method demonstrates competitive performance while maintaining a compact four-sensor wearable configuration.Table 5Comparison with existing magnetic localization approaches.WorkCal. Alg.Loc. Alg.#Sens.Static err. (cm, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Dynamic err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Complexity38ManualHybrid, Cart.6(0.13, 1.32)(0.13, 1.32)High393-stepLM, Cart.16(0.45, 2.37)N/AHigh8Geom.LM, Cart.16(0.97, 12.3)(1.00, 12.0)High40ManualLM, Cart.96(0.12, 1.10)(0.24, 3.20)High41N/ALM, Cart.15(0.12, 1.05)(0.54, 0.83)HighOursNN-basedLM, Cyl.4(0.12, 1.10)(0.20, 2.10)Moderate Table 5Comparison with existing magnetic localization approaches.WorkCal. Alg.Loc. Alg.#Sens.Static err. (cm, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Dynamic err. (cm,\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$^\circ$$\end{document})Complexity38ManualHybrid, Cart.6(0.13, 1.32)(0.13, 1.32)High393-stepLM, Cart.16(0.45, 2.37)N/AHigh8Geom.LM, Cart.16(0.97, 12.3)(1.00, 12.0)High40ManualLM, Cart.96(0.12, 1.10)(0.24, 3.20)High41N/ALM, Cart.15(0.12, 1.05)(0.54, 0.83)HighOursNN-basedLM, Cyl.4(0.12, 1.10)(0.20, 2.10)Moderate Comparison with existing magnetic localization approaches. Overall, the proposed method provides a favorable balance between localization accuracy, robustness to dynamic disturbances, and computational cost. Although NN-based calibration requires offline training and introduces moderate additional complexity, the resulting improvement in accuracy and robustness justifies this trade-off. Future work will focus on improving computational efficiency for practical embedded implementation and validating the system in clinical environments. Conclusion This work presented a comprehensive framework for accurate magnetic capsule localization using a compact four-sensor wearable belt array modeled in a cylindrical coordinate framework, with emphasis on robustness under dynamic measurement disturbances. A two-stage cylindrical localization strategy was introduced, in which radial and axial position components are estimated independently in the first stage, significantly reducing problem dimensionality, followed by full position and orientation refinement in the second stage. To address measurement distortions caused by sensor misalignment, environmental magnetic interference, and relative motion between the capsule and wearable sensor array, both model-based and NN-based calibration were investigated and compared. Experimental results showed that NN-based calibration substantially improves magnetic field consistency and localization accuracy, particularly under dynamic conditions where model-based calibration methods leave disturbance-correlated residual errors. In addition, neural network optimization and sensor placement strategies were explored to enhance robustness while preserving a compact system design. The results demonstrate the practicality of the proposed approach and establish a solid foundation for future practical and clinical magnetic capsule localization systems.