NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

80
NORTHWESTERN UNIVERSITY Algorithm development for sensing the position and orientation of a magnet within residual bone A DISSERTATION SUBMITTED TO THE GRADUATE SCHOOL IN PARTIAL FULFILLMENT OF THE REQUIREMENTS for the degree of MASTER OF SCIENCE Field of biomedical engineering By Elliott Jay Rouse EVANSTON, ILLINOIS June 2009

Transcript of NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Page 1: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

NORTHWESTERN UNIVERSITY

Algorithm development for sensing the position and orientation of a magnet within residual bone

A DISSERTATION

SUBMITTED TO THE GRADUATE SCHOOL

IN PARTIAL FULFILLMENT OF THE REQUIREMENTS

for the degree of

MASTER OF SCIENCE

Field of biomedical engineering

By Elliott Jay Rouse

EVANSTON, ILLINOIS

June 2009

Page 2: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

2

Page 3: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

3

Abstract

Algorithm development for sensing the positions and orientation of a magnet within residual bone

Elliott Jay Rouse

Most transradial and transhumeral amputees can rotate their bone(s) within the residual soft-tissue of their arm. Unfortunately, this motion can rarely be captured with their socket. We propose coupling the rotation of the residual bone to the rotation of a prosthetic rotator by sensing the orientation of a magnet implanted within the bone. A key element of this rotation control mechanism is the determination of the magnet’s orientation, independent of its position in space. This thesis focuses on the comparison of three algorithms that enable the inverse determination of the position and orientation of the magnet from the magnetic field vectors sensed within the prosthetic socket. These algorithms include a simple Look-Through Table, as well as iterative algorithms: Gradient Descent and the Newton method. All algorithms were tested computationally, and the most effective algorithm was tested subsequently on a physical model. We have determined that the Newton method is a robust method of determining magnet orientation. During computational testing, the algorithm followed a simulated magnet position and orientation trajectory with an error of less than 1° for 100% of the trajectory. Furthermore, there was only a 2.7% reduction of accuracy upon introducing a ± 0.16 G random noise term into the sensor equations, indicating that the algorithm is robust to sensor noise. Lastly, the algorithm was the most computationally efficient requiring approximately 25% of the total floating point operations needed in each of the other algorithms. When tested on the physical model, the algorithm obtained rotational errors less than 5 degrees for the most of the workspace, with errors less than 1 degree when the magnet was approximately centered. Thus, in this thesis we have shown feasibility and proof-of-concept of this novel prosthetic rotation control mechanism.

Page 4: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

4

Contents Abstract ......................................................................................................................................................... 3

List of Figures and Tables .............................................................................................................................. 6

List of Figures ............................................................................................................................................ 6

List of Tables ............................................................................................................................................. 7

Chapter I: Introduction ................................................................................................................................. 8

Background ............................................................................................................................................... 8

Motivation ............................................................................................................................................. 8

Concept ..................................................................................................................................................... 9

Previous Work ......................................................................................................................................... 10

Chapter II: Materials and Methods ............................................................................................................. 12

Device Objectives .................................................................................................................................... 12

Introduction ............................................................................................................................................ 12

System Characterization ..................................................................................................................... 12

Degree of Freedom Analysis ............................................................................................................... 14

Computational Model ............................................................................................................................. 15

Modeling ............................................................................................................................................. 15

Sensor Placement ............................................................................................................................... 21

Inversion Method 1: Look-Up Table ................................................................................................... 27

Inversion Method 2: Cost Function Algorithms .................................................................................. 28

Look Through Table ......................................................................................................................... 31

Gradient Descent ............................................................................................................................ 32

Newton Method .............................................................................................................................. 35

Algorithm Architecture ....................................................................................................................... 39

Comparison Tests .................................................................................................................................... 40

Translation to the Physical Model .......................................................................................................... 42

Physical Model .................................................................................................................................... 42

Magnet ............................................................................................................................................ 43

Casing .............................................................................................................................................. 43

Model Arm ...................................................................................................................................... 44

Model Bone ..................................................................................................................................... 44

Magnet Position and Orientation Motion ...................................................................................... 45

Sensors ................................................................................................................................................ 46

Data Acquisition and Computational Processing ................................................................................ 48

Prosthetic Rotator and Control ........................................................................................................... 49

Page 5: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

5

Shell ..................................................................................................................................................... 49

Testing the Physical Model ..................................................................................................................... 49

Chapter III: Results ...................................................................................................................................... 51

Computational Results ............................................................................................................................ 51

Look-Through Table ............................................................................................................................ 51

Random Trials ................................................................................................................................. 51

Lissajous Trajectory ......................................................................................................................... 52

Gradient Descent Algorithm ............................................................................................................... 53

Random Trials ................................................................................................................................. 53

Lissajous Trajectory ......................................................................................................................... 54

Newton Method .................................................................................................................................. 56

Random Trials ................................................................................................................................. 56

Lissajous Trajectory ......................................................................................................................... 57

Physical Model Results ............................................................................................................................ 59

Chapter IV: Discussion ................................................................................................................................ 64

Sensor Placement ................................................................................................................................... 64

Look-Through Table ................................................................................................................................ 64

Gradient Descent .................................................................................................................................... 66

Newton Method ...................................................................................................................................... 67

Comparison of Algorithms ...................................................................................................................... 69

Physical Model ........................................................................................................................................ 71

Chapter V: Conclusion ................................................................................................................................. 73

Conclusion ............................................................................................................................................... 73

Future Work ............................................................................................................................................ 73

Division of Thesis..................................................................................................................................... 74

Acknowledgements ................................................................................................................................. 75

References .................................................................................................................................................. 76

Appendix A .................................................................................................................................................. 78

Look-Through Table Parameters ............................................................................................................. 78

Gradient Descent Parameters ................................................................................................................. 78

Newton Parameters ................................................................................................................................ 78

Appendix B .................................................................................................................................................. 79

Lissajous Trajectory Equations ................................................................................................................ 79

Page 6: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

6

List of Figures and Tables

List of Figures Figure 1: Arm showing coordinate axes ...................................................................................................... 13

Figure 2: Cross-section of arm with parameters ........................................................................................ 14

Figure 3: Magnet and world coordinate systems ....................................................................................... 16

Figure 4: Rotated magnet coordinate system, denoted by prime .............................................................. 17

Figure 5: Parameters for dipole equation from s' shown in mcs ................................................................ 17

Figure 6: Circumferential magnetic Fields through a trajectory ................................................................. 19

Figure 7: Magnetic field shown in 3D ......................................................................................................... 20

Figure 8: Iso-magnitude surface (arbitrary axes) ........................................................................................ 23

Figure 9: Possible position solutions for a magnet, given a 𝑩𝑩 at a specified location ................................ 24

Figure 10: Solutions for 5 1-axis sensors ..................................................................................................... 25

Figure 11: Solutions for 6 1-axis sensors ..................................................................................................... 25

Figure 12: Magnetic field vs. distance ........................................................................................................ 26

Figure 13: Sensor ring with Hall-Effect sensors ......................................................................................... 27

Figure 14: Example of Gradient Descent NOTE: 100 Iterations .................................................................. 33

Figure 15: ET shown for R-Z values; R-Z axis shown as an index. NOTE: X-Y dimensions not shown ....... 35

Figure 16: Graphical representation for finite difference H calculation ..................................................... 37

Figure 17: Example of the Newton Method NOTE: 8 Iterations ................................................................. 39

Figure 18: Picture of physical model ........................................................................................................... 43

Figure 19: Threaded titanium with encased magnet .................................................................................. 44

Figure 20: Picture showing model arm and model bone ............................................................................ 45

Figure 21: Linear stage and carrier demonstrating Y-axis translation ........................................................ 46

Figure 22: Carriage and sliding bars for Z-axis translation .......................................................................... 46

Figure 23: Allegro linear Hall-effect sensor (left), location of sensing plate (right) ................................... 48

Figure 24: Closed-loop motor control diagram ........................................................................................... 49

Figure 25: Histogram of orientation error (with noise) .............................................................................. 52

Figure 26: Actual and Predicted XYZ space for Look-Through Table (resolution = 10, noise) .................... 53

Figure 27: Actual and Predicted XYZ space for Gradient Descent (resolution = 10, noise) ........................ 56

Figure 28: Actual and predicted XYZ space for Newton (resolution = 10, noise) ....................................... 59

Figure 29: Errors associated with magnet X-translation ............................................................................ 60

Figure 30: Errors associated with magnet Y-translation ............................................................................ 61

Figure 31: Errors associated with magnet Z-translation ............................................................................ 62

Figure 32: Errors associated with magnet 𝜷𝜷 rotation ................................................................................. 63

Figure 33: Examples of Lissajous trajectories for varying coefficients ....................................................... 80

Page 7: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

7

List of Tables Table 1: Explanation of dynamics parameters for model ........................................................................... 14

Table 2: List of system inputs/outputs for given equations ....................................................................... 18

Table 3: Allegro A3515 sensor properties ................................................................................................... 48

Table 4: Results of Look-Through Trials ...................................................................................................... 51

Table 5: Results of Lissajous Trajectory for Look-Through Table................................................................ 53

Table 6: Results of Gradient Descent Trials ............................................................................................... 54

Table 7: Results of Lissajous Trajectory for Gradient Descent .................................................................... 55

Table 8: Continuation of Results of Lissajous Trajectory for Gradient Descent ......................................... 55

Table 9: Results of Newton Trials................................................................................................................ 57

Table 10: Results for Lissajous Trajectory for Newton .............................................................................. 58

Table 11: Continuation of Results of Lissajous Trajectory for Newton ....................................................... 58

Table 12: Comparison of Algorithms .......................................................................................................... 69

Page 8: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

8

Chapter I: Introduction

Background

Motivation Wrist and humeral rotations are essential functions for the performance of activities of

daily living (ADL) [1] [2]. Amputees need wrist flexion and rotation units as well as humeral rotation,

especially when performing ADL that occur on the midline, such as shirt-buttoning [3]. Currently,

prosthetic wrist rotators are limited to body powered and myoelectric control systems. Body powered

wrist rotators are simple mechanical devices that rely on a harness and cabling system that allows

shoulder protraction to rotate a passive friction turntable or ratcheting device [4]. In the cases of long

transradial amputations, wrist rotation may be augmented by forearm pronation and supination. Body

powered systems rely on sequential control to operate multiple degrees of freedom, and often involve

movements typically not associated with the desired motion. Myoelectric wrist rotators use surface

electromyography (EMG) to determine muscle action. The EMG signal is detected by electrodes and

used to control single or multiple degrees of freedom. EMG signals are taken from muscle agonist-

antagonist pairs, and similar to body powered systems, typically utilizes sequential control. If EMG sites

are severely limited, control of wrist rotation may be digital (fixed-speed) control—where muscle EMG

activity is thresholded in order to control two actions [5]. Due to the sequential nature of control and

limiting control inputs (shoulder protraction or EMG sites), body powered and myoelectric systems can

be cumbersome and unintuitive [6]. In addition to unintuitive control, these control mechanisms

provide no proprioceptive feedback.

Proprioception is the ability to detect limb position in space without visual feedback. Typically, this

information is perceived through the intact neural pathways in the joint capsules, skin and muscles [7].

Current body-powered and myoelectric prosthesis provide no proprioception for humeral rotation in

transhumeral amputation, wrist rotation in transradial amputation or any of the prosthetic joints.

Loading from the intrinsic weight of the prosthesis can be sensed through the suspension of the

Page 9: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

9

prosthesis by the intact skeletal structures and mechanoreceptors in the skin, golgi-tendon organs and

muscles, thus providing some sensory information often called 'extended physiological proprioception'.

Some experimental systems provide arm rotation proprioception for amputees through surgically

augmented prosthesis suspension systems such as artificial epicondyles and osseointegration. With

artificial epicondyles, the prosthesis is suspended from a surgically implanted structure that is covered

with soft tissue and skin. This system allows for the transfer of loads through the artificial epicondyles

and has had success in enabling the user to sense extended physiological proprioception. However, it

has the drawback that continuous loading on the implants can cause the skin to break down [8].

Osseointegration involves implanting a titanium abutment into the distal residual limb [9]. The titanium

implant integrates into the bone and protrudes through an opening in the skin, and the prosthesis is

attached to it directly. The system has great promise and many advantages such as better mechanical

coupling, relief of soft-tissue loading and enhanced sensory perception [10]. However, this system has

complications that the protrusion through the skin is prone to infection and the loading characteristics

of the abutment can cause de-calcification of the distal bone. In addition, both of these systems require

invasive surgical procedures, which significantly delay the use of a prosthesis.

Concept

We are proposing a novel method of prosthesis rotational control that is intuitive and provides the user

with elements of proprioception; an idea that was initially conceived by T. Walley Williams of Liberating

Technologies Inc. Transradial (or transhumeral) amputees can rotate their bone within the soft tissue of

their residual limb, with the rotation relative to the surface of the arm. We would like to capture this

rotation and couple it to the rotation of a prosthetic wrist rotator. Rotation will be determined by

implanting a permanent magnet into the distal residual bone. The magnetostatic field produced by the

magnet can be detected by sensors in the prosthetic socket. The sensors will be used to determine the

magnetic field vector and thus the angle of the magnet in the bone. The prosthetic rotator will then

Page 10: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

10

match the angle of the prosthesis to the angle of the magnet (bone). Therefore, user control of the

device will be intuitive, as it functions on the remaining physiology, analogous to typical skeletal wrist

rotation control. Furthermore, this enables the user to ‘feel’ the angle of their residual bone within their

arm, and due to the linear (physiological) mapping of residual bone angle to prosthetic wrist angle, the

user can know the angle of the prosthetic wrist without visual feedback, as the user can receive position

feedback. The surgical procedure for implanting the magnet will be a simple outpatient procedure,

similar to the implantation of an orthopedic screw. Thus, the delay until prosthesis use will be minimal.

Previous Work

The sensing of the position and orientation of a magnet in space has been studied since the 1970’s.

Originally, the goal was to sense position relative to an induced dipole in order to extract buried miners

[11]. In Raab et al., the process is completed iteratively, where the previous sensor position is used to

perform linear transformations which approximate the inverse of transformations describing the true

relationship between a source and a sensor. One of the transformations is applied immediately prior to

exciting the source and the other transformation is applied to the sensor. The change in sensor position

can be determined from differences in the sensor output and the source excitation (prior to

transformation). This method was designed to meet the needs of a specific system and is overly

complex for our application. Furthermore, the system developed by Raab et al. relies on small angle

approximations for sensor motion which is an unnecessary constraint for our objectives. Troyk et al.

developed an implantable goniometer for the detection of joint angle by sensing the magnetic field

produced by two magnets [12]. This study determined the angle of the magnets relative to one another,

thus no position was determined. The system relied on monotonic increases in Hall-sensor voltage from

flexion to extension, and was subsequently calibrated. This system assumes no movement of the

magnets relative to each other, and over time, the two magnets eventually attracted themselves to each

other. Therefore, this study investigated the feasibility of implanting magnets, but did not address

Page 11: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

11

mechanisms for tracking position and orientation and did not discuss accuracy. Johnson et al. described

the creation of an implantable joint angle transducer that senses rotation [13]. In concept, it is similar to

Troyk et al., however, this system had two degrees of freedom (DOF), and solved the dipole equations.

This showed feasibility and further broadened the literature base regarding the detection of the position

and orientation of implanted magnets; however Johnson’s model is too limited for our specifications as

it only had two DOFs. Finally, Sherman et al. have developed a very interesting system that sensed

