Skip to main content

Development of Withdrawal Algorithm for Capsule Endoscopy in Research and Clinical Setting


The Magnetically Actuated Capsule (MAC) is a lab-designed capsule endoscope still undergoing experimental assessment that will upgrade capsule endoscopy from current non-controllable technology to technology with controllable capabilities. MAC is controlled by an External Permanent Magnet (EMP), which is an extension of 7 degrees of freedom (DoF) robotic arm controlled by a joystick.  The Withdrawal technique is a programmed function integrated between the capsule and the robotic arm. Essentially, the doctor will manually pull on the capsule tethering, which will consequently allow the EMP to travel with the capsule autonomously. By localizing the magnet according to the capsule, the doctor will see many advantages that were previously not available, such as stabilized observation and localized information; not to forget the hassle it is to retract the capsule by joystick itself. The withdrawal function will enhance the quality control of endoscopy for the doctor. Potential benefits include stabilized capsule camera visualization, precise location of the capsule inside the body, decreased chance of decoupling, etc.


Capsule endoscopy is the 21st century medical advancement that is replacing the traditional endoscopic procedure. With traditional colonoscopy, as many as 1 in 100 procedures report some sort of complication during the course of action, 1 in 300 report some sort of bleeding, and 1 in 500 report puncture of the colon [1]. Unfortunately, complications can get even worse (“Death is extremely rare but remains a possibility”[1]). To put the importance of procedural complications in perspective, an estimated 14.2 million colonoscopies were performed in USA alone in 2002 [3]. That number increased to an estimated 27.5 million by 2009 (and about 28 million other endoscopy procedures) [4]. Additionally, traditional colonoscopes are not a feasible option when used for small intestine (SI) procedures due to the strenuous maneuverability that is required for the colonoscope to reach the SI, which can also cause nausea and other complications.

Capsule technology has made great progress in safety, reachability and feasibility concerns. However, it still lacks the ability to be maneuvered inside the body from exterior without the traditional invasive methods (0/14 clinically used GI capsules have any controllable feature [2]). Maneuverability would be a significant addition to the features of capsule endoscopy because it will open up many doors for the health care giver, due to the extensive control over the capsule. Such benefits would include localized observations, therapeutic treatments and drug delivery system among others.

Our lab aims to answer these maneuverability issues by developing a remote controlled capsule endoscope that will pass safety regulations for usage in clinical setting. Respectively, we focus on the Magnetically Actuated Capsule (MAC) device, which functions by using an exterior magnet to control the movement of the capsule inside the patient’s body [3]. STORM lab’s MAC device is made up of the following major components: Mitsubishi robotic arm (6 degrees of freedom) with a magnetic end effector attached to the end of the arm; 3D printed custom capsule endoscope with cameras, sensors, and a magnet included; 3D printed joystick based on endoscopists’ feedback on a desired joystick design for maneuvering. It is also important to note that unlike orthodox capsule endoscopes, MAC has tethered attachments. These tethers provide the MAC with versatile functionalities that includes features like insufflation, irrigation, camera cleaning, therapeutic tools, etc.

Due to the fact that the MAC device has tethering attachments, one of the areas in need for development is the withdrawal maneuver. “Withdrawal” is the conventional term for the action of pulling out the endoscope from patient’s body. Currently, in experimental setting (since magnetic actuated capsule endoscopy is not clinically available), the endoscopist has to maneuver the Mitsubishi arm to withdraw the capsule (same as default maneuvering). For the purpose of retracting the capsule, this is tedious and inefficient. It requires much attention from the endoscopist, which can affect the patient’s safety.  Consequently, it also takes away endoscopist’s complete focus on diagnostic observation.

By creating a withdrawal program for the robotic arm to follow the capsule’s movement,  uncessary time and effort required of the endoscopist can be minimized. An endoscopist can manually pull out the capsule by safely drawing the tethers. If performed as instructed, the robotic arm should follow the capsule as it moves towards the rectum (entry/exit point).

Figure 1. The key components of magnetic capsule endoscopy setting.