position and orientation of a magnet using a large planar array of twenty-seven Hall-effect sensors [14],

with preliminary work shown in [15]. This system approximated the permanent magnet using the dipole

equations, and then used an optimization routine to traverse an error function, arriving at the solution.

This system solved five DOFs, which is very encouraging. However, it is ill suited for our objectives as it

is overly complex (using twenty-seven Hall-sensors and associated processing), and used a large array

that would be difficult to implement in a mobile prosthetics application.

Work regarding the feasibility of implanting a magnet for wrist or humeral rotation control was

initially done by Li et al. [6]. They used a finite element model to examine the magnetic field vectors at

36 equally-spaced nodes around the circumference of a male upper-arm model. They showed that

using Hall-Effect sensors, there was sufficient field strength outside the residual limb that may be

utilized for the determination of magnet orientation. Furthermore, they examined the effects of an off-

center magnet, and an off-angle magnet (when the magnet is implanted skewed in one of the neglected

angles). They also investigated the effect of the magnet size and the displacement of the magnetic

sensors as the socket moved axially. They showed that the form of the magnetic field vectors around

the circumference of the arm changed dramatically as the magnet moved off center, in any direction.

From the results of Li et al., it is apparent that a system that determines magnet orientation can be

developed by sensing the magnetic field vectors, however, the system must be able to determine

magnet orientation independent of magnet position.

Page 12: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

12

Chapter II: Materials and Methods

Device Objectives

The overarching goal for controls development in this research is the determination of the magnet

orientation- the angle about the limb axis. However, the magnet and residual bone are free to move

about the remaining soft tissue within the residual limb. Thus, the detection of magnet angle must be

independent of the position in three-dimensional space. Additionally, it must be able to track the

rotation of the magnet in real-time, and the effects of external magnetic fields (from the earth’s

magnetic field or electric motors) should be minimal. The device objectives are outlined in Box 1.

Introduction

System Characterization For both applications—transradial and transhumeral—the X-axis was taken

as along the length of the limb, with positive sense facing distally. The Y-axis was the anterior –

Device Objectives:

• Independent of planar space

o Bone translations should not affect determination of rotation

Motion to be considered involves translation within the cross-section of

residual limb, as well as translation along limb axis

• Rotation

o Discern 360 degree rotations

o Steady-state error must be less than five degrees, ideally less than one degree

• Simplicity

o Must be readily transferrable to a clinical device

o Minimal floating point operations (FLOPs)

Box 1: Outline of design objectives

Page 13: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

13

posterior axis, with the positive sense facing anteriorly. Similarly, the Z-axis was taken as the inferior –

superior axis, with the positive sense facing superiorly. This is illustrated in Figure 1.

Figure 1: Arm showing coordinate axes

In order to build an appropriate physical model, it was necessary to fully describe the motion of the

magnet and residual bone. Due to the larger cross-sectional area (and therefore larger possible magnet

workspace) of the transhumeral case, we will consider it throughout the rest of the study. The

characterization of this movement was intended to be as general as possible within the system’s

constraints. In other words, the motion of the magnet within the physical model was constrained as

little as possible in order for the magnet to be able to perform very general movements. The first

qualification was for the magnet to be placed anywhere within the working cross-section, therefore Y-Z

translations across the entire cross-section were required. Additionally, translation in the X-direction

was required in order to simulate socket slip. The final requirement was full X-axis rotation about a

static (constant during rotation) point anywhere in the X-Y plane which allowed a variable distance

between the magnet and the center of rotation (Figure 2).

Page 14: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

14

Figure 2: Cross-section of arm with parameters

Symbol Description Zc Z-coordinate to center of rotation Yc Y-coordinate to center of rotation Rm Distance from center of rotation to magnet center

βx Angle of magnet rotated about the X-axis Mx Magnet center X-coordinate (not shown) My Magnet center Y-coordinate (not shown) Mz Magnet center Z-coordinate (not shown)

From Figure 2, it can be seen that the angle, βx , is constrained to always describe a circle of radius

Rm, centered at Yc, Zc.

We chose the parameters shown above based on the feasibility of implementation in a physical

model. Computationally, the movements of the magnet were described by the parameters

𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 , thus allowing more complex continuous movements.

Degree of Freedom Analysis To reduce the inherent complexity of the problem at hand, we wished

to reduce the degrees of freedom. In the aforementioned section, we showed that the three

translational degrees of freedom were relevant to the magnet’s movement through bone translation (Y

and Z) or socket translation (X). Furthermore, rotation about the X-axis was inherent in the problem

statement (and our overall goal). However, rotation about the Y and Z axes were constrained by the

Table 1: Explanation of dynamics parameters for model

Page 15: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

15

ball-and-socket shoulder joint on the proximal end, which allows rotation and no translation. The distal

end was constrained by the prosthetic socket, thereby only allowing movement within the soft tissue.

Because these movements would be relatively small, rotation about these two axes were neglected.

Computational Model

Modeling In order to more fully understand the problem, our first task was representing the magnetic

field computationally. In order to avoid the computationally intense Maxwell’s equations, we

approximated the magnet as a dipole and used the far-field approximation. Thus, the magnetic field

vector, 𝐵𝐵�⃑ , at a given point for a dipole located at the origin along the Z-axis, described in spherical

coordinates by (𝑟𝑟,𝜃𝜃,𝜑𝜑) is governed by the following equations:

𝐵𝐵𝑟𝑟 = 2𝜇𝜇0𝑚𝑚4𝜋𝜋𝑟𝑟3 cos𝜃𝜃 𝐵𝐵𝜃𝜃 =

𝜇𝜇0𝑚𝑚4𝜋𝜋𝑟𝑟3 sin𝜃𝜃 𝐵𝐵𝜑𝜑 = 0 (1)

Where 𝑚𝑚 is the magnetic moment of the dipole, 𝜇𝜇0 is the magnetic permeability of free space, 𝑟𝑟 is the

radial distance to the dipole, 𝜃𝜃 is the polar angle and 𝜑𝜑 is the azimuth angle [16]. At this point, it is

convenient to establish a coordinate frame of reference for the magnet and the world (Figure 3).

Page 16: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

16

Figure 3: Magnet and world coordinate system

In the above figure, the sensor is represented by the cube and the dipole (magnet) is at the center of the

cylinder. The world coordinate system (𝑤𝑤𝑤𝑤𝑤𝑤) is in black and the magnet coordinate system (𝑚𝑚𝑤𝑤𝑤𝑤) is in

blue. The magnet is located at [𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧]𝑤𝑤𝑤𝑤𝑤𝑤 and the sensor’s location is described by the vector 𝑆𝑆.

The vector 𝑤𝑤 describes the spatial relationship between the magnet and the sensor. The dipole

equations rely on the magnet being located is along the Z-axis, therefore we must rotate the magnet

coordinate system by the angle -𝛽𝛽𝑥𝑥 . Since we have constrained the system to only the one rotational

degree of freedom, we know that the rotation by -𝛽𝛽𝑥𝑥 will align the magnet with the Z-axis. Rotation of

the magnet coordinate system causes a rotation of 𝑤𝑤. This is accomplished using the following

transformation (2).

�1 0 00 cos(−𝛽𝛽𝑥𝑥) sin(𝛽𝛽𝑥𝑥)0 −sin(𝛽𝛽𝑥𝑥) cos(−𝛽𝛽𝑥𝑥)

� [𝑤𝑤]𝑚𝑚𝑤𝑤𝑤𝑤 = [𝑤𝑤′]𝑚𝑚𝑤𝑤𝑤𝑤 (2)

The prime notation indicates a rotated coordinate system.

Page 17: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

17

Figure 4: Rotated magnet coordinate system, denoted by prime

Note that the location of the sensor in the world coordinate system has changed (Figure 4). Finally, to

use the dipole equations, we must analyze 𝑤𝑤′��⃑ in the magnet coordinate system. The parameters 𝑟𝑟,𝜃𝜃 and

𝜑𝜑 are defined with respect to the 𝑚𝑚𝑤𝑤𝑤𝑤, seen in (3), (4) and (5), and Figure 5.

Figure 5: Parameters for dipole equation from s' shown in mcs

Page 18: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

18

𝑟𝑟 = �𝑤𝑤′���⃑ � (3)

𝜃𝜃 = cos−1 𝑤𝑤′𝑧𝑧

𝑟𝑟 (4)

𝜑𝜑 = tan−1 𝑤𝑤′𝑥𝑥𝑤𝑤′𝑦𝑦

(5)

From (3) - (5), we now have the required information to determine the magnetic field vector at 𝑤𝑤′��⃑ .

𝐵𝐵𝑟𝑟′ = 2𝜇𝜇0𝑚𝑚4𝜋𝜋𝑟𝑟3 cos 𝜃𝜃 𝐵𝐵𝜃𝜃′ =

𝜇𝜇0𝑚𝑚4𝜋𝜋𝑟𝑟3 sin𝜃𝜃 𝐵𝐵𝜑𝜑′ = 0 (6)

For convenience, we will put (6) into Cartesian coordinates.

𝐵𝐵𝑥𝑥′ = (𝐵𝐵𝑟𝑟 sin𝜃𝜃 + 𝐵𝐵𝜃𝜃 cos 𝜃𝜃) cos𝜑𝜑 (7)

𝐵𝐵′𝑦𝑦 = (𝐵𝐵𝑟𝑟 sin𝜃𝜃 + 𝐵𝐵𝜃𝜃 cos 𝜃𝜃) sin𝜑𝜑 (8)

𝐵𝐵′𝑧𝑧 = 𝐵𝐵𝑟𝑟 cos𝜃𝜃 − 𝐵𝐵𝜃𝜃 sin𝜃𝜃 (9)

To put the Cartesian magnetic field vector into the world coordinate system, we must reverse the

rotation made to align the magnet with the Z-axis, thus we must rotate by the angle 𝛽𝛽𝑥𝑥 .

�1 0 00 cos𝛽𝛽𝑥𝑥 sin𝛽𝛽𝑥𝑥0 − sin𝛽𝛽𝑥𝑥 cos𝛽𝛽𝑥𝑥

� �𝐵𝐵′����⃑ � = �𝐵𝐵�⃑ � (10)

Given equations (2) – (10), we have the ability to determine the magnetic field vector at a given location,

specified by 𝑆𝑆.

Inputs Outputs Magnet

position/orientation Magnetic field

vector 𝑀𝑀𝑥𝑥 𝐵𝐵𝑥𝑥 𝑀𝑀𝑦𝑦 𝐵𝐵𝑦𝑦 𝑀𝑀𝑧𝑧 𝐵𝐵𝑧𝑧 𝛽𝛽𝑥𝑥

𝑆𝑆

Table 2: List of system inputs/outputs for given equations

Page 19: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

19

Using these equations, we investigated the nature of the magnetic field for given set of inputs (seen in

Table 2).

Figure 6: Circumferential magnetic Fields through a trajectory

From Figure 6, we can see the change in the magnetic field strength at 36 equally-spaced nodes around

the circumference (r = 5 cm) as the magnet (black and red stars) traverses a semi-circular trajectory

(green arc). Additionally, it may be helpful to visualize the magnetic field in three dimensions.

Page 20: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

20

Figure 7: Magnetic field shown in 3D

From Figure 7, we can see the field distribution from an offset magnet (red star), rotated 45° around the

X-axis, with the origin denoted by the green circle. This picture gives a qualitative analysis of the dipole

equations; note the field drops off as one over the distance cubed.

At this point, we could go from having position and orientation to determining the magnetic field

vector. We wished, however, to solve the inverse problem: calculating the magnet location from the

field vector. Thus, we needed the inverse of these equations, which brought us to a classical inverse

problem.

𝐵𝐵�⃑ = 𝑓𝑓�𝑀𝑀𝑥𝑥 , 𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 , 𝑆𝑆� → �𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� = 𝑔𝑔(𝐵𝐵�⃑ , 𝑆𝑆)

We could not directly solve for �𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� in closed form. In other words, we could not

determine the function 𝑔𝑔(𝐵𝐵�⃑ , 𝑆𝑆) that was necessary to determine the position and orientation of the

Page 21: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

21

magnet. Therefore, we needed a suitable method of inversion; we investigated algorithms that could

perform the inversion through an iterative or look-up method.

Sensor Placement Initially, sensor placement was chosen based on qualitative results seen in

algorithm testing. However, to further substantiate the results observed qualitatively, we investigated

sensor placement quantitatively.

In order to carry out the subsequent algorithms, we must have a reliable measure of the magnetic

field vectors at known locations. We investigated potential sensor number and configuration with the

following goals in mind:

1. Robust measurements of magnetic field vector irrespective of magnet position

2. Minimize number of sensors, while maintaining goal 1

3. Sensor locations convenient for mounting within prosthetic socket

Since magnetic field drops off inversely proportionally to the distance cubed (1), proximity was of

high importance. With the inherent constraints in the socket/residual limb geometry, we investigated

sensors that were placed circumferentially around the residual limb and in the Y-Z plane. We also

investigated sensors that were in the Y-Z plane 2 cm distal to the end of the residual limb (along the X-

axis).

Sensor investigation involved first determining the maximum distance that gave sufficient signal

strength, given the sensor noise. Secondly, we determined the number of sensors necessary, given goal

2. To aid in determining the number of sensors necessary to give a unique solution for the inversion of

the dipole equations, we investigated the theoretical solutions for given components of the magnetic

field vector. In other words, we investigated what magnet solutions were available for a known 𝐵𝐵𝑥𝑥 , 𝐵𝐵𝑦𝑦 ,

or 𝐵𝐵𝑧𝑧 , given that the magnet solutions only had 4 available degrees of freedom.

Page 22: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

22

This investigation was done by using Nelder-Mead optimization (MATLAB Optimization Toolbox) for

the dipole equations, solving for 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 for a range of initial guesses. The initial guesses

included many possible combinations of 𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽, where 𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽 refers to the position and orientation

of the suspected magnet, before it has been deemed the true value of 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 . Therefore, for

each 𝑥𝑥, 𝑦𝑦, 𝑧𝑧,𝛽𝛽, the optimization converged on values of 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥while minimizing the sum of

squared error (SSE) between 𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽 and 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 , until the SSE was below a cutoff threshold.

The result was a vector 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 for each initial guess. If there was only one solution available, the

vector containing 𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥 would be the same for every initial 𝑥𝑥, every initial 𝑦𝑦, and so on. This

gave a visualization of the possible solution space, given the magnetic field components at specific

locations which enabled us to make an educated decision on where to put the sensors.

For transhumeral subjects, the average mid-arm diameter is 10 cm. Therefore, sensors located

circumferentially would have an average distance to the magnet of over five centimeters. However, if

the sensors were placed distal to the end of the residual limb, we could take advantage of the relatively

small distance between the distal residual humerus and the distal end of the residual limb. This distance

is approximately three centimeters. For transradial subjects, the circumferential geometry may be

more appropriate; however, the analysis considered the transhumeral case.

With these known aspects of sensor location, we determined exactly how many sensors were

required to provide a unique solution, as well as a convenient geometry for the algorithms to traverse.

Given that there are four degrees of freedom, we were interested in how many possible magnet

position/orientation solutions existed for a given magnetic field. We considered a magnet situated at

the origin. A convenient initial method of thinking about the possible position/orientation solutions

began with first considering a surface around a magnet where all points on the surface had the same 𝐵𝐵�⃑

magnitude.

Page 23: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

23

Figure 8: Iso-magnitude surface (arbitrary axes)