The withdrawal function was developed on Python programming language. Python is a general-purpose programming language very close, in comparison, to Java and C++. Python is a common programming language and was chosen based on its ease of use and required little time to master. Python’s object-oriented programming (OOP) allows for simplicity in coding by inheriting definitions from classes that have previously defined a method/function. Python’s computing library “NumPy” was exploited to calculate the rotations of Mitsubishi Arm by using the algebraic function rotation matrix (fig.1).


The robotic arm utilized by STORM laboratory is a 7 degrees of freedom (DoF) industrial arm machine manufactured by Mitsubishi Electrics. 6 degrees of freedom are from the 3 joints of the arm with the 7th being the end effector [5]. The end effector is a 1.38T cylindrical-shaped fixed magnet that can manipulate the capsule using robot’s joints [8]. The STORM lab also developed a 3D printed joystick custom designed to fit the needs of a local endoscopist. The joystick controls the Mitsubishi arm, which consequently controls the capsule by the influence of the exterior permanent magnet (end effector). Capsule’s camera is wired to a video monitor that is used for maneuvering feedback and serves the purpose for observational diagnosis.


MACs are STORM lab designed 3D printed capsules measuring approximately 13.5mm x 29.5mm. The interior of the MAC contains an LED light, a 1.48T cylinder-shaped magnet, and a camera. The MAC also has tethered attachments that serve multiple purposes, although they are still under development, such as insufflation, irrigation, camera cleaning etc. Tethering for this project is essential because they allow the endoscopist to pull out the capsule manually, initiating the withdrawal function.


This research is a pioneer study and it is not considered safe enough to be tested in vivo. Ergo the withdrawal technology was tested in a simulation environment called “Gazebo Simulator”. Gazebo is specifically designed for robotic simulations. By running the withdrawal algorithm in a controlled environment that resembles the real world, we tested the efficacy of the withdrawal function and improved the function by debugging the program code.

The model environment for this research was developed by the STORM lab to create a realistic simulation of the procedure. This includes controller code for safety bounds of the robot arm. This allowed the model robotic arm to only move between the certain bounds since in real world the arm can only move as far as the joints allow it. The STORM lab also had multiple models that were integrated into the environment to simulate the biological factors. For example, a model anus was created to simulate where the capsule enters the body; a model colon was created to test the efficacy of the withdrawal function as it performed colonoscopy in the simulation. This model is similar to the physical model used in the lab to ensure accurate representation of the task being performed.


15 trials were successfully performed under recording condition. Statistical summary from an individual trial is provided in Table 1. Coordinates of both, capsule and EPM, are recorded at 12 ms intervals. The average position of CapX (x-coordinate of capsule) is approximately 0.0005 meter away from the average position of MagX (x-coordinate of magnetic end-effector). The average difference in the y-coordinate of positions of capsule and magnetic end is approximately 0.0001 meters apart. However for z-coordinate, the difference in average position increased to 0.15 meter.

Table 1. Statistical summary from an arbitrarily chosen trial. Average position in x and y axis seems to be very similar for capsule and magnetic end

Overlap in the analysis (mean, St.Dev., and S.E.) of x- and y-axes shows that the pathway taken by the capsule and magnet are statistically similar. Furthermore, t-test analysis (0.91, α = 0.05) also shows that the movement of capsule and magnetic ends in the x and y axis are not statistically different (Table 1).

Figure 2. Display of the movement of capsule and magnet in the x-axis and y-axis.

Mapping out each axis also displayed trace of similar path between the x-axis and y-axis of capsule and magnetic end. Figure 2 shows the overlapping graphs of each axis. Figure 3 shows the differences between the capsule and magnet’s position in the z-axis.

Figure 3. Display of the movement of capsule and magnet in the z-axis.


The withdrawal function can successfully perform the task of making the EPM mechanically follow the capsule. Of the 15 trials recorded under the experimental set-up, the robotic arm ended up at the exact same location as the capsule (in x,y coordinates) with a max error of approximately 0.5 mm, which has no significant effect on the capsule. In fact, the paths for capsule and magnet in the xy-axes have a p-value of greater than 0.91, showing the overlap in the movement of each device.