If we consider a single point on this surface (Figure 8), any vector on this surface can be matched to any

other vector if we apply a translation and rotation (6 DOF) to the magnet. If we limit the possible

solutions to four degree of freedoms, we now have a subset of the surface of possible solutions

considered above.

We then considered a three-axis sensor located five centimeters along the positive Z-axis. We

would like to know the possible magnet position/orientation solutions, given the magnetic field vector

at the sensor location.

Page 24: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

24

Figure 9: Possible position solutions for a magnet, given a 𝑩𝑩��⃑ at a specified location

What we have is two closed paths, in this case, a circle and an ellipse. In addition to the plot shown

above, each point has a corresponding angle of rotation about the X-axis (𝛽𝛽𝑥𝑥 ). For the circle, the

rotation value is constant (0 degrees), and rotation varies continuously around the ellipse (with a

discontinuity when the magnet orientation is 0° or 360°). The circle and the ellipse will fit on the iso-

magnitude surface. The circle is parallel to the X-Y plane and the ellipse is parallel to the Y-Z plane.

Next we examined sensors at two locations. One location was the same as indicated above, 3-axis

sensor at (0, 0, 0.05) meters. The other location was similarly located at (0, 0.05, 0) meters, however

this sensor only sensed 2 components of magnetic field, the y-component and the z-component. The

possible magnet position and orientations that provided the specified magnetic fields are shown below.

Page 25: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

25

Figure 10: Solutions for 5 1-axis sensors

Thus, with five 1-axis sensors in two locations, we did not have a unique solution (Figure 10). Therefore,

we needed to add more sensors to ensure the dipole solution was the correct position and orientation

of the magnet. We analyzed six 1-axis sensors, three in each of the locations mentioned above.

Figure 11: Solutions for 6 1-axis sensors

We can see from Figure 11, that when six 1-axis sensors were considered, we have a unique solution.

Page 26: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

26

We also considered the working distance for the magnet we are using. To this end, the

magnetic field was recorded at varying distances.

Figure 12: Magnetic field vs. distance

From Figure 12, we can see that in order to obtain substantial signal-to-noise, we needed to limit the

maximum distance the magnet can be from the sensors. We chose to place the sensors around a circle

of radius 2 cm, at 90 degree intervals, located 2 cm from the distal end of the residual bone. This

allowed the magnet to be proximal to two sensors regardless of its position in the workspace.

Page 27: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

27

Figure 13: Sensor ring with Hall-Effect sensors

Since we have established a suitable placement for the sensors, we then investigated the algorithms

that could determine magnet position and orientation from the magnet field vectors obtained at the

locations described above.

Inversion Method 1: Look-Up Table The first method is the simplest, and involves no iterative

solving. The idea is to create a massive database containing the angular solution for many sensor

readings, allowing the solution to be ‘looked up’ and not requiring costly computation. With four

degrees of freedom, we must have at least four sensors involved in the determination of the angle

(ideally it would be 6 sensors, but memory limitations immediately restrict the use of 6 sensors for the

table). We also would like the table to have the finest possible resolution so that solutions do not

overlap many angular values in a single cell. Due to the limitations of MATLAB, the largest possible table

for a computer with 64-bit Windows Vista, running 32-bit MATLAB, is approximately 2047 MB [17].

Using 4-byte single precision numbers, the largest table size is given by the following equation:

𝑀𝑀 = �2047 𝑀𝑀𝐵𝐵

4 𝐵𝐵𝑒𝑒𝑒𝑒𝑒𝑒𝑚𝑚𝑒𝑒𝑒𝑒𝑒𝑒

14

= 150 𝑒𝑒𝑒𝑒𝑒𝑒𝑚𝑚𝑒𝑒𝑒𝑒𝑒𝑒𝑤𝑤 (11)

Page 28: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

28

Where 𝑀𝑀 is the largest equi-dimension characterizing a 4-D matrix (i.e. 𝑀𝑀 x 𝑀𝑀 x 𝑀𝑀 x 𝑀𝑀 is maximized).

Thus, we need to cover the entire applicable sensor range in 150 elements. If we would like to

characterize the entire 5 V range for the sensors, the resolution of the table would be given by:

5 𝑉𝑉150 𝑤𝑤𝑒𝑒𝑒𝑒𝑒𝑒𝑤𝑤

= 0.033 𝑉𝑉𝑤𝑤𝑒𝑒𝑒𝑒𝑒𝑒

∙1000 𝐺𝐺

5 𝑉𝑉= 6.66

𝐺𝐺𝑤𝑤𝑒𝑒𝑒𝑒𝑒𝑒

(12)

Therefore, the table has a resolution of 6.66 G. In other words, solutions differing by less than 6.66 G

will be placed in the same cell, in each sensor dimension. Due to the ambiguity of the relation between

Gauss readings of the four sensors and angle of the magnet, we cannot determine the exact detriment

of this resolution.

The table would be populated using the theoretical dipole equations. For a given magnet position

and orientation resolution, the table can be constructed. Initially, the 150 cell 4-D table would be pre-

allocated (with a number that corresponds to “no solution”), and for every magnet position/orientation

combination tried, the result would be tabulated into the corresponding address in the table.

Depending on the ratio of possible position/orientation combinations to the maximum number of

elements (approximately 5 ∙ 108 elements) in the table would indicate the relative sparsity of the table,

not including overlap. With a known position/orientation resolution, we would also determine the

number of elements overlapped, to give us a measure of the appropriateness of the table resolution.

However, following discussions with the projects advisors, the resolution was deemed impractical

and this method of inversion was terminated. Thus, the remainder of the project will focus on cost

function algorithms.

Inversion Method 2: Cost Function Algorithms In order to navigate the solution space effectively,

we must determine a cost function that will indicate the correct solution. Furthermore, the cost

function must be unique, indicating only one solution. Since we have an analytical solution for the

Page 29: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

29

magnetic field, given the position and orientation, we should be able to introduce the concept of the

difference between the sensor-reading magnetic field vector (𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 ) and the dipole predicted

magnetic field vector (𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 ). Thus, theoretically, the difference between 𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 and 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚

should be zero at the solution, where 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 and 𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 are row vectors. With this information,

we would like the neighborhood of the solution to increase monotonically, as well as establish 0 as the

smallest possible value.

𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 − 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 �𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� = 0�⃑ (13)

We must augment (13) to create a minimum at the solution; thus we will investigate the difference

squared.

�𝐷𝐷��⃑ � = �𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 − 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 �𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥�� (14)

𝐶𝐶�𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� = �𝐷𝐷��⃑ ��𝐷𝐷��⃑ �𝑇𝑇

(15)

Where 𝐶𝐶�𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� denotes the cost as a function of the magnet position/orientation. The cost

sums the squared error between the theoretical dipole values and the observed/measured values (given

by (14)), summed over each component. This penalizes for increasing error and makes the local surface

around the solution parabolic. However, with (15) we can see that due to the nature of the dipole

equations, if just one 𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 point is analyzed, the solution is not unique. There are infinitely many

magnet position/orientations describing the magnetic field at a point. Therefore, we must augment (15)

by analyzing more than a single point. Thus, we will introduce the error as a function that analyzes 𝑒𝑒

points:

𝐸𝐸�𝑀𝑀𝑥𝑥 ,𝑀𝑀𝑦𝑦 ,𝑀𝑀𝑧𝑧 ,𝛽𝛽𝑥𝑥� = �𝐶𝐶𝑝𝑝

𝑒𝑒

𝑝𝑝 = 1

(16)

Page 30: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

30

Where 𝑒𝑒 signifies the number of points or sensors (𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 ) being analyzed. The result is that (16)

will have a global minimum at the solution. In order to have an understanding of the solution space, we

will create a table known as the Error Table (𝐸𝐸𝑇𝑇) that contains the error between the theoretical

magnetic field vectors and the measured magnetic field vectors (16) for many possible position and

orientation combinations. We will populate table theoretically, given the solution to the dipole

equations. The parameters governing the resolution of the 𝐸𝐸𝑇𝑇 are as follows:

𝑀𝑀𝑥𝑥 = [𝑚𝑚𝑝𝑝𝑒𝑒𝑥𝑥 :𝑅𝑅𝑥𝑥 :𝑚𝑚𝑚𝑚𝑥𝑥𝑥𝑥 ], 𝑀𝑀𝑦𝑦 = �𝑚𝑚𝑝𝑝𝑒𝑒𝑦𝑦 :𝑅𝑅𝑦𝑦 :𝑚𝑚𝑚𝑚𝑥𝑥𝑦𝑦�

𝑀𝑀𝑧𝑧 = [𝑚𝑚𝑝𝑝𝑒𝑒𝑧𝑧 :𝑅𝑅𝑧𝑧 :𝑚𝑚𝑚𝑚𝑥𝑥𝑧𝑧], 𝛽𝛽𝑥𝑥 = [𝑚𝑚𝑝𝑝𝑒𝑒𝛽𝛽 :𝑅𝑅𝛽𝛽 :𝑚𝑚𝑚𝑚𝑥𝑥𝛽𝛽 ]

Where [𝑚𝑚𝑝𝑝𝑒𝑒𝑥𝑥 :𝑅𝑅𝑥𝑥 :𝑚𝑚𝑚𝑚𝑥𝑥𝑥𝑥 ] denotes an array from 𝑚𝑚𝑝𝑝𝑒𝑒𝑥𝑥 to 𝑚𝑚𝑚𝑚𝑥𝑥𝑥𝑥 , with a resolution of 𝑅𝑅𝑥𝑥 . For each

degree of freedom, the size of the dimension, 𝑒𝑒, (where 𝑒𝑒 = 𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽), is

𝑆𝑆𝑝𝑝𝑧𝑧𝑒𝑒 𝑜𝑜𝑓𝑓 𝑒𝑒𝑒𝑒ℎ𝑚𝑚𝑝𝑝𝑚𝑚𝑒𝑒𝑒𝑒𝑤𝑤𝑝𝑝𝑜𝑜𝑒𝑒 𝑜𝑜𝑓𝑓 𝐸𝐸𝑇𝑇 𝑆𝑆𝑒𝑒 = 𝑚𝑚𝑚𝑚𝑥𝑥𝑒𝑒 − 𝑚𝑚𝑝𝑝𝑒𝑒𝑒𝑒

𝑅𝑅𝑒𝑒+ 1 (17)

∴ 𝐸𝐸𝑇𝑇 → 𝑆𝑆𝑥𝑥 × 𝑆𝑆𝑦𝑦 × 𝑆𝑆𝑧𝑧 × 𝑆𝑆𝛽𝛽

Where 𝑚𝑚𝑝𝑝𝑒𝑒𝑒𝑒 through 𝑚𝑚𝑚𝑚𝑥𝑥𝑒𝑒 refers to the possible range of values for each degree of freedom. The

resolution of each dimension is governed by 𝑅𝑅𝑒𝑒 , which indicates the size of the 𝑒𝑒𝑒𝑒ℎdimension. The 𝐸𝐸𝑇𝑇 is

a 4-D solution space that has a global minimum at the solution. This is convenient because we can focus

on methods of traversing the 4-D solution space, which will lead us to the solution.

Based on (16), to determine the 𝐸𝐸𝑇𝑇 we must know the magnetic field vectors at given locations. To

minimize processing, it is convenient to establish a pre-table that contains the 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 values for all

possible combinations at 𝑒𝑒 locations, instead of the error values dictated by (16). This may be done by

using the dipole equations, and cataloging each possible 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 governed by the size requirements

for (17). The resultant 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 table (𝐵𝐵𝑇𝑇) is a 𝑒𝑒 × 3 matrix, with each element containing a

Page 31: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

31

𝑆𝑆𝑥𝑥 × 𝑆𝑆𝑦𝑦 × 𝑆𝑆𝑧𝑧 × 𝑆𝑆𝛽𝛽 matrix. In summary, to make the 𝐵𝐵𝑇𝑇 into the 𝐸𝐸𝑇𝑇, the difference between 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚

and 𝐵𝐵�⃑ 𝑚𝑚𝑒𝑒𝑚𝑚𝑤𝑤𝑚𝑚𝑟𝑟𝑒𝑒𝑚𝑚 is taken for 𝑒𝑒 points for every 𝑆𝑆𝑥𝑥 × 𝑆𝑆𝑦𝑦 × 𝑆𝑆𝑧𝑧 × 𝑆𝑆𝛽𝛽 element (𝐵𝐵𝑇𝑇), and these elements are

summed over the 𝑒𝑒 points, creating the 𝐸𝐸𝑇𝑇.

Look Through Table This method is similar to the Look Up Table, because there is no computation

beyond manipulating the 𝐸𝐸𝑇𝑇. Solutions are found by determining the minimum of the 𝐸𝐸𝑇𝑇, and taking

the corresponding 𝑀𝑀𝑥𝑥 , 𝑀𝑀𝑦𝑦 , 𝑀𝑀𝑧𝑧 , 𝛽𝛽𝑥𝑥 . For clarification, (16) can be rewritten in the following form,

𝐸𝐸𝑇𝑇 = � ��𝐵𝐵𝒊𝒊1 𝐵𝐵𝑗𝑗1 𝐵𝐵𝑘𝑘1⋮ ⋮ ⋮𝐵𝐵𝑝𝑝𝑒𝑒 𝐵𝐵𝑗𝑗𝑒𝑒 𝐵𝐵𝒌𝒌𝒌𝒌

𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎

− �𝐵𝐵𝑝𝑝1(4𝐷𝐷) 𝐵𝐵𝑗𝑗1(4𝐷𝐷) 𝐵𝐵𝑘𝑘1(4𝐷𝐷)

⋮ ⋮ ⋮𝐵𝐵𝑝𝑝𝑒𝑒 (4𝐷𝐷) 𝐵𝐵𝑗𝑗𝑒𝑒 (4𝐷𝐷) 𝐵𝐵𝑘𝑘𝑒𝑒 (4𝐷𝐷)

𝒑𝒑𝒎𝒎𝒎𝒎𝒎𝒎𝒊𝒊𝒑𝒑𝒑𝒑𝒎𝒎𝒎𝒎

𝟐𝟐𝑒𝑒

𝑝𝑝 ,𝑗𝑗 ,𝑘𝑘

(18)

Where 𝐸𝐸𝑇𝑇 is a table with dimensions 𝑆𝑆𝑥𝑥 × 𝑆𝑆𝑦𝑦 × 𝑆𝑆𝑧𝑧 × 𝑆𝑆𝛽𝛽 . To find the solution, the minimum of the 𝐸𝐸𝑇𝑇 is

determined in MATLAB.

The corresponding position and orientation are the values of 𝑥𝑥, 𝑦𝑦, 𝑧𝑧,𝛽𝛽 that were used to populate

that index of the 𝐸𝐸𝑇𝑇, where the index’s are denoted 𝐼𝐼𝑥𝑥 , 𝐼𝐼𝑦𝑦 , 𝐼𝐼𝑧𝑧 , and 𝐼𝐼𝛽𝛽 .

𝑚𝑚𝑝𝑝𝑒𝑒{𝐸𝐸𝑇𝑇} = 𝐸𝐸𝑇𝑇�𝐼𝐼𝑥𝑥 , 𝐼𝐼𝑦𝑦 , 𝐼𝐼𝑧𝑧 , 𝐼𝐼𝛽𝛽� (19)

To get from the index value back to the position and orientation of the magnet we use the following

transformations:

𝑀𝑀𝑥𝑥 = 𝑅𝑅𝑥𝑥 ∙ (𝐼𝐼𝑥𝑥 − 1) + 𝑚𝑚𝑝𝑝𝑒𝑒𝑥𝑥 𝑀𝑀𝑦𝑦 = 𝑅𝑅𝑦𝑦 ∙ �𝐼𝐼𝑦𝑦 − 1� + 𝑚𝑚𝑝𝑝𝑒𝑒𝑦𝑦

𝑀𝑀𝑧𝑧 = 𝑅𝑅𝑧𝑧 ∙ (𝐼𝐼𝑧𝑧 − 1) + 𝑚𝑚𝑝𝑝𝑒𝑒𝑧𝑧 𝛽𝛽𝑥𝑥 = 𝑅𝑅𝛽𝛽 ∙ �𝐼𝐼𝛽𝛽 − 1� + 𝑚𝑚𝑝𝑝𝑒𝑒𝛽𝛽 (20)

For example, if the minimum of the 𝐸𝐸𝑇𝑇 was found at (1,1,1,1), the solution for the orientation

would be 𝑚𝑚𝑝𝑝𝑒𝑒𝛽𝛽 , and the solution for the position would be (𝑚𝑚𝑝𝑝𝑒𝑒𝑥𝑥 ,𝑚𝑚𝑝𝑝𝑒𝑒𝑦𝑦 ,𝑚𝑚𝑝𝑝𝑒𝑒𝑧𝑧 ). Thus, the answer lies in

Page 32: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

32

the minimization of the 𝐸𝐸𝑇𝑇, and then back calculating the position and orientation from the indexing

formulas (20). Parameters used in the Look-Through Table are given in Appendix A.

Gradient Descent Instead of purely minimizing the 𝐸𝐸𝑇𝑇, it may be possible to search the space and seek

out the minimum rather than relying on direct computation seen in (18). One method of seeking the

minima of functions is known as Gradient Descent. Imagine we have a continuous function 𝑓𝑓 that exists

in real 𝑒𝑒-dimensional Euclidean space. If the gradient of 𝑓𝑓 at 𝒙𝒙0, denoted ∇𝑓𝑓(𝒙𝒙0), is a non-zero vector,

−∇𝑓𝑓(𝒙𝒙0) will point in the direction of the maximum rate of decrease of 𝑓𝑓 at 𝒙𝒙0, where 𝒙𝒙0 is the

parameter vector of the initial iteration. Therefore, if a small step is taken in the direction indicated by

−∇𝑓𝑓(𝒙𝒙0) to a new location denoted 𝒙𝒙1, we know that:

𝑓𝑓(𝒙𝒙0) > 𝑓𝑓(𝒙𝒙1) (21)

Therefore, if we take many small steps we will approach the minimum of 𝑓𝑓 [18]. This brings us to an

iterative formula for Gradient Descent that should stop when specific criteria are met.

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼𝑘𝑘∇𝑓𝑓(𝒙𝒙𝑘𝑘) (22)

Where 𝑘𝑘 indicates the iteration index. The term 𝛼𝛼𝑘𝑘 is a positive scalar representing the step size. In our

case, 𝛼𝛼𝑘𝑘 is fixed, however, there are methods, such as Steepest Descent, that include a variable step size

determined by a line search. Notice that the direction with the maximum rate of decrease will always

be perpendicular to the level set of 𝑓𝑓 (i.e. where 𝑓𝑓(𝒙𝒙𝑘𝑘) equals a constant value). With Gradient Descent

we have an iterative method of locating the minimum, however, we still must determine the stopping

criteria. The first criterion is defined as:

𝜀𝜀 > 𝑓𝑓(𝒙𝒙𝑘𝑘) − 𝑓𝑓(𝒙𝒙𝑘𝑘+1) (23)

Where 𝜀𝜀 represents the smallest acceptable change in 𝑓𝑓. In addition to 𝜀𝜀, it is sometimes important to

add the additional constraint 𝜏𝜏 > 𝑓𝑓(𝒙𝒙𝑘𝑘) to ensure that a local minimum is not reached. This will bias

Page 33: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

33

the algorithm against areas where ∇𝑓𝑓(𝒙𝒙𝑘𝑘) is small, but does not indicate a global minimum. Thus we

have defined a stopping criteria of when the change in 𝑓𝑓 is sufficiently small (𝜀𝜀) and 𝑓𝑓 is less than 𝜏𝜏, the

algorithm will stop searching, and let 𝒙𝒙𝑘𝑘+1 be considered a local minimum of 𝑓𝑓.

Figure 14: Example of Gradient Descent NOTE: 100 Iterations

In our case, 𝑓𝑓 represents the error equation, 𝐸𝐸, from the dipole approximation (16). In order to

perform Gradient Descent, we must establish ∇𝑓𝑓(𝒙𝒙𝑘𝑘). The vector 𝒙𝒙𝑘𝑘 represents [𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽]𝑇𝑇 , therefore,

by the definition of the gradient of 𝐸𝐸:

∇𝐸𝐸(𝒙𝒙𝑘𝑘) = �𝜕𝜕𝐸𝐸𝜕𝜕𝑥𝑥

,𝜕𝜕𝐸𝐸𝜕𝜕𝑦𝑦

,𝜕𝜕𝐸𝐸𝜕𝜕𝑧𝑧

,𝜕𝜕𝐸𝐸𝜕𝜕𝛽𝛽

�𝑇𝑇

(24)

Since we are solving an inverse problem, the partial derivatives are not available. Therefore, in

order to approximate the partial derivatives, we will use the finite difference method. For example, the

finite difference partial derivative of 𝑥𝑥 is calculated by the following:

𝜕𝜕𝐸𝐸𝜕𝜕𝑥𝑥

≅ 𝐸𝐸(𝑥𝑥𝑘𝑘 + ∆𝑥𝑥, 𝑦𝑦𝑘𝑘 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘) − 𝐸𝐸(𝑥𝑥𝑘𝑘 , 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘)

∆𝑥𝑥 (25)

Page 34: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

34

Where ∆𝑥𝑥 is a small displacement in the 𝑥𝑥 direction. A similar process is done for each degree of

freedom.

In some cases it is convenient to augment equation (22) with the propensity to keep 𝒙𝒙𝑘𝑘+1 large even

when the slope decreases. From equation (22) we can see that as the slope decreases, the step that is

taken is reduced, thus it may be practical to add a term that artificially boosts step length. This is

commonly known as momentum, as this term replicates the inertia that would build as 𝑓𝑓 and ∇𝑓𝑓(𝒙𝒙𝑘𝑘)

dictate the topography (e.g. a ball rolling down a hill, building inertia). We will add a term that is

proportional to the previous change in 𝒙𝒙𝑘𝑘 , which will bias the algorithm to persist in areas where the

gradient is becoming small.

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼∇𝐸𝐸(𝒙𝒙𝑘𝑘) + 𝛾𝛾(𝒙𝒙𝑘𝑘 − 𝒙𝒙𝑘𝑘−1) (26)

Where 𝛾𝛾 indicates a coefficient that scales the relative effect of the momentum.

In order to arrive at the minimum of 𝐸𝐸, we must have an initial starting point. This initial guess is

defined as [𝑥𝑥𝑝𝑝 𝑦𝑦𝑝𝑝 𝑧𝑧𝑝𝑝 𝛽𝛽𝑝𝑝]𝑇𝑇 . Due to the nature of Gradient Descent, we must choose the initial guess

carefully, otherwise the algorithm may find an incorrect solution. Since Gradient Descent follows the

negative gradient, we must choose an initial guess that is within the topographical “bowl” of the

minimum. This requires us to know approximately where to begin the search (𝑥𝑥𝑝𝑝 𝑦𝑦𝑝𝑝 𝑧𝑧𝑝𝑝 𝛽𝛽𝑝𝑝). Since we

have a 4-D solution space grid already defined (18), we can simply start at the minimum of (18) defined

by (19) and (20). This requires us to store the 𝐵𝐵𝑇𝑇, and determine the 𝐸𝐸𝑇𝑇 for the initial guess. However,

due the nature of Gradient Descent we only need to be in the vicinity of the solution, and the

dimensions of the 𝐵𝐵𝑇𝑇 can be relaxed. In Figure 15, the vertices indicate a point in the 𝐸𝐸𝑇𝑇 and the

minimum is taken as the starting point. The algorithm descends through all dimensions to reach the

minimum. Parameters used in the Gradient Descent algorithm are given in Appendix A.

Page 35: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

35

Figure 15: ET shown for R-Z values; R-Z axis shown as an index. NOTE: X-Y dimensions not shown

In summary, we have defined the Gradient Descent algorithm that begins with an initial

value [𝑥𝑥𝑝𝑝 𝑦𝑦𝑝𝑝 𝑧𝑧𝑝𝑝 𝛽𝛽𝑝𝑝]𝑇𝑇, and iterates following the negative gradient of 𝐸𝐸, until the change in 𝐸𝐸 is sufficiently

small and 𝐸𝐸 is less than a critical value 𝜏𝜏. This point is taken as a representation of the approximate

minimum of 𝐸𝐸.

Newton Method Analogous to the Gradient Descent algorithm, we are looking to search the 𝐸𝐸 space

and come to an estimation of the minimum. We must have a continuous function, 𝑓𝑓, that exists in real

𝑒𝑒-dimensional Euclidean space where we have a non-zero gradient vector at a position 𝒙𝒙𝑘𝑘 , ∇𝑓𝑓(𝒙𝒙𝑘𝑘). The

Newton method defines the position vector of the 𝑘𝑘 + 1 point to be governed by:

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼[∇2𝑓𝑓(𝒙𝒙𝑘𝑘)]−1∇𝑓𝑓(𝒙𝒙𝑘𝑘) (27)

Page 36: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

36

Where 𝑓𝑓 represents the error equation, 𝐸𝐸, and ∇2𝑓𝑓(𝒙𝒙𝑘𝑘) denotes a matrix containing the partial second

derivatives of 𝐸𝐸. Under the assumption that the second derivative matrix is positive and definite [19],

we may conclude that:

𝑓𝑓(𝒙𝒙0) > 𝑓𝑓(𝒙𝒙1) (28)

The matrix containing the second derivatives is commonly known as the Hessian, denoted 𝑯𝑯. Thus,

equation (27) can be re-written in a common form:

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼𝑯𝑯−1∇𝑓𝑓(𝒙𝒙𝑘𝑘) (29)

Where 𝛼𝛼 is a step coefficient that can be tuned depending on the quality of the surface being minimized.

Computation of the Hessian can be a major task; however, similar to computation of the gradient, we

will compute it using the finite difference method. In our case, the Hessian is defined as:

𝑯𝑯 =

⎣⎢⎢⎢⎢⎢⎢⎢⎢⎡ 𝜕𝜕

2𝐸𝐸𝜕𝜕𝑥𝑥2

𝜕𝜕2𝐸𝐸𝜕𝜕𝑦𝑦𝜕𝜕𝑥𝑥

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝑦𝑦𝜕𝜕2𝐸𝐸𝜕𝜕𝑦𝑦2

𝜕𝜕2𝐸𝐸𝜕𝜕𝑧𝑧𝜕𝜕𝑥𝑥𝜕𝜕2𝐸𝐸𝜕𝜕𝛽𝛽𝜕𝜕𝑥𝑥

𝜕𝜕2𝐸𝐸𝜕𝜕𝑧𝑧𝜕𝜕𝑦𝑦𝜕𝜕2𝐸𝐸𝜕𝜕𝛽𝛽𝜕𝜕𝑦𝑦

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝑧𝑧𝜕𝜕2𝐸𝐸𝜕𝜕𝑦𝑦𝜕𝜕𝑧𝑧

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝛽𝛽𝜕𝜕2𝐸𝐸𝜕𝜕𝑦𝑦𝜕𝜕𝛽𝛽

𝜕𝜕2𝐸𝐸𝜕𝜕𝑧𝑧2

𝜕𝜕2𝐸𝐸𝜕𝜕𝛽𝛽𝜕𝜕𝑧𝑧

𝜕𝜕2𝐸𝐸𝜕𝜕𝑧𝑧𝜕𝜕𝛽𝛽𝜕𝜕2𝐸𝐸𝜕𝜕𝛽𝛽2 ⎦

⎥⎥⎥⎥⎥⎥⎥⎥⎤

(30)

Since we have four degrees of freedom, the Hessian is a symmetrical 4 × 4 matrix. A graphical

representation of the finite difference calculation for 𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥2 and

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝑦𝑦

is shown below:

Page 37: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

37

Figure 16: Graphical representation for finite difference H calculation

Where 𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥2 can be calculated by the following:

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥2 ≅

𝐸𝐸(𝑥𝑥𝑘𝑘 + ∆𝑥𝑥, 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘) − 2 ∙ 𝐸𝐸�𝑥𝑥𝑘𝑘 , 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘� + 𝐸𝐸(𝑥𝑥𝑘𝑘 − ∆𝑥𝑥, 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘)∆𝑥𝑥2 (31)

And 𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝑦𝑦

can be calculated by the following:

𝜕𝜕2𝐸𝐸𝜕𝜕𝑥𝑥𝜕𝜕𝑦𝑦

≅[𝐸𝐸(𝑥𝑥𝑘𝑘 + ∆𝑥𝑥, 𝑦𝑦𝑘𝑘 + ∆𝑦𝑦, 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘) − 𝐸𝐸(𝑥𝑥𝑘𝑘 , 𝑦𝑦𝑘𝑘 + ∆𝑦𝑦, 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘)] − �𝐸𝐸�𝑥𝑥𝑘𝑘 + ∆𝑥𝑥, 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘� − 𝐸𝐸�𝑥𝑥𝑘𝑘 , 𝑦𝑦𝑘𝑘 , 𝑧𝑧𝑘𝑘 , 𝛽𝛽𝑘𝑘��

∆𝑥𝑥 ∙ ∆𝑦𝑦 (32)

Since we are evaluating the Hessian using finite difference, it is relatively simple to compute.

However, this is dangerous because it tends to allow the inverse of the Hessian to be (nearly) singular or

badly scaled, which may invalidate equation (28). This is a major area of literature on Newton

optimization [20]. There are many Hessian approximation techniques available, such as the Broyden–

Fletcher–Goldfarb–Shanno (BFGS) method, which updates the Hessian by observing successive gradient

vectors instead of direct calculation [20]. Such techniques are known as ‘Quasi-Newton’ methods, as

there is no inversion of the Hessian. Due to the volatility of the Hessian, we added a threshold to the

maximum step values allowed. If the desired step is above a threshold, 𝜌𝜌, the step will be multiplied by

0.1 until it is below 𝜌𝜌. This is essentially a “safety” which keeps the step within the “bowl” containing

the minimum.

Page 38: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

38

Similar to Gradient Descent, we must determine stopping criteria that allows the algorithm to

assume 𝒙𝒙𝑘𝑘+1 is the approximate global minimum of 𝐸𝐸. We will again use the criterion, 𝜀𝜀, that is shown

in equation (23) augmented with the additional criterion 𝜏𝜏. Therefore, when the change in 𝒙𝒙𝑘𝑘 is

sufficiently small and 𝐸𝐸(𝒙𝒙𝑘𝑘+1) is less than 𝜏𝜏, we will stop iterating.

To minimize computation, a modified Newton approach exists, where the Hessian is approximated

by the Hessian diagonals, making the Hessian a vector, rather than a matrix. This is a less precise version

of the Newton method, in that there is no cross-dimensional parabolic compensation; that is, movement

is only based on approximated parabolas that exist in each degree of freedom independently. Therefore

(29) can be simplified to:

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼∇𝐸𝐸(𝒙𝒙𝑘𝑘)𝜕𝜕2𝐸𝐸𝜕𝜕𝒙𝒙𝑘𝑘2

(33)

Where 𝒙𝒙𝑘𝑘 is the 𝑘𝑘𝑒𝑒ℎ position vector [𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝛽𝛽]𝑇𝑇 , and the division represents element by element

division.

In order to arrive at the minimum of 𝐸𝐸, we must have an initial starting point, (𝑥𝑥𝑝𝑝 𝑦𝑦𝑝𝑝 𝑧𝑧𝑝𝑝 𝛽𝛽𝑝𝑝), chosen

carefully to prevent a badly scaled Hessian inverse. Additionally, the guess must be within the inflection

point that contains the minimum, due to the directionality of 𝒙𝒙𝑘𝑘 governed by the signs of the Hessian

(i.e. the Hessian must be positive definite). This is a stricter criteria than that for Gradient Descent, as

we must be within the inflection point, not just within the “bowl”, and requires us to know

approximately where to begin the search. Since we have a 4-D solution space grid already defined in

(18), we can simply start at the minimum of (18) defined by (19) and (20). Again, this requires us to

store the 𝐵𝐵𝑇𝑇, and determine the 𝐸𝐸𝑇𝑇 for the initial guess.

Page 39: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

39

In summary, we have defined the Newton method that begins with an initial value [𝑥𝑥𝑝𝑝 𝑦𝑦𝑝𝑝 𝑧𝑧𝑝𝑝 𝛽𝛽𝑝𝑝]𝑇𝑇, and

iterates following a step given by a second order approximation of 𝐸𝐸, until the change in 𝐸𝐸 is sufficiently

small and 𝐸𝐸 is less than a critical value 𝜏𝜏. This point is taken as a representation of the approximate

minimum of 𝐸𝐸. Parameters used in the Newton method are given in Appendix A.

Figure 17: Example of the Newton Method NOTE: 8 Iterations

Algorithm Architecture In addition to providing a suitable method for inverting the dipole equations,

we devised an architecture for the algorithm and overall structure of the device. The algorithms must

be able to track a moving magnet, in addition to finding its position and orientation in space. We

created an outer-program, known as the shell, and the algorithms run within the shell. The algorithms

operate in sequence by determining the magnet angle one instant at a time, each sequence is denoted

as a cycle.

The Look-Through Table architecture is simple, in that during each cycle the sensor values are read

in, and the 𝐸𝐸𝑇𝑇 is determined and the minimum is found. Upon determining the rotation from the table

indexes, it is then output to the motor controller via the data acquisition card. Once this is complete, it

Page 40: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

40

starts over; the process completed was one cycle. Thus, all cycles during operation of the Look-Through

Table are identical and independent.

For Gradient Descent and the Newton method, the first cycle must begin with an appropriate initial

guess. This guess is determined by finding the minimum of the 𝐸𝐸𝑇𝑇. Once the initial guess is determined

and the algorithm converges on a solution, the second cycle starts. The initial guess for each

subsequent cycle is taken as the solution from the previous cycle. This may ensure that the initial

guesses remain in the vicinity of the solution. Additionally, we stipulate a maximum number of

iterations as a stopping point, in case the algorithm does not converge; we will select a number that is

dictated by the rate of convergence of the algorithms. If the solution does not converge in the

maximum iterations or the error goes above a threshold, the algorithm can assume it will not converge.

Therefore, the minimization of the 𝐸𝐸𝑇𝑇 is used as an initial guess.

In summary, we have laid the foundation of the architecture that will enable the shell to track the

position and orientation of the magnet in real-time.

Comparison Tests

In order to determine the feasibility of each inversion technique, we determined tests that may be used

for comparison. The algorithms were judged with respect to two tasks:

1. General determination of magnet position and orientation

2. Tracking a simulated magnet trajectory in time-space

These two tasks provided suitable characterization of each algorithm in that they measured the ability

of the algorithms to find a magnet position and orientation (cycle 1 for Gradient Descent and Newton),

and track the magnet as it moved in space (remaining cycles for Gradient Descent and Quasi

Page 41: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

41

Newton/all cycles for Look-Through Table). Thus, all areas of the architecture were tested and can be

compared.

In test 1, we examined the algorithm’s ability to determine a solution for random positions and

orientations of the magnet. A single trial consisted of a random selection of the magnets position and

orientation from the possible workspace, which was defined as possible locations for the magnet in

clinical application. In the Y and Z-directions, the workspace was defined as [−30, 30] mm, and in the

X-direction it was defined as [−5, 5] mm. The Y and Z-axis limitations arose from the geometry of the

residual limb, and X-axis limitation arose from probable limitations in socket movement. The test

consisted of 1000 trials. Metrics that were compared include the error in the rotation between the

solution and the simulated value, the average rotational error, and the number of iterations completed

(where applicable).

Test 2 consisted of a simulated path and the results of the algorithms attempt to follow it. The path

chosen was a Lissajous trajectory, with the formula given in Appendix B. This trajectory was chosen

because it was moderately complex, continuous, and explores much of the workspace. For the

applicable algorithms, the first cycle began with the initial guess via the 𝐸𝐸𝑇𝑇. Then the algorithms

followed the path, dependant on the solution found in the previous cycle. The metrics compared were

the same as those listed above: rotational error, average error, number of iterations, and the additional

metric of resolution. The resolution is assigned based on the number of points needed to complete the

trajectory. Trajectories with a lower resolution have fewer points, and therefore larger gaps. Thus, for

the iterative algorithms, the proximity of the initial guess to the solution was crucial, and the larger the

gap, the farther the algorithm must traverse through the solution space.

In the tests mentioned above, the simulated 𝐵𝐵�⃑ was calculated directly from the dipole equations.

Therefore, this may be considered the “best case scenario,” in that the 𝐵𝐵�⃑ fields generated by the

Page 42: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

42

algorithms exactly matched the simulated fields. In order to more accurately represent a real system,

tests 1 and 2 were also completed with an inherent noise term. Thus, the simulated 𝐵𝐵�⃑ fields had an

additional term representing random noise. The noise term added was twice that of the RMS output

noise seen from the sensors in Table 3, thereby more accurately reflecting real-world conditions.

Translation to the Physical Model

Once a suitable algorithm was chosen from the results of the computational studies, we tested the

chosen algorithm on the physical model. Tests included errors in rotation due to translations along the

X, Y and Z axes.

Physical Model To test the determination of magnet position and orientation, we developed a physical

model with approximately anatomical dimensions (Figure 18). The goal of the model was to not only

represent the anatomic structures, but also demonstrate all possible combinations of constrained

rotation and translation.

Page 43: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

43

Figure 18: Picture of physical model

Magnet A Neodymium-Iron-Boron (NdFeB) rare earth magnet was used because of its availability and

high strength. For this magnet, the residual inductance (Br) was 13.2 kG and the grade was N40. We

used cylindrical NdFeB magnets with a diameter of 6.35 mm and a length of 19.05 mm. The size was

dictated by the ability to fit within the residual humerus once encased within a biocompatible material.

Casing In order for a magnet to be implanted into the body, it must be encased in a substance that is

biocompatible. Additionally, it must be placed in a substance that will not attenuate the magnetic field.

Titanium was chosen because it has a relative magnetic permeability of 1.00005 at 1600 A/m (20 Oe)

[21]. The relative magnetic permeability is defined as:

𝜇𝜇𝑟𝑟 = 𝜇𝜇𝜇𝜇0

(34)

Page 44: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

44

Where μ0 is defined as the permeability of free space (4π×10−7 N·A−2), μ is the magnetic permeability and

μr is the relative magnetic permeability. Therefore, the relative magnetic permeability indicates that

titanium behaves very similarly to free space. The relative magnetic permeability is slightly greater than

1, thus titanium is paramagnetic. Paramagnetic substances act slightly magnetic only in the presence of

an external magnetic field. However, paramagnetic substances do not retain any magnetism following

the removal of the external magnet field, a phenomenon known as hysteresis [22]. Additionally,

titanium is biocompatible and is used in surgical implants in a wide variety of applications. The casing is

threaded to mimic the characteristics of a simple orthopedic screw (Figure 19).

Figure 19: Threaded titanium with encased magnet

Model Arm The average adult male upper arm circumference is 30 cm [23], making the average male

upper arm diameter approximately 10 cm. Therefore, the model arm was constructed from a 10 cm

inner diameter clear acrylic tube (thickness of approximately 6 mm) with the inner-surface of the tube

representing the surface of the arm. There was no medium inside the tube because the magnetic

permeability of tissue is approximately the same as that of free space [24].

Model Bone The average male humerus diameter is 2.3 cm [25], hence the bone was modeled as a 2.3

cm diameter extruded nylon rod. The magnetic permeability of nylon is approximately that of free

space, so no disturbance of the magnetic field was expected. The nylon rod was mounted in a 25 mm

Page 45: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

45

inner-diameter stainless-steel bearing far from the magnet. The encased magnet was threaded into the

nylon through a 9.5 mm diameter hole, 1 cm from the distal end of the nylon rod (Figure 20).

Figure 20: Picture showing model arm and model bone

Magnet Position and Orientation Motion In order to address the degrees of freedom, we installed

hardware on the model that allowed for the necessary movements of the magnet, as well as the

measurement of the respective movements. To provide Y-axis translation, a linear stage was installed

under the acrylic tube. The aluminum stage was fastened to a custom-made aluminum carrier which fit

the arc of the acrylic tube. The linear stage slid on a 6 mm anodized aluminum rod. The aluminum rod

slid through an aluminum bushing to ensure smooth translation. This allowed the tube to move around

the stationary bone, effectively causing the bone to translate relative to inside of the arm. Z-axis

translation was addressed with a polypropylene carriage that supported the roller bearing and nylon

bone. This carriage translated in the Z-direction on two plastic bushings within the polypropylene

carriage. The carriage/bushings slid on two 12 mm anodized aluminum rods. The sliding of the carriage

was direct Z-axis translation of the magnet within the model arm. The radius of rotation (Rm) can be

changed by screwing the encased magnet through the nylon bone. To facilitate this, several

Page 46: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

46

magnet/titanium packages were created, each with a different shaft length, allowing the relative

displacement of the magnet from bone. This simulated the bone traveling in an arc of radius Rm.

Figure 21: Linear stage and carrier demonstrating Y-axis translation

Figure 22: Carriage and sliding bars for Z-axis translation

Sensors In order to determine the position and orientation of the magnet, the magnetic field vector at

any a given position had to be measured. Magnetic fields may be measured by a variety of sensors,

including magnetoresistive sensors, fiber-optic magnetometers or Hall-effect sensors [26]. For our

application, we needed sensors that could detect a wide range of field magnitudes, yet were also

sensitive and had a low noise floor to provide a signal not confounded by saturation or noise. The

Page 47: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

47

sensors chosen were Allegro A3515 linear ratiometric Hall-effect sensors. These sensors had a

sensitivity of 5V/1000 Gauss (G) and a working range of -500 – 500 G with a 5V supply voltage . The

sensors had an RMS noise of 400 μV or 0.08 G and a supply current of approximately 7.2 mA at 25°C.

The sensor voltage at 0 G was approximately 2.5 V (with a 5.0 V supply), which indicates a ±2.5 V or 500

G range [27].

The Hall effect arises from the nature of current flowing through a conducting medium. The current

is made of flowing electrons, and in the presence of a (non-parallel) magnetic field, the electrons

experience a force, known as the Lorentz force. The Lorentz force causes the flowing electrons to

gather on one side of the plate, creating a potential difference across the plate. The equation that

governs the potential difference is:

𝑉𝑉𝐻𝐻 =− 𝑝𝑝𝑚𝑚 × 𝐵𝐵�⃑

𝑒𝑒 ∙ 𝑒𝑒 (35)

where 𝑉𝑉𝐻𝐻 is the voltage produced across the plate, 𝑝𝑝 is the current through the plate, 𝐵𝐵�⃑ is the applied

magnetic field vector, 𝑚𝑚 is the thickness of the plate, 𝑒𝑒 is the charge carrier density of the electrons and

𝑒𝑒 is the electron charge [28]. Therefore, from (35) we can see that under certain restrictions (i.e.

constant current), the output voltage will be proportional to the applied magnetic field. In general, Hall-

effect sensors sense the component of magnetic field that is perpendicular to the plate within the

sensor.

Page 48: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

48

Figure 23: Allegro linear Hall-effect sensor (left), location of sensing plate (right)

Description Min Average Max Units Supply Voltage 4.5 5.0 5.5 V Supply Current - 7.2 10 mA Output Voltage 0.2 2.5 4.7 V Wide-Band Output Noise - 400 - μV Operating Temp -40 - 85 °C Sensitivity at T = 25 °C 4.5 5.0 5.5 mV/G

Table 3: Allegro A3515 sensor properties

The sensors had to be placed close enough to the magnet to preserve substantial magnetic field, but far

enough away to be placed within a prosthetic socket. As a baseline for testing, we chose a location 2

cm. distal to the end of the model bone. With the magnet placed 1 cm. proximal to the end of the bone,

there was an effective distance of 3 cm between the magnet and sensors. The exact position of the

sensors was discussed above (Sensor Placement).

Data Acquisition and Computational Processing A National Instruments NI USB-6218 data

acquisition (DAQ) device was used to collect data from the Hall-effect sensors. The 16-bit A/D device

was configured using 16 differential inputs with a sample rate of 1000 Hz. The differential configuration

was used in order to help eliminate common-mode noise from the signal. MATLAB was used to perform

all aspects of the data acquisition and computation.

Page 49: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

49

Prosthetic Rotator and Control We chose a Pittman brushed DC motor with a 19.5:1 gearbox and a

built-in optical encoder, counting 500 counts per revolution, for the prosthetic rotator. This motor

allowed us to accurately control position while maintaining a large range of possible angular velocities.

A PIC 18f4520 microcontroller was used to control the motor. Thus, we had the NI DAQ device output

an analog voltage indicating a scaled version of the rotation. The PIC read in the analog voltage and

used the encoder to match the angle of the motor. The PIC used standard closed-loop control, with a

proportional-derivative control scheme [29].

Figure 24: Closed-loop motor control diagram

Shell The 𝐵𝐵�⃑ will be read in from the sensors. The sample rate will be set to 1000 Hertz (Hz). Depending

on the speed of the algorithm, the shell will read in all samples available (i.e. if the shell operates at 20

Hz, it would read in 50 samples per cycle). The mean will be taken of each channel and the

corresponding voltage will be converted in Gauss. The Gauss values obtained will be used as 𝐵𝐵�⃑ 𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 in

the algorithms seen above.

Testing the Physical Model

In order to quantify the results of the algorithm when used with the physical model, we compared the

predicted locations with the actual magnet location. This will enable us to objectively evaluate

algorithm robustness to translation in the workspace. We examined the error in all the translation

directions as well as rotation.

Page 50: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

50

To test the errors in when the magnet is translated in the X-direction, the magnet was located in the

center at 0° and slowly moved in the X-direction. X-translation is defined as the sensors moving forward

in the X-axis. This is analogous to the socket slipping off the amputee. The system is restricted to

getting closer than approximately -25 mm to the sensors due to the relative position of the sensors and

the magnet within the bone.

Similarly, we tested the errors associated with Y and Z translations. In each case the magnet is

oriented at 0° and translated through the workspace. The errors are taken as the magnet is translated.

Due to the symmetrical nature of the physical model, the errors should all be even or odd symmetric

about the origin.

Page 51: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

51