It can be seen in the Figure 3 that although the magnet stays much above the capsule, it replicates the same behavior as its counterpart. This is due to the fact that the magnetic robot is forced to stay 15 centimeters above the capsule at all times due to its real life application. Although “15 cm” is an arbitrarily picked value, when the capsule is inside the patient, the robot should maintain a distance of x centimeters from the capsule to stabilize the movement. Essentially, with a constant distance maintained, the magnetic drag, or the resistance, will be minimal due to the lack of fluctuation in the distance from their counterpart. This can be used in clinical settings to have stable visualization of the observing area

Another advantage of this withdrawal function is the precise location feature. As shown in the figure 2 and figure 3, the data from the capsule/magnet position coordinates can be used to graph the precise location of the capsule at any given moment while observing. This feature will be used to pinpoint specific locations in the body to be noted for future treatment/diagnosis. In essence, an invisible Cartesian coordinate plane is used to locate specific point in the body that corresponds to the location of the capsule. While this is a concept only, it can easily be implemented to clinical usage just like it was used to graph the x-, y-, and z- axes in this paper.

Additionally, the withdrawal function decreases the chance of magnet decoupling from the capsule. Without this function, if the capsule was pulled by hand, the robot would stay still; that would cause disconnection of the magnetic attraction. With the use of withdrawal function, the endoscopist can go back and forth between going in and withdrawing the capsule without decoupling the device.

Since the experimental set-up used for this project was simulation based, it would be appropriate to run experiments on the actual robot as next step. Although the simulations are very accurate representation of how the robot will react, it is still the next required step to test the physical robot before any integration or further development in the project.

Due to the lack of time and accessibility, experiments on animal tissues couldn’t be performed either. However, that would be the next step after the experiments on the actual robot show expected results. Since plastic tubes do not well represent the human colon, it would be more accurate to see the withdrawal function on a pig’s colon tissue (standard tissue in the endoscopy labs).


Although capsule endoscopes were first clinically introduced in 2000, it has been 16 years and they are still being used in passive (non-controllable) manner only [4]. Active capsule endoscopy has only been a topic of research with no timetable for implementation in clinical use due to lack of safe and viable technique thus far [4]; thus, this work has significant implications to the scientific knowledge in this field and the gastrointestinal endoscopic community. With the integration of this withdrawal function to a magnetically controllable capsule endoscope, the endoscopist will be equipped with more stable visual to provide clear images, have access to knowledge of precise location in human body based on the location of the capsule, and can go either passive or active without any doubt for decoupling the devices. The withdrawal function is a great addition to any magnetically controllable capsule because it provides convenience for the endoscopist without bearing any hindrance.


I would like to extend my utmost gratitude to The School of Math and Science at Vanderbilt for providing me with an opportunity to conduct this research, especially Dr. Weeden-Wright and Dr. Brown for guiding me through this experience. I would also like to thank the STORM lab, especially my mentors Addisu and Piotr, for taking me under their mentorship and teaching me the skills that helped me finish this project.


  1. “Colonoscopy,” Eugene Gastroenterology Consultants. [Online]. Available:
  2. P. Slawinski, Emerging issues and future developments in capsule endoscopy. Techniques in Gastrointestinal Endoscopy.
  3. S. LC, How many endoscopies are performed for colorectal cancer screening? Results from CDC’s survey of endoscopic capacity. National Center for Biotechnology Information, Dec-2004. [Online]. Available: [Accessed: 06-Jul-2016].
  4. “35 Statistics About GI/Endoscopy,” 35 Statistics About GI/Endoscopy.
  5.  A. Arezzo, Experimental assessment of a novel robotically-driven endoscopic capsule compared to traditional colonoscopy. Digestive and Liver Disease 45, 657–662 (2013).

Posted by on Wednesday, May 24, 2017 in May 2017.

Tags: , , , ,