Chapter III: Results

Computational Results

Grayed table section indicates added noise.

Look-Through Table Random Trials For each trial, a pre-constructed 𝐵𝐵𝑇𝑇 was used with grid dimensions of 2.5 mm for

𝑥𝑥,𝑦𝑦, 𝑧𝑧 and 6° for 𝛽𝛽. For the 1000 random trials, 49.5%, 63.6% and 98.0% of the predicted solutions

were within 0.1 degrees, 1 degree and 5 degrees of the actual orientation (𝛽𝛽𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 − 𝛽𝛽𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 ),

respectively. The mean absolute value of 𝐵𝐵�⃑ 𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 and 𝐵𝐵�⃑ 𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 was 1.94° with a standard deviation of

1.80°. When ± 0.16 G random noise was added, the accuracy was 49.8% within 0.1 degrees, 62.2%

within 1 degree and 97.8% within 5 degrees. The mean absolute value of error was 2.09° with a

standard deviation of 1.78°.

# Trials % within .1° % within 1° % within 5° Mean |Error| (°) Grid Dim (mm) Noise (G)

1000 49.50 63.60 98.00 1.94 (1.80) 2.5 01000 49.8 62.2 97.8 2.09 (1.78) 2.5 ± 0.16

Table 4: Results of Look-Through Trials

The error for the orientation is shown in Figure 25. The error follows a normal distribution due to

the nature of the random test. The shape of the distribution can be set, based on the resolution of the

𝐸𝐸𝑇𝑇.

Page 52: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

52

Figure 25: Histogram of orientation error (with noise)

Lissajous Trajectory The Look-Through Table was tested with a resolution of 10, indicating the

average steps of 6.37 mm/step, and 3.7°/step. Similar to the random trials, 60.3%, 69.4% and 94.0% of

the predicted solutions were within 0.1 degrees, 1 degree and 5 degrees of the actual orientation,

respectively. The mean absolute value of error was 3.57° with a standard deviation of 3.32°. When

noise was introduced, the algorithm determined 53.1% within 0.1 degrees, 66.10% within and 1 degree,

and 96.6% within 5 degrees. The mean absolute value of error was 2.00° with a standard deviation

1.56°.

In order to estimate the computational burden associated with the determination of the magnet

orientation for each cycle, the floating point operations (FLOPs) were determined for each algorithm.

The computational burden associated with generating the 𝐸𝐸𝑇𝑇 from the 𝐵𝐵𝑇𝑇 is substantial. Due to the

generation of the 𝐸𝐸𝑇𝑇, there are 𝑒𝑒 ∙ �6 ∙ (𝑆𝑆𝑥𝑥 ∙ 𝑆𝑆𝑦𝑦 ∙ 𝑆𝑆𝑧𝑧 ∙ 𝑆𝑆𝛽𝛽) − 4� floating-point operations, where 𝑒𝑒 is the

number of point (3-axis or 1-axis) sensors used, and 𝑆𝑆𝑒𝑒 is the respective size of each dimension of the

𝐵𝐵𝑇𝑇. Therefore, each cycle uses approximately 80 megaFLOPs in the determination of the 𝐸𝐸𝑇𝑇 alone.

Page 53: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

53

Since the Look-Through Table uses the same method of determination for each cycle, the number of

FLOPs does not change with resolution in the trajectory.

Resolution Trials in Traj mm deg % within .1° % within 1° % within 5° Mean |Error| (°) MFLOPs/cycle Noise (G)

10 1000 6.37 3.70 60.30 69.40 94.00 3.57 (3.32) 80.0 010 1000 6.37 3.70 53.10 66.10 96.60 2.00 (1.56) 80.0 ± 0.16

Avg Step

Table 5: Results of Lissajous Trajectory for Look-Through Table

Figure 26: Actual and Predicted XYZ space for Look-Through Table (resolution = 10, noise)

Gradient Descent Algorithm Random Trials Gradient Descent was tested at two 𝐵𝐵𝑇𝑇 resolutions; a courser 10 mm for 𝑥𝑥,𝑦𝑦, 𝑧𝑧 and 9°

for 𝛽𝛽, and a finer 5 mm for 𝑥𝑥,𝑦𝑦, 𝑧𝑧 and 6° for 𝛽𝛽. This dictated the initial starting position for the descent

(the initial guess). The courser grid caused the algorithm to traverse a larger distance in the 𝐸𝐸𝑇𝑇. With

the courser 𝐵𝐵𝑇𝑇 grid, Gradient Descent determined the error between 𝛽𝛽𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 and 𝛽𝛽𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 for each

trial to be 86.1%, 99.3% and 100% within 0.1 degrees, 1 degree and 5 degrees respectively. The

algorithm took an average of 51.46 iterations, with a standard deviation of 27.38 iterations, to reach the

Page 54: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

54

stopping criteria. The mean absolute value of error was 0.14° with a standard deviation of 0.35°. When

the finer 𝐵𝐵𝑇𝑇 grid is used, the algorithm determined 86.6%, 99.7% and 100% within 0.1 degrees, 1 degree

and 5 degrees respectively. The mean iterations were reduced to 43.33 iterations with a standard

deviation of 24.87 iterations. The mean absolute value of error was reduced to 0.09° with a standard

deviation of 0.14°. When ± 0.16 G random noise was introduced the courser 𝐵𝐵𝑇𝑇 grid achieved 51.1%

within 0.1 degrees, 70.4% within 1 degree and 98.7% within 5 degrees. The average iterations were

51.87 iterations per trial, with a standard deviation of 28.2 iterations. The mean absolute value of error

increased to 1.65° with a standard deviation of 1.37°. The finer 𝐵𝐵𝑇𝑇 achieved 53.5% within 0.1 degrees,

68.5% within 1 degree and 98.6% within 5 degrees. The average iterations were 42.25 iterations per

trial, with a standard deviation of 23.9 iterations. In addition the mean absolute value of error was 1.75°

with a standard deviation of 1.34°.

# Trials % within .1° % within 1° % within 5° Mean Iter Mean |Error| (°) Grid Dim (mm) Noise (G)

1000 86.10 99.30 100.00 51.46 (27.38) 0.14 (0.35) 10 01000 86.60 99.70 100.00 43.33 (24.87) 0.09 (0.14) 5 01000 51.10 70.40 98.70 51.87 (28.20) 1.65 (1.37) 10 ± 0.161000 53.50 68.50 98.60 42.25 (23.92) 1.75 (1.34) 5 ± 0.16

Table 6: Results of Gradient Descent Trials

Lissajous Trajectory Trajectories were applied to the algorithm, where cycle 1 consisted of using the

𝐵𝐵𝑇𝑇 to determine an initial guess, with the following cycles using the previous determined position and

orientation as the initial guess. Resolutions of 15, 10 and 5 were tested, with the average steps

increasing from 4.3mm/2.46°, 6.37mm/3.7° and 12.66mm/7.37°, respectively. Resolutions below 5

could not be completed reliably, and the trajectory for a resolution of 10 is shown below. We will

consider the trajectory completed with a resolution of 5, however all results are summarized below.

Gradient Descent determined 50.2% of trials within 0.1 degrees of 𝛽𝛽𝑚𝑚𝑤𝑤𝑒𝑒 𝑚𝑚𝑚𝑚𝑒𝑒 , 57% within 1 degree and

77.8 within 5 degrees. The mean iterations/trial was 86.71, with a standard deviation of 21.6 iterations.

Page 55: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

55

The mean absolute value of error for the trajectory was 8.93° with a standard deviation of 11.3°. When

± 0.16 G random noise was introduced, the percent within 0.1 degrees and 1 degree remained the same.

However, the percent within 5 degrees increased to 78.4%. The average iterations remained

approximately the same at 87.29 iterations and a standard deviation of 20.97 iterations. The mean

absolute value of error also remained approximately unchanged at 8.88°, with a standard deviation of

11.25°.

During the first iteration of the shell, the FLOPs can be calculated similarly to the Look-Through

Table, however with a courser grid. Following the first cycle, the FLOPs are a direct result of the

computation inherent in the determination of the finite-difference gradients. The FLOPs associated with

each iteration of Gradient Descent are approximately 1 megaFLOPs. Therefore, the number of FLOPs

per cycle can be readily calculated. As shown in Table 8, the FLOPs/cycle steadily increases as the

resolution is decreased, due to the increase in iterations required to minimize the 𝐸𝐸 solution space.

Resolution Trials in Traj mm deg % within .1° % within 1° % within 5° Noise (G)

15 1500 4.3 2.46 51.80 64.13 90.40 010 1000 6.37 3.7 50.20 59.30 87.10 05 500 12.66 7.37 50.20 57.00 77.80 0

15 1500 4.3 2.46 52.07 64.07 90.47 ± 0.1610 1000 6.37 3.7 50.30 59.50 87.00 ± 0.165 500 12.66 7.37 50.20 57.00 78.40 ± 0.16

Avg Step

Table 7: Results of Lissajous Trajectory for Gradient Descent

Mean Iter Mean |Error| (°) MFLOPs/cycle Noise (G)

67.28 (30.72) 5.42 (8.49) 67.3 076.17 (28.51) 6.25 (9.17) 76.2 086.71 (21.26) 8.93 (11.30) 86.7 065.61 (33.88) 5.37 (8.34) 67.3 ± 0.1675.79 (30.34) 6.19 (9.04) 75.8 ± 0.1687.29 (20.97) 8.88 (11.25) 87.3 ± 0.16

Table 8: Continuation of Results of Lissajous Trajectory for Gradient Descent

Page 56: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

56

Figure 27: Actual and Predicted XYZ space for Gradient Descent (resolution = 10, noise)

Newton Method Random Trials Similarly, two grid types were used during the random trials testing the Newton

method. With courser 𝐵𝐵𝑇𝑇 grid, the Newton method determined the error between 𝛽𝛽𝑝𝑝𝑟𝑟𝑒𝑒𝑚𝑚𝑝𝑝𝑤𝑤𝑒𝑒𝑒𝑒𝑚𝑚 and

𝛽𝛽𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 for each trial to be 94.8%, 95.3% and 95.4% within 0.1 degrees, 1 degree and 5 degrees

respectively. The algorithm took an average of 24.88 iterations, with a standard deviation of 26.53

iterations, to reach the stopping criteria. The mean absolute value of error was 7.22° with a standard

deviation of 28.88°. When the finer 𝐵𝐵𝑇𝑇 grid is used, the algorithm determined 99.4%, 99.5% and 99.5%

within 0.1 degrees, 1 degree and 5 degrees respectively. The mean iterations were reduced to 7.17

iterations with a standard deviation of 10.1 iterations. The mean absolute value of error was reduced to

0.70° with a standard deviation of 7.17°. When ± 0.16 G random noise was introduced the courser 𝐵𝐵𝑇𝑇

grid achieved 66.6%, 94.6%, 95.0% within 0.1 degrees, 1 degree and 5 degrees, respectively. The

average iterations were 21.6 iterations, with a standard deviation of 26.3 iterations. The mean absolute

Page 57: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

57

value of error increased slightly to 7.97° with a standard deviation of 30.35°. The finer 𝐵𝐵𝑇𝑇 achieved

55.0% within 0.1 degrees, 98.5% within 1 degree and 99.6% within 5 degrees. The mean iterations were

10.5 iterations, with a standard deviation of 9.8 iterations. In addition the mean absolute value of error

was 0.90° with a standard deviation of 12.46°.

# Trials % within .1° % within 1° % within 5° Mean Iter Mean |Error| (°) Grid Dim (mm) Noise (G)

1000 94.80 95.30 95.40 24.88 (26.53) 7.22 (28.88) 10 01000 99.40 99.50 99.50 7.17 (10.10) 0.70 (7.17) 5 01000 66.60 94.60 95.00 21.65 (26.36) 7.97 (30.35) 10 ± 0.161000 55.00 98.50 99.60 10.46 (9.78) 0.90 (12.46) 5 ± 0.16

Table 9: Results of Newton Trials

Lissajous Trajectory Similar to Gradient Descent, resolutions of 15, 10 and 5 were tested, with the

average steps increasing from 4.3mm/2.46°, 6.37mm/3.7° and 12.66mm/7.37°, respectively. Again,

resolutions below 5 could not be completed reliably due to the large gaps between successive points.

We will consider the trajectory completed with a resolution of 5, however all results are summarized

below. The Newton method determined 99.2% of trials within 0.1 degrees of 𝛽𝛽𝑚𝑚𝑤𝑤𝑒𝑒𝑚𝑚𝑚𝑚𝑒𝑒 , 100% within 1

degree and 100% within 5 degrees. The mean iterations were 7.8, with a standard deviation of 1.0

iteration. The mean absolute value of error for the trajectory was 0.009° with a standard deviation of

0.01°. When ± 0.16 G random noise was introduced, the results changed dramatically for the 0.1 degree

case. Accuracy was reduced to 60% within 0.1 degree, but remained stable at 97.2% for 1 degree and

again 100% for within 5 degrees. The average iterations remained the same at 7.8 iterations with a

standard deviation of 0.98 iterations. The mean absolute value of error changed by several orders of

magnitude, but remained very low at 0.32°, with a standard deviation of 0.37°.

During the first iteration of the shell, the FLOPs can be calculated similarly to the Look-Through

Table, however with a courser grid. Following the first cycle, the FLOPs are a direct result of the

computation inherent in the determination of the finite-difference gradients. However, due to the

Page 58: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

58

determination of the Hessian matrix, the FLOPs associated with the Newton method are 2.6-times

greater than those associated with Gradient Descent. The FLOPs associated with each iteration of the

Newton method are approximately 2.6 megaFLOPs. Therefore, the number of FLOPs per cycle can be

readily calculated. As shown in Table 11, the FLOPs/cycle steadily increases as the resolution is

decreased, due to the increase in iterations required to minimize the 𝐸𝐸 solution space.

Resolution Trials in Traj mm deg % within .1° % within 1° % within 5° Noise (G)

15 1500 4.3 2.46 99.00 100.00 100.00 010 1000 6.37 3.7 99.50 100.00 100.00 05 500 12.66 7.37 99.20 100.00 100.00 0

15 1500 4.3 2.46 64.47 97.53 100.00 ± 0.1610 1000 6.37 3.7 64.00 97.30 100.00 ± 0.165 500 12.66 7.37 60.00 97.20 100.00 ± 0.16

Avg Step

Table 10: Results for Lissajous Trajectory for Newton

Mean Iter Mean |Error| (°) MFLOPs/cycle Noise (G)

6.33 (1.09) 0.009 (0.01) 16.4 06.84 (1.02) 0.01 (0.02) 17.8 07.82 (1.04) 0.01 (0.02) 20.3 06.51 (0.89) 0.32 (0.36) 16.9 ± 0.166.94 (0.88) 0.31 (0.33) 18.0 ± 0.167.84 (0.98) 0.32 (0.37) 20.4 ± 0.16

Table 11: Continuation of Results of Lissajous Trajectory for Newton

Page 59: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

59

Figure 28: Actual and predicted XYZ space for Newton (resolution = 10, noise)

Physical Model Results

The appropriate algorithm was implemented in the physical model and the position and orientation data

were compared to actual data read by digital scales or the precision rotational potentiometer. The

magnet was translated around the workspace to quantify the errors in measuring varying magnet

position. We will examine translations in the X, Y, and Z-directions, and 𝛽𝛽-rotation (denoted R in

MATLAB). The plane with the sensors is set as the zero in the X-direction.

Page 60: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

60

Figure 29: Errors associated with magnet X-translation

The position and orientation errors slowly diverge as the magnet moves farther from the sensors,

and reaching a maximum of approximately 8 mm, 6 mm, -2 mm and -8 degrees for 𝑥𝑥,𝑦𝑦, 𝑧𝑧 and 𝛽𝛽,

respectively.

Further from sensors

Page 61: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

61

Figure 30: Errors associated with magnet Y-translation

Similarly, with the magnet located along the center at 0°, it is translated in the Y-direction. It should

be noted that the figure is roughly symmetric, which is consistent with the sensor geometry and circular

nature of the physical model. With Y-translation, the errors in 𝑥𝑥 are limited to about 4 mm, errors in 𝑦𝑦

are sinusoidal with an amplitude of approximately 2 mm. The errors in 𝑧𝑧 change linearly with Y-position,

with a maximum of approximately 4 mm, and the errors in 𝛽𝛽 do not exceed 3 degrees.

Page 62: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

62

Figure 31: Errors associated with magnet Z-translation

Similar to translations in Y, translations in Z are quasi-symmetric with the exception of the rotational

errors. The overall symmetry is appropriate, due to the circular nature of the physical model, the Z-

translation should mimic the Y-translation. However, translations in the Z-direction with the magnet

orientation at 0° are along the long axis of the magnet, which will cause irregularities in the

determination of magnet position and orientation. This is due to the breakdown in the dipole

equations, specifically as the magnet translates across the sensors which occurs at Z = 20 mm. This is an

artifact of the geometry of the magnet and sensor geometries. It can be addressed by using a magnet

that has a similar dipole moment, but does not have the length separating the poles. Furthermore, a

sensor geometry that prevented the magnet from “straddling” or going outside the ring would aid in

preventing such dipole-breakdown artifacts. This is discussed in further detail in [29]

Page 63: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

63

Figure 32: Errors associated with magnet 𝜷𝜷 rotation

This test was completed with the magnet in the center of the workspace, and subsequently rotated

and the error is shown above. The positional errors all remain relatively low, approximately less than 1

mm. The rotational error oscillates about 0 degrees, with an amplitude between 1 and 2 degrees.

Page 64: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

64

Chapter IV: Discussion

Sensor Placement

Sensor placement is crucial to the viability of the algorithms, especially those that traverse the

solution space. We have defined locations for four 3-axis sensors, 90° apart around a 2 cm. radius circle.

These locations were used for all computational determinations of 𝐵𝐵�⃑ , for all algorithms.

Additionally, there is something to be said for the addition of sensors, purely for the augmentation

of the 𝐸𝐸 solution space. For every additional sensor, there is a corresponding alteration in the contours

of the 𝐸𝐸 solution space, namely, the slopes become greater. This is because each additional sensor

results in an additional term in (16), causing the values of 𝐸𝐸 to increase everywhere, except the at

solution (assuming it is unique); however, this does not affect all areas of the 𝐸𝐸 solution space equally.

This factor does not lend itself to quantification; however, it should be considered carefully when

determining the location of sensor placement. The ramifications of this include altering error surface

the algorithm is traversing, causing it to be more or less difficult to find the minimum.

Since sensor placement was initially determined qualitatively, there is much potential for an

increase in algorithm efficiency and/or accuracy following the determination of optimally placed

sensors. This would be an excellent next step in algorithm development and could have a major impact

on the algorithm characteristics.

Look-Through Table

The Look-Through Table method involved the minimization of the 𝐸𝐸𝑇𝑇. Thus, the resolution of the

solution was restricted to that of the 𝐵𝐵𝑇𝑇. Therefore, depending on the desired accuracy, we can then

set the resolution of the grid defining the 𝐵𝐵𝑇𝑇 . For the results shown above, the dimensions of the 𝐵𝐵𝑇𝑇

used for the Cartesian axes was set to 2.5 mm, and the resolution for the orientation was set to 4.5°.

This enables most solutions to be within 2.25° of the solution. Additionally, the error followed a normal

Page 65: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

65

distribution around zero, which can be seen by the histogram of error shown in Figure 25. This leads us

to the desire to make the resolution as fine as possible, thereby reducing the average absolute value of

error.

We see similar characteristics in the Lissajous trajectory plots. Approximately all the data (>94%) fall

within 5° of the actual orientation used to create the trajectory. An interesting finding is that the mean

and standard deviation of the mean absolute value of error for the case with ± 0.16 G random noise is

significantly lower than that of the case without noise. This could be due to the ambiguity between the

relationship of the minimum of the 𝐸𝐸𝑇𝑇 with respect to the proximity to the solution. Perhaps the

addition of noise, effectively allows the minimum of the 𝐸𝐸𝑇𝑇 to less frequently misrepresent the node

that is closest to the solution. It is interesting that there are physiological analogies, such as vision,

when a small amount of Gaussian noise is introduced, perceived distortion actually decreases, despite

the increase in noise.

For the determination of magnet position and orientation, each cycle uses approximately 80

megaFLOPs. The number of FLOPs is proportional to the power of the resolutions used in creating the

𝐵𝐵𝑇𝑇. This translates to a tradeoff between accuracy (resolution of the 𝐵𝐵𝑇𝑇) and the operating speed

between cycles (frequency). Due to the imposed restrictions on accuracy from the design constraints,

and the speed required for device operation, we must conclude that the Look-Through Table does not

meet the design requirements.

However, it should be noted that the Look-Through Table method has advantages. The error will

(almost) always be bounded by the resolution of the grid. Additionally, since it is not traversing the 𝐸𝐸

solution space, it will always find a solution based on the data that is input; as it is not susceptible to

finding local minima as is Gradient Descent or being on the wrong side of an inflection point as is the

Newton method.

Page 66: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

66

Gradient Descent

The Gradient Descent algorithm follows the negative gradient until it converges on the minimum of an

n-dimensional space. In order to quantify the dependence of the algorithm to the initial guess, two sets

of 𝐵𝐵𝑇𝑇 resolutions were tested. The finer resolution enabled the algorithm to have a shorter distance to

traverse and minimized the chance that the initial guess would fall into a local minimum. Without

noise, the algorithm performed very well, greater than 99% of trials had less than 1 degree of error and

all trials had error less than 5 degrees. The course 𝐵𝐵𝑇𝑇 grid performed similarly, thus error statistics were

independent of grid resolution. The algorithm was able to compensate for the increased grid resolution

by taking an average of about eight more iterations to reach the solution. This helps us understand that

the “bowl” in the 𝐸𝐸 solution space is large enough not to fall in-between the grid resolutions. When the

± 0.16 G random noise was introduced, the algorithms accuracy dropped to getting approximately 99%

with less than 5 degrees error. The noise may have slightly altered the location of the global minimum

in the 𝐸𝐸 solution space or it may have enlarged the “bowl” creating an area at the base of the global

minimum with very low slope (effectively causing the algorithm to stop due to the stopping criterion).

Similar to the case without noise, the grid resolution did not have an effect. Therefore, we can conclude

that future work involving the Gradient Descent algorithm would not require a fine resolution for the

𝐵𝐵𝑇𝑇. The benefits of the courser resolution include less memory required for storing the 𝐵𝐵𝑇𝑇 in the host

microprocessor that will run the algorithm. Additionally fewer FLOPs are required to convert the 𝐵𝐵𝑇𝑇 to

the 𝐸𝐸𝑇𝑇. In the Gradient Descent algorithm the 𝐵𝐵𝑇𝑇 is only used for the first iteration, unless the

algorithm exits due to the local minimum contingency. The local minimum contingency will cause the

shell to exit and re-lay the 𝐸𝐸𝑇𝑇 if the gradients go to zero but the error is still sufficiently high. This is a

preventative measure that keeps the algorithm robust to local minimum. Additionally, since the shell

uses the position and orientation determined in the previous cycle as the initial guess, if the position and

orientation are changing sufficiently, the initial guess will no longer be in the proximity of the global

Page 67: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

67

minimum. Thus, the local minimum contingency will cause the shell to exit and it will find the position

and orientation again, as if it were the first cycle of the shell.

This brings us to the Lissajous trajectory, where the 𝐵𝐵𝑇𝑇 is only used on the first cycle. In these trials,

the local minimum contingency was not applied. Thus, we are within the maximum step size allowed by

the geometry of the 𝐸𝐸 solution space. In other words, the resolutions shown in the results involve steps

that are traversable. An interesting result of the Lissajous trajectory is that the random noise seems to

have no effect on the accuracy, the mean iterations taken, or the mean absolute value of error. With

the lowest resolution, the algorithm gets approximately 78% within 5 degree, in about 90 iterations.

This shows that it becomes difficult for the algorithm to find the minimum in 100 iterations (limited), or

it may stop because of the stopping criteria. To address this issue, the step size coefficient (𝛼𝛼) could be

increased; however this may cause the algorithm to become unstable. Thus, it may be beneficial to use

an adaptive step that minimizes a function of the step size coefficient. Due to the high average

sustained error during the determination of the trajectory, we can conclude that Gradient Descent does

not meet our design requirements.

The computational burden for the Gradient Descent algorithm is substantially less than that of the

Look-Through Table. We will focus on the computations following the first iteration of the shell (cycle),

as that is where the algorithm remains while following trajectories. During each iteration following the

initial determination of the initial guess via the 𝐸𝐸𝑇𝑇, the algorithm must compute approximately 1

megaFLOPs per iteration. Due to the relatively high number of iterations required to reach a solution in

each cycle, the Gradient Descent algorithm is computationally inefficient.

Newton Method

Similar to the Gradient Descent algorithm, the Newton method got approximately 99% within 1 degree,

regardless of noise. With the use of the course 𝐵𝐵𝑇𝑇 the accuracy dropped about 5%. This suggests that

Page 68: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

68

the Newton method is more sensitive to the initial guess. Also, notice that the accuracy did not change

substantially between 1 degree and 5 degrees accuracy. This suggests that when the algorithm cannot

determine the solution, the predicted value it determines is substantially different than the actual

solution (i.e. not within 5 degrees). This can be explained by the inflection point issue, and the Hessian

inversion issue. Occasionally, when the initial guess is substantially far from the solution, it may cause

the algorithm to diverge. Notice that the iterations required to reach the solution were approximately

24 for the course grid and approximately 8 for the fine grid. This demonstrates the algorithms

efficiency, and the propensity for the 𝐸𝐸 solution space to be traversed by minimizing a quadratic. Thus if

we can keep the initial guesses relatively close to the solution, the algorithm will converge very rapidly.

The results for the Lissajous trajectory were remarkable. All trajectories got 100% of the

trajectory within 5 degrees, regardless of noise. When noise was added, it significantly decreased the

percentage with error less than 0.1 degree; however, this is a very reasonable result of the addition of

noise. Furthermore, the accuracy percentages remained virtually constant over all three resolutions

tested. This shows that the algorithm is robust to initial guesses provided that they are within the

inflection point of the solution.

The computational burden for the Newton method is substantially less than that of the Look-

Through Table, but is greater than the Gradient Descent algorithm. We will focus on the computational

load following the first iteration of the shell, as that is where the algorithm remains while following

trajectories. During each iteration following the initial determination of the initial guess via the 𝐸𝐸𝑇𝑇, the

algorithm must compute approximately 2.6 megaFLOPs. Therefore, the Newton method requires more

FLOPs than the Gradient Descent algorithm, and in order to be more computationally efficient, it must

reduce iterations by more than the relative increase in FLOPs.

Page 69: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

69

To address the inflection point issue and the Hessian inversion issue, we similarly instituted the local

minimum contingency, where the shell would exit if the solution diverged. It then re-applied the 𝐵𝐵𝑇𝑇 and

came to a come to a solution, similar to the first cycle. This brings us to an important issue, which

involves the first iteration of the shell. If the shell will exit occasionally, the algorithm cannot spend a

significant amount of time searching to find the solution again. Thus, the 𝐵𝐵𝑇𝑇 must be kept as small as

possible, to avoid the delay associated with too many FLOPs. Therefore, in a clinical application the 𝐵𝐵𝑇𝑇

can be reduced to searching only the combinations of position and orientation that are possible by the

patient. For example, the 𝐵𝐵𝑇𝑇 that have been discussed all search through 2𝜋𝜋 radians, but clinically it is

unlikely that a patient will have such rotations possible by their residual bone, and the 𝛽𝛽 dimension of

the 𝐵𝐵𝑇𝑇 can be significantly reduced.

Additionally, it should be noted that some of the cases where the algorithm appears to diverge, it

actually finds a solution that is a multiple of 2𝜋𝜋 of the actual solution, because the solution surface is 2𝜋𝜋

periodic. To accommodate the cases when this occurs, if the returned orientation is greater than 2𝜋𝜋 (or

less than 0), the shell subtracts 2𝜋𝜋 (or adds 2𝜋𝜋) from the orientation, bounding it between 0 and 2𝜋𝜋. In

addition to taking care of bounding possible solutions, it also keeps the orientation in the bounds when

the rotation crosses 2𝜋𝜋 or 0.

Comparison of Algorithms

Algorithm % Error < 1°Avg. iterations

per cycleMFLOPs per

iterationMFLOPs per cycle

% Reduction in accuracy w/ noise

Re-initialize

Look-Through 66.10 1.00 80.00 80.00 4.75 NGradient Descent 59.50 75.79 1.00 75.80 -0.33 YNewton Method 97.30 6.94 2.60 18.00 2.70 Y* Data used from Lissajous trajectory with noise, resolution = 10

Table 12: Comparison of Algorithms

Page 70: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

70

In order to concisely show the results of the performance of the algorithms, we have broken the

algorithms down into six basic categories. These categories address the main practical issues associated

with the systems development. Most importantly, we investigated accuracy. This enabled us to

determine how the algorithms performed with respect to the overarching goal of magnet orientation

determination. For the Lissajous trajectory, with a resolution of 10, the Newton method outperformed

the Gradient Descent and the Look-Through Table by greater than 25%. Conversely, the error for the

Newton method was an order of magnitude less than that of the Look-Through Table and Gradient

Descent algorithm. This provides strong evidence that the Newton method is far superior to tracking a

moving magnet. This is likely due to the ability of the algorithm to effectively traverse the 𝐸𝐸 solution

space, without over-iterating. Another important factor is the average iterations to determine a

solution. This information should be considered in light of the number of FLOPs required for each

iteration. Thus, if only iterations are considered, it appears that the Look-Through Table is the most

efficient, requiring only 1 iteration to arrive at a solution. However, considering that each cycle of the

Look-Through Table requires 80 MFLOPs, compared to approximately 7 iterations for the Newton

method requiring only 2.6 MFLOPS. Thus, using the FLOPs as the indicator for computational burden,

we can see that the Newton method is the least computationally intense for each cycle. Another

important factor is the algorithms robustness to noise. To investigate this property, we looked at the

percent change in accuracy when the ± 0.16 G random noise was introduced. All algorithms had small

percent changes in accuracy with the addition of noise; specifically the Gradient Descent algorithm had

a slight increase in accuracy with the addition of noise. The Newton method had a 2.7 % decrease in

accuracy from 100% to 97.3% accuracy within 1°. Despite the small reduction in accuracy, the Newton

method still performed well. Lastly, we considered the property of re-initialization. This can be defined

as an instance when the algorithm cannot locate the suitable minimum of the 𝐸𝐸 solution space and must

re-lay the initial 𝐸𝐸𝑇𝑇 grid (when applicable). Table 12 states that the Newton method and Gradient

Page 71: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

71

Descent algorithms are susceptible to this property. Unfortunately, there is no convenient way of

quantifying this susceptibility, as it is dependent on the local surface of the 𝐸𝐸 solution space. A potential

future area of research regarding the algorithm development would be to reduce the possibility of this

occurrence. The Look-Through Table is not susceptible since it requires no initial-guess, and computes

solutions in the entire workspace.

Physical Model

In order to validate the results seen in the computational simulation, the Newton method was tested on

the physical model. The goal was to isolate the errors in the position and orientation caused by

translation and rotation in the workspace. This enabled us to determine the errors associated with the

breakdown of the algorithm or the errors in the dipole assumption. When the magnet was translated in

the X-direction, the errors diverged as the magnet was translated further from the sensors. The

divergence could be a result of the decreasing signal-to-noise ratio, which enables the minimum of the

of the 𝐸𝐸 solution space to not necessarily represent the true solution. However, even as the magnet

was translated in the X-direction, the magnitude of the errors remains relatively small, with the

maximum error in 𝛽𝛽 approaching 8 degrees as the magnet is translated 55 mm along the X-axis. This is

analogous to the socket moving/slipping off the amputee, thus, travel should be limited.

Translations in the Y and Z directions had similar results, each with quasi-symmetric errors about 0.

The rotational error remained approximately 3 degrees in the Y-axis translation. The rotational error in

the Z-axis translation diverged on the negative Z-translation. This is most likely a breakdown in the

dipole approximation and can be addressed in several ways. One method would be to reduce the

distance between the poles, shortening the magnet. Another method would be to increase the radius of

the sensor ring, preventing the magnet from straddling the sensors or going beyond the sensor ring.

One aspect to note is that the error in Z-translation diverges only on half of the workspace. This

Page 72: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

72

indicates that it may be a result of the sensors not being exactly orthogonal to one-another, which is not

compensated for in the algorithm. Clinically, these translations will be due to the bone moving in the

residual soft-tissue, or in the transradial case, the radius rotating around the ulna. In either case, we

would not expect to see deviations greater than 30 mm, where the rotational error is typically below 5

degrees. Similarly, the errors associated with the rotation of the magnet should be 𝜋𝜋2

periodic, due to

the locations of the sensors, which can be seen from Figure 32.

Due to the nature of the physical model, the error plots should be perfectly symmetric about the

origin for the translations in the Y and Z-directions. A possible explanation for why the errors were not

perfectly symmetric about the origin would be that the sensors may not be placed perfectly orthogonal

to one another. The sensors were fitted to blocks that would enable them to be nested orthogonal to

one another, but small deviations in their orthagonality are not accounted for in the algorithm.

Additionally, the algorithm depends on the location of the sensors with respect to one-another. If the

sensors are not positioned in the exact locations specified, it can cause errors in the algorithm that can

result in errors in the position orientation determination.

Page 73: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

73

Chapter V: Conclusion

Conclusion

In order to obtain an intuitive control mechanism that preserves proprioception we have developed an

algorithm that can track the rotation of an implanted permanent magnet. The rotation of the magnet

and residual bone will be ‘felt’ through the intact neural pathways in the limb and proximal joint, thus

providing the ability to feel the orientation of the limb in space. The Newton method has been shown to

have the ability to track the position and orientation of the magnet in space, with 97.3% of angular error

of less than 1 degree. If the algorithm ‘loses’ the position and orientation of the magnet, a robust

contingency plan has been implemented with little notice from users.

To address the device objectives, the following algorithm characteristics were obtained.

• The determination of angle is independent of magnet position. Therefore, if the magnet

translates in space, the algorithm does not confuse translation with a change in orientation.

• The algorithm can discern rotations anywhere from 0 to 360 degrees, dependent on the size

of the initial 𝐵𝐵𝑇𝑇 grid in the 𝛽𝛽 direction.

• The steady state error is less than 5 degrees most the workspace, and is within 1 degree

when the magnet is approximately centered (± 20 mm) in the workspace.

• The Newton method is relatively simple, using a minimal number of floating-point

operations. This is especially apparent when the number of iterations for each cycle is

considered.

Therefore, we have addressed all initial concerns for algorithm development.

Future Work

Despite the success of the algorithm and physical model, there is much work to be done to further

advance the precision of the algorithm and viability of the concept in general. A logical next step would

be the use of more advanced optimization algorithms such as the Levenberg-Marquardt algorithm that

uses a hybrid of Gradient Descent and Newton optimization to avoid the inflection point issue.

Page 74: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

74

Additionally, the Quasi-Newton algorithm: Broyden-Fletcher-Goldfarb-Shanno can be used to

approximate the Hessian, in order to negate issues associated with the inversion.

There are also several parameters that could be optimized in using the Quasti-Newton algorithm.

These factors include the step coefficient which was set to 0.85, which biases the algorithm to not take

the full step suggested by the Newton method. Ideally, the step coefficient would be adaptive in order

to push the algorithm through areas of low slope when the minimum is not close. Additionally, the size

of the finite-difference derivative approximation step could be optimized. The gain of this optimization

is unclear; however we chose an arbitrary small number of 0.00001 meters.

The most influential parameters to be optimized are likely the sensor number and placement. In our

case, we qualitatively assessed the most appropriate sensor number and placement with our algorithm

and the investigation of the magnet solution space, however, a great deal more research could be done

on this topic. This had substantial influence on the success of the project, because of the profound

influence of sensor number and placement on the 𝐸𝐸 solution space. Also, the sensor number and

placement dictates the workspace for the possible detection of magnet position and orientation,

therefore, if the workspace was designed for a different paradigm (i.e. maximum possible workspace)

the sensor configuration could reflect that while the algorithm remained unchanged.

Division of Thesis All of the work regarding this project was completed by both Elliott Rouse and David Nahlik. The

work was done cooperatively and in parallel, however much of the detail pertaining the algorithms was

explored by Elliott Rouse, and likewise much of the clinical implementation and analysis was completed

by David Nahlik. For further information pertaining to the clinical implementation, feasibility, as well as

many other aspects of this project, please reference David Nahlik’s MS Thesis seen in the references.

Page 75: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

75

Acknowledgements

I would like to acknowledge Dave Nahlik who contributed to all aspects of this project. Also, Todd

Kuiken M.D. Ph.D., Michael Peshkin Ph.D. and Allen Taflove Ph.D. for the guidance making this project

possible. Thanks to T. Walley Williams who initially conceived of the concept. Additionally, I would like

to thank Richard Weir Ph.D. and Aimee Schultz M.S. for their input and help in the preparation of this

thesis. This work was supported by the NIH National Institute of Child and Human Development, Grant

Number N01-HD-5-3402.

Page 76: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

76

References 1. Taylor, C., The biomechanics of the normal and the amputated upper extremity. Human Limbs

and Their Substitutes, ed. W.P. Klopsteg PE. 1954, New York: McGraw-Hill.

2. Engen, T., Spencer WA, Development of externally powered upper extremity orthotics, final report. 1969, Texas Institute for Rehabilitation and Research: Houston.

3. DeLisa, J.A., Physical Medicine and Rehabilitation. 2005, Philadelphia: Lippincott Williams and Wilkins.

4. Atkins, D.J., D.C.Y. Heard, and W.H. Donovan, Epidemiologic overview of individuals with upper-limb los and their reported research priorities. Journal of Prosthetics and Orthotics, 1996. 8(1): p. 2-11.

5. Gard, S.A., Prosthetic devices and methods, in Wiley Encyclopedia of Biomedical Engineering. 2006, John Wiley and Sons.

6. Li, G. and T.A. Kuiken, Modeling of prosthetic limb rotation control by sensing rotation of residual arm bone. IEEE Trans Biomed Eng, 2008. 55(9): p. 2134-42.

7. Jerosch, J. and M. Prymka, Proprioception and joint stability. Knee Surg Sports Traumatol Arthrosc, 1996. 4(3): p. 171-9.

8. Witso, E., et al., Improved comfort and function of arm prosthesis after implantation of a Humerus-T-Prosthesis in trans-humeral amputees. Prosthet Orthot Int, 2006. 30(3): p. 270-8.

9. Branemark, P.I., Osseointegration and Its experimental background. Journal of Prosthetic Dentistry, 1983. 50(3): p. 399-410.

10. Branemark, R., et al., Osseointegration in skeletal reconstruction and rehabilitation: a review. Journal of Rehabilitation Research and Development, 2001. 38(2): p. 175-81.

11. Raab, F., et al., Magnet position and orientation tracking system. IEEE Trans Aero and Elec Sys, 1979. 15(5): p. 709-718.

12. Troyk, P., et al., Design and implementation of an implantable goniometer. IEEE Trans Biomed Eng, 1986. 33(2): p. 215-222.

13. Johnson, M., et al., Implantable transducer for two-degree of freedom joint angle sensing. IEEE Trans Rehab Eng, 1999. 7(3): p. 349-360.

14. Sherman, J., et al., Characterization of a novel magnetic tracking system. IEEE Trans Magnetics, 2007. 43(6): p. 2725-2728.

15. Schlageter, V., et al., Tracking system with five degrees of freedom using a 2D-array of Hall sensors and a permanent magnet. Sensors and Actuators, 2001. 92: p. 37-42.

16. Griffiths, D., Introduction to electrodynamics. American Journal of Physics, 2005. 73(6).

Page 77: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

77

17. Mathworks. Maximum Matrix Size by Platform. 2009 [cited 2009 March].

18. Chong, E. and Z. Stanislaw, An Introduction to Optimization. 3rd ed. Wiley-Interscience Series in Discrete Mathematics and Optimization. 2008, Hoboken: John Wiley and Sons. 608.

19. Nocedal, J. and S. Wright, Numerical Optimization. Springer Series in Operations Research, ed. G. P. 1999, New York: Springer Science+Business Media.

20. Press, W., et al., Numerical Recipes in C. 2nd ed. 1992, New York: Cambridge University Press.

21. Welsch, G. and R. Boyer, Materials Properites Handbook: Titanium. 1994, Materials Park: ASM Internation.

22. Smit, J., Magnetic Properties of Materials. 1971, New York: McGraw-Hill. 344.

23. Berkow, R., M. Beers, and A. Fletcher, The Merck Manual of Medical Information. 2nd ed. 1997, Whitehouse Station: Merck Research Laboratories.

24. Malmivuo, J. and R. Plonsey, Bioelectromagnetism. 1995, New York: Oxford University Press.

25. Heymsfield, S.B., et al., Anthropometric measurement of muscle mass: revised equations for calculating bone-free arm muscle area. Am J Clin Nutr, 1982. 36(4): p. 680-90.

26. Lenz, J., A review of magnetic sensors. Proceedings of the IEEE, 1990. 78: p. 973-989.

27. A3515 Ratiometric Linear Hall Effect Sensors, in Allegro Microsystems, A. Microsystems, Editor. 2008: Worcestor.

28. Hall, E., On a new action of the magnet on electric currents. American Journal of Math, 1879. 2: p. 287.

29. Nahlik, D., Development of osseo-magnetic link for intuitive rotational control of upper limb prosthesis MS Thesis Biomedical Engineering. June 2009, Northwestern University: Evanston.

Page 78: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

78

Appendix A

Look-Through Table Parameters

𝐸𝐸𝑇𝑇:

𝑀𝑀𝑥𝑥 = [−0.02: 0.0025: 0.02], 𝑀𝑀𝑦𝑦 = [−0.03: 0.0025: 0.03]

𝑀𝑀𝑧𝑧 = [−0.03: 0.0025: 0.03], 𝛽𝛽𝑥𝑥 = �0:𝜋𝜋

30: 2𝜋𝜋 −

𝜋𝜋30�

Gradient Descent Parameters

Algorithm Coefficients:

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼∇𝐸𝐸(𝒙𝒙𝑘𝑘) + 𝛾𝛾(𝒙𝒙𝑘𝑘 − 𝒙𝒙𝑘𝑘−1)

𝛼𝛼 = 3.5 ∙ 10−8 𝛾𝛾 = 0.1

Finite-Difference Step:

∆ = 5 ∙ 10−7

Stopping Criteria:

𝜀𝜀 = 10−4 𝜏𝜏 = 50

Newton Parameters

Algorithm Coefficients:

𝒙𝒙𝑘𝑘+1 = 𝒙𝒙𝑘𝑘 − 𝛼𝛼∇𝐸𝐸(𝒙𝒙𝑘𝑘) ∙ 𝑯𝑯−1

𝛼𝛼 = 0.85

Finite-Difference Step:

∆ = 10−5

Stopping Criteria:

𝜀𝜀 = 10−4 𝜏𝜏 = 50

Page 79: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

79

Appendix B

Lissajous Trajectory Equations The Lissajous trajectory in 4 dimensions arises from the following equations:

𝑀𝑀𝑥𝑥 = 𝐺𝐺𝑥𝑥 ∙ sin(0.2 ∙ 𝐽𝐽)

𝑀𝑀𝑦𝑦 = 𝐺𝐺𝑦𝑦 ∙ sin(0.4 ∙ 𝐽𝐽)

𝑀𝑀𝑧𝑧 = 𝐺𝐺𝑧𝑧 ∙ sin(0.3 ∙ 𝐽𝐽)

𝛽𝛽𝑥𝑥 =𝜋𝜋2

+ 𝐺𝐺𝛽𝛽 ∙ sin(0.1 ∙ 𝐽𝐽)

Where 𝐽𝐽 is a running index that is dictated by the resolution number specified.

𝐽𝐽 =𝑝𝑝

100 ∙ 𝑟𝑟𝑒𝑒𝑤𝑤𝑜𝑜𝑒𝑒𝑚𝑚𝑒𝑒𝑝𝑝𝑜𝑜𝑒𝑒∙ 20𝜋𝜋

And 𝑝𝑝 is a loop iteration index corresponding to one cycle, which is bounded by 1 and 100 ∙ 𝑟𝑟𝑒𝑒𝑤𝑤𝑜𝑜𝑒𝑒𝑚𝑚𝑒𝑒𝑝𝑝𝑜𝑜𝑒𝑒.

The 𝑟𝑟𝑒𝑒𝑤𝑤𝑜𝑜𝑒𝑒𝑚𝑚𝑒𝑒𝑝𝑝𝑜𝑜𝑒𝑒 is an arbitrary number that is varied to lengthen the steps that must be taken by the

algorithms between cycles. 𝐺𝐺𝑥𝑥 , 𝐺𝐺𝑦𝑦 , 𝐺𝐺𝑧𝑧 and 𝐺𝐺𝛽𝛽 represent the maximum values the position and

orientation are permitted to take, with the exception of 𝛽𝛽𝑥𝑥 , which is bounded by 𝜋𝜋2

± 𝐺𝐺𝛽𝛽 . The

coefficients within the 𝑤𝑤𝑝𝑝𝑒𝑒 term dictate the complexity of the path. For example, 0.1 represents a ‘figure

eight’ whereas 0.4 represents a much more complex shape. Some examples are shown in Figure 33,

with 𝐺𝐺𝑥𝑥 , 𝐺𝐺𝑦𝑦 , 𝐺𝐺𝑧𝑧 and 𝐺𝐺𝛽𝛽 all set to 1. It can be seen that as the coefficients become larger, the trajectory

becomes more complex, as the frequency of the 𝑤𝑤𝑝𝑝𝑒𝑒 function increases.

Page 80: NORTHWESTERN UNIVERSITY A DISSERTATION ... - Elliott J Rouse

Algorithm development for sensing the position and orientation of a magnet within residual bone

80

Figure 33: Examples of Lissajous trajectories for varying coefficients