Patent Publication Number: US-10328267-B2

Title: Methods for constructing posture calibration matrices

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application claims the benefit of U.S. Provisional Application No. 61/304,649, filed on Feb. 15, 2010, under 35 U.S.C. § 119(e), which is incorporated herein by reference in its entirety. 
    
    
     BACKGROUND 
     Medical devices include devices designed to be implanted into a patient. Some examples of these implantable medical devices (IMDs) include cardiac function management (CFM) devices such as implantable pacemakers, implantable cardioverter defibrillators (ICDs), cardiac resynchronization therapy devices (CRTs), and devices that include a combination of such capabilities. The devices can be used to treat patients or subjects using electrical or other therapy or to aid a physician or caregiver in patient diagnosis through internal monitoring of a patient&#39;s condition. The devices may include one or more electrodes in communication with one or more sense amplifiers to monitor electrical heart activity within a patient, and often include one or more sensors to monitor one or more other internal patient parameters. Other examples of IMDs include implantable diagnostic devices, implantable drug delivery systems, or implantable devices with neural stimulation capability. 
     Medical devices also include wearable medical devices (WMDs) such as wearable cardioverter defibrillators (WCDs). WCDs are monitors that include surface electrodes. The surface electrodes are arranged to provide one or both of monitoring surface electrocardiograms (ECGs) and delivering cardioverter and defibrillator shock therapy. 
     Some IMDs include one or more sensors to monitor different physiologic aspects of the patient. Sensing of patient posture can provide information related to a patient&#39;s condition or disease. For example, a patient with congestive heart failure (CHF) may tend to sleep in an upward position as their condition worsens. Patient posture information may also be useful in other aspects of patient monitoring. For example, measurements taken by a medical device may vary with patient posture. Knowledge of the posture of the patient during the measurements may be useful to a caregiver in interpreting the device measurements. 
     OVERVIEW 
     This document relates generally to systems, devices, and methods for determining posture in a patient or subject. In particular it relates to, systems, devices, and methods that calibrate a posture sensing device for varying orientation that results from mounting or implanting the posture sensing device. 
     Example 1 can include a device that comprises a multi-dimensional posture sensor configured to provide an electrical sensor output representative of alignment of respective first, second, and third non-parallel axes of the device with the gravitational field of the earth, a processor that includes a calibration circuit and a posture circuit. The calibration circuit can be configured to measure a first sensor output for the first device axis and a second sensor output for one of the second or third device axes while the subject is in a first specified posture, measure sensor outputs for the first, second, and third device axes while the subject is in a second specified posture, calculate one or more coordinate transformations using a sensor output from the first specified posture, transform the sensor outputs for the second posture using the coordinate transformations, and calibrate the posture sensor by calculating a calibration transformation using the first and second sensor outputs and the transformed sensor outputs. The posture circuit can be configured to determine a subsequent posture of the subject using the posture sensor. 
     In Example 2, the subject matter of Example 1 can optionally include the calibration circuit being configured to calculate a first coordinate transformation associated with a first orientation angle using the first sensor output, calculate a second coordinate transformation associated with a second orientation angle using the first sensor output and the second sensor output, measure third, fourth, and fifth sensor outputs for respective first, second, and third device axes while the subject is in the second specified posture, and transform the third, fourth, and fifth sensor outputs using the first and second coordinate transformations. 
     In Example 3, the subject matter of any one of Examples 1-2 can optionally include the calibration circuit being configured to calculate elements of a first rotation matrix using the first sensor output, calculate elements of a second rotation matrix using the first sensor output and the second sensor output, and multiply the third, fourth, and fifth sensor outputs by the first and second rotation matrices to transform the sensor outputs. 
     In Example 4, the subject matter of any one of Examples 1-3 can optionally include the calibration circuit being configured to calculate a calibration transformation by calculating elements of a calibration matrix. 
     In Example 5, the subject matter of any one of Examples 1-4 can optionally include the calibration circuit being configured to calculate a first set of matrix components related to a first orientation angle using the first sensor output, calculate a second set of matrix components related to a second orientation angle using the first sensor output and one of the second sensor output or the third sensor output, calculate a third set of matrix components related to a third orientation angle using the transformed sensor outputs, and calculate the elements of the calibration matrix using the first, second, and third sets of matrix components. 
     In Example 6, the subject matter of any one of Examples 1-5 can optionally include the calibration circuit being configured to calculate the first set of matrix components related to a first orientation angle associated with a pitch angle, calculate a second set of matrix components related to a second orientation angle associated with a roll angle, and calculate a third set of matrix components related to a third orientation angle associated with a yaw angle. 
     In Example 7, the subject matter of any one of Examples 1-6 can optionally include the calibration circuit being configured to calculate the first set of matrix components related to a first orientation angle associated with a pitch angle, calculate a second set of matrix components related to a second orientation angle associated with a roll angle, and calculate a third set of matrix components related to a third orientation angle associated with a roll angle. 
     In Example 8, the subject matter of any one of claims  1 - 7  can optionally include the posture circuit being configured to receive a sensor output for each of the three non-parallel axes of the posture sensor, transform the sensor outputs using the calibration transformation, and compare the transformed sensor outputs to specified thresholds to determine posture of the subject. 
     In Example 9, the subject matter of any one of Examples 1-8 can optionally include the second posture being a posture non-orthogonal to the first posture. 
     In Example 10, the subject matter of any one of Examples 1-9 can optionally include the first posture being an upright posture, and the second posture being optionally more supine than the first posture and less than fully supine. 
     In Example 11, the subject matter of any one of Examples 1-10 can optionally include the first posture being a supine posture, and the second posture being optionally more upright than the first posture and less than fully upright. 
     Example 12 can include, or can be combined with the subject matter of any one of Examples 1-10 to optionally include, subject matter that can comprise measuring a first sensor output for the first device axis and a second sensor output for one of the second or third device axes while the subject is in a first specified posture, measuring sensor outputs for the first, second and third device axes while the subject is in a second specified posture, calculating one or more coordinate transformations using a sensor output from the first specified posture, transforming the sensor outputs using the coordinate transformations, and calibrating the posture sensor by calculating a calibration transformation using the first and second sensor outputs and the transformed sensor outputs. The calibration can be used to determine subsequent subject posture from subsequent sensor output. 
     In Example 13, the subject matter of any one of Examples 1-12 can optionally include calculating one or more coordinate transformations using a sensor output from the first specified posture, which can optionally include calculating, using the first sensor output, a first coordinate transformation associated with a first orientation angle, calculating, using the first sensor output and the second sensor output, a second coordinate transformation associated with a second orientation angle, wherein measuring sensor outputs for the first, second and third device axes includes measuring third, fourth, and fifth sensor outputs for respective first, second and third device axes while the subject is in the second specified posture, and wherein transforming outputs includes transforming the third, fourth, and fifth sensor outputs using the first and second coordinate transformations. 
     In Example 14, the subject matter of any one of Examples 1-13 can optionally include calculating the first coordinate transformation including calculating elements of a first rotation matrix using the first sensor output, the calculating the second coordinate transformation optionally includes calculating elements of a second rotation matrix using the first sensor output and the second sensor output, and the transforming the third, fourth, and fifth sensor outputs optionally includes multiplying the third, fourth, and fifth sensor outputs by the first and second rotation matrices to transform the sensor outputs. 
     In Example 15, the subject matter of any one of Examples 1-14 can optionally include calculating a calibration transformation including calculating elements of a calibration matrix, and the using the calibration to determine subsequent subject posture optionally includes using the calibration matrix to determine subsequent subject posture from subsequent sensor output. 
     In Example 16, the subject matter of any one of Examples 1-15 can optionally include calculating elements of a matrix to calibrate the posture sensor using sensor outputs, including calculating a first set of matrix components related to a first orientation angle using the first sensor output, calculating a second set of matrix components related to a second orientation angle using the first sensor output and the second sensor output, calculating a third set of matrix components related to a third orientation angle using the transformed sensor outputs, and calculating the elements of the calibration matrix using the first, second, and third sets of matrix components. 
     In Example 17, the subject matter of any one of Examples 1-16 can optionally include calculating a first set of matrix components related to a first orientation angle, including calculating a first set of matrix components associated with a pitch angle, the calculating a second set of matrix components related to a second orientation angle optionally includes calculating a second set of matrix components associated with a roll angle, and the calculating a third set of matrix components related to a third orientation angle optionally includes calculating a second set of matrix components associated with a yaw angle. 
     In Example 18, the subject matter of any one of Examples 1-17 can optionally include calculating a first set of matrix components related to a first orientation angle, optionally including calculating a first set of matrix components associated with a pitch angle, the calculating a second set of matrix components related to a second orientation angle includes calculating a second set of matrix components associated with a yaw angle, and the calculating a third set of matrix components related to a third orientation angle includes calculating a second set of matrix components associated with a roll angle. 
     In Example 19, the subject matter of any one of Examples 1-18 can optionally include measuring while the subject is in a second specified posture, optionally including measuring while the subject is in a second specified posture that is non-orthogonal to the first specified posture. 
     In Example 20, the subject matter of any one of Examples 1-19 can optionally include using the calibration to determine subsequent subject posture, optionally including receiving a sensor output for each of three orthogonal axes of the multi-dimensional sensor, transforming the sensor outputs to body coordinate values using the calibration transformation, and comparing the sensor outputs to specified thresholds to determine the posture. 
     This section is intended to provide an overview of subject matter of the present patent application. It is not intended to provide an exclusive or exhaustive explanation of the invention. The detailed description is included to provide further information about the present patent application. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       In the drawings, which are not necessarily drawn to scale, like numerals may describe similar components in different views. Like numerals having different letter suffixes may represent different instances of similar components. The drawings illustrate generally, by way of example, but not by way of limitation, the various examples discussed in the present document. 
         FIG. 1  is an illustration of an example of portions of a system that includes an IMD. 
         FIG. 2  is an illustration of portions of another system that uses an IMD. 
         FIGS. 3A and 3B  illustrate a coordinate system for a patient&#39;s body. 
         FIG. 4  illustrates device coordinates that are skewed from the body coordinates. 
         FIG. 5  illustrates the Tait-Bryan yaw, pitch, and roll angles and how they can be used to describe device coordinate to body coordinate rotations. 
         FIG. 6  is a flow diagram of a method of determining a calibration matrix for a multi-dimensional posture sensor. 
         FIG. 7  graphically illustrates a component of the g force that is in the (x′, y′) plane to visualize transforming from device coordinates toward body coordinates. 
         FIG. 8  graphically illustrates a component of the g force that is in the (y′, z′) plane to visualize transforming from device coordinates toward body coordinates. 
         FIG. 9  is a flow diagram of another method of determining a calibration matrix for a multi-dimensional posture sensor. 
         FIG. 10  is a block diagram of an example of portions of a device capable of determining a calibration matrix for a multi-dimensional posture sensor. 
     
    
    
     DETAILED DESCRIPTION 
     A medical device (e.g., an IMD or WMD) can include one or more of the features, structures, methods, or combinations thereof described herein. For example, a cardiac monitor or a cardiac stimulator can be implemented to include one or more of the advantageous features or processes described below. It is intended that such a monitor, stimulator, or other implantable or partially implantable device need not include all of the features described herein, but can be implemented to include selected features that provide for unique structures or functionality. Such a device can be implemented to provide a variety of therapeutic or diagnostic functions. 
     Posture sensing with a medical device can improve patient monitoring. Examples of a posture sensor include a multi-axis accelerometer and a tilt switch. With a posture sensor, a medical device can detect whether a patient is in an upright position, a supine position, a prone position, on his or her left or right side, or if the patient is in a tilted position. For patients with heart failure, posture sensing allows monitoring of orthopnea; a condition where the patient can breathe easily only when in an upright posture (e.g., standing or sitting with the torso upright). Posture sensing also allows monitoring of Paroxysmal Nocturnal Dyspnea (PND); a condition including labored or difficult breathing that awakens patients from sleep. 
     Posture sensing can also improve the use of other sensors used to monitor a patient&#39;s cardiac activity. For example, heart sounds are associated with mechanical activity of a patient&#39;s heart. The amplitude of heart sounds can vary with patient posture as well as cardiac disease. Knowledge of patient posture can improve monitoring of patient heart sounds. In another example, pulmonary arterial (PA) pressure is useful to monitor a patient&#39;s cardiac disease, but varies with patient posture. Patient posture information can improve monitoring of PA pressure by determining whether PA pressure variation is due to posture or to disease. 
     Orientation of a medical device can vary from patient to patient. This complicates the automatic determination of patient posture by the medical device. For instance, for an implantable device the orientation of the IMD in the body is unknown. Because physiology varies among patients, a pacemaker can have a different orientation from patient to patient due to differences in angles of the chest of the patients. Also, an IMD can undergo some rotation or other migration over the life of the device. Calibration of the posture sensor compensates for the unknown angle of an IMD in a body or for a changing angle of a WMD. 
       FIG. 1  is an illustration of portions of a system  100  that uses an IMD  110  or other ambulatory medical device. Examples of IMD  110  include, without limitation, a pacer, a defibrillator, a cardiac resynchronization therapy (CRT) device, or a combination of such devices. The system  100  also typically includes an IMD programmer or other external device  170  that communicates wireless signals  190  with the IMD  110 , such as by using radio frequency (RF) or other telemetry signals. 
     The IMD  110  is coupled by one or more leads  108 A-C to heart  110 . Cardiac leads  108 A-C include a proximal end that is coupled to IMD  110  and a distal end, coupled by electrical contacts or “electrodes” to one or more portions of a heart  105 . The electrodes typically deliver cardioversion, defibrillation, pacing, or resynchronization therapy, or combinations thereof to at least one chamber of the heart  105 . The electrodes can be electrically coupled to sense amplifiers to sense electrical cardiac signals. 
     Heart  105  includes a right atrium  100 A, a left atrium  100 B, a right ventricle  105 A, a left ventricle  105 B, and a coronary sinus  120  extending from right atrium  100 A. Right atrial (RA) lead  108 A includes electrodes (electrical contacts, such as ring electrode  125  and tip electrode  130 ) disposed in an atrium  100 A of heart  105  for sensing signals, or delivering pacing therapy, or both, to the atrium  100 A. 
     Right ventricular (RV) lead  108 B includes one or more electrodes, such as tip electrode  135  and ring electrode  140 , for sensing signals, delivering pacing therapy, or both sensing signals and delivering pacing therapy. Lead  108 B optionally also includes additional electrodes, such as for delivering atrial cardioversion, atrial defibrillation, ventricular cardioversion, ventricular defibrillation, or combinations thereof to heart  105 . Such electrodes typically have larger surface areas than pacing electrodes in order to handle the larger energies involved in defibrillation. Lead  108 B optionally provides resynchronization therapy to the heart  105 . Resynchronization therapy is typically delivered to the ventricles in order to better synchronize the timing of depolarizations between ventricles. 
     The IMD  110  can include a third cardiac lead  108 C attached to the IMD  110  through the header  155 . The third cardiac lead  108 C includes ring electrodes  160  and  165  placed in a coronary vein lying epicardially on the left ventricle (LV)  105 B via the coronary vein. The third cardiac lead  108 C can include a ring electrode  185  positioned near the coronary sinus (CS)  120 . 
     Lead  108 B can include a first defibrillation coil electrode  175  located proximal to tip and ring electrodes  135 ,  140  for placement in a right ventricle, and a second defibrillation coil electrode  180  located proximal to the first defibrillation coil  175 , tip electrode  135 , and ring electrode  140  for placement in the superior vena cava (SVC). In some examples, high-energy shock therapy is delivered from the first or RV coil  175  to the second or SVC coil  180 . In some examples, the SVC coil  180  is electrically tied to an electrode formed on the hermetically-sealed IMD housing or can  150 . This improves defibrillation by delivering current from the RV coil  175  more uniformly over the ventricular myocardium. In some examples, the therapy is delivered from the RV coil  175  only to the electrode formed on the IMD can  150 . 
     Note that although a specific arrangement of leads and electrodes are shown the illustration, the present methods and systems will work in a variety of configurations and with a variety of electrodes. Other forms of electrodes include meshes and patches which can be applied to portions of heart  105  or which can be implanted in other areas of the body to help “steer” electrical currents produced by IMD  110 . 
     An IMD can be configured with a variety of electrode arrangements, including transvenous, endocardial, and epicardial electrodes (i.e., intrathoracic electrodes), and/or subcutaneous, non-intrathoracic electrodes, including can, header, and indifferent electrodes, and subcutaneous array or lead electrodes (i.e., non-intrathoracic electrodes). 
       FIG. 2  is an illustration of portions of another system  200  that uses an IMD  210  to provide a therapy to a patient  202 . The system  200  typically includes an external device  270  that communicates with a remote system  296  via a network  294 . The network  294  can be a communication network such as a phone network or a computer network (e.g., the internet). In some examples, the external device includes a repeater and communicated via the network using a link  292  that can be wired or wireless. In some examples, the remote system  296  provides patient management functions and can include one or more servers  298  to perform the functions. 
       FIG. 3  shows a coordinate system for a patient&#39;s body. The body coordinate system uses the x, y, and z axes to describe the posterior to anterior direction, left to right direction, and inferior to superior direction respectively.  FIG. 3  also shows a device coordinate system using u, v, and w axes as shown. A desirable orientation of the device  300  can be in the coronal plane such that the device axes match the body axes (e.g., u↔x, v↔y, w↔z). However, a device orientation is not typically in an ideal orientation. 
       FIG. 4  shows the more typical case in which the device coordinates are skewed from the body coordinates. As discussed previously, this can be due to patient anatomy or due to movement of the implanted or worn medical device  400 . A calibration procedure is used to determine the device orientation or to translate the device coordinates to body coordinates so that algorithms run by the medical device that use posture sensing can correct for the device orientation. 
     The calibration procedure involves determining the elements of a calibration matrix. Once the calibration matrix is determined, algorithms of the medical device can determine the posture of the patient such as by multiplying the output or outputs of the posture sensor by the calibration matrix to generate outputs calibrated to body coordinates. The calibrated outputs can be compared to specified thresholds to determine the posture. 
     In some examples, a three-dimensional DC accelerometer is used for the posture sensor. The accelerometer provides a DC-responsive output for each of three mutually orthogonal axes. To determine the elements of the calibration matrix, a coordinate rotation is performed. The Tait-Bryan angles can be used to define an arbitrary coordinate rotation. 
     Coordinate Transformation 
       FIG. 5  shows the Tait-Bryan angles yaw, pitch, and roll and how they can be used to describe device coordinate to body coordinate rotations or transformations, such as for a pectorally implanted CFM device. The arbitrary coordinate rotation of the device on the body can be determined by three consecutive rotations. The first rotation can be about the inferior-superior (z) body axis or the vertical axis when the patient is upright. In  FIG. 5  it can be seen that this angle can be the yaw angle, denoted as θ 7 . 
     If the device is mounted on the body with yaw angle θ y , any vector a originally expressed in body coordinates can be expressed in the rotated coordinate system as: 
                       a   ′     =       [           a   x   ′               a   y   ′               a   z   ′           ]     =       [           cos   ⁡     (     θ   y     )             -     sin   ⁡     (     θ   y     )             0             sin   ⁡     (     θ   y     )             cos   ⁡     (     θ   y     )           0           0       0       1         ]     ⁡     [           a   x               a   y               a   z           ]           ,           (   1   )               
where a′ represents the vector expressed in the coordinate system rotated through angle θ y  about the z axis.
 
     This first rotation results in a new rotated y axis y′. The second rotation is about this y′ axis, through an angle θ p  that can be referred to as the pitch angle: 
                           a   ″     =       ⁢     [           a   x   ″               a   y   ″               a     z   ⁢             ″           ]                 =       ⁢       [           cos   ⁡     (     θ   p     )           0         sin   ⁡     (     θ   p     )               0       1       0             -     sin   ⁡     (     θ   p     )             0         cos   ⁡     (     θ   p     )             ]     ⁡     [           a   x   ′               a   y   ′               a   z   ′           ]                   =       ⁢         [           cos   ⁡     (     θ   p     )           0         -     sin   ⁡     (     θ   p     )                 0       1       0             sin   ⁡     (     θ   p     )           0         cos   ⁡     (     θ   p     )             ]     ⁡     [           cos   ⁡     (     θ   y     )             -     sin   ⁡     (     θ   y     )             0             sin   ⁡     (     θ   y     )             cos   ⁡     (     θ   y     )           0           0       0       1         ]       ⁡     [           a   x               a   y               a   z           ]                     (   2   )               
where a″ represents the vector expressed in the coordinate system rotated through angle θ y  about the z axis and then rotated through θ p  about the y′ axis.
 
     These two rotations result in a new rotated x axis x″. The third rotation is about this x″ axis, through an angle θ r  that can be referred to as the roll angle: 
                           [           a   x   ′′′               a   y   ′′′               a   z   ′′′           ]     =       ⁢       [         1       0       0           0         cos   ⁡     (     θ   r     )             sin   ⁡     (     θ   r     )               0         -     sin   ⁡     (     θ   r     )               cos   ⁡     (     θ   r     )             ]     ⁡     [           a   x   ″               a   y   ″               a     z   ⁢             ″           ]                   =       ⁢       [         1       0       0           0         cos   ⁡     (     θ   r     )             sin   ⁡     (     θ   r     )               0         -     sin   ⁡     (     θ   r     )               cos   ⁡     (     θ   r     )             ]     ⁡     [           cos   ⁡     (     θ   p     )           0         sin   ⁡     (     θ   p     )               0       1       0             -     sin   ⁡     (     θ   p     )             0         cos   ⁡     (     θ   p     )             ]                       ⁢         [           cos   ⁡     (     θ   y     )             -     sin   ⁡     (     θ   y     )             0             sin   ⁡     (     θ   y     )             cos   ⁡     (     θ   y     )           0           0       0       1         ]     ⁡     [           a   x               a   y               a     z   ⁢                     ]       ,                   (   3   )               
where a′″ represents the vector expressed in the coordinate system rotated through angle θ y  about the z axis, rotated through θ p  about the y′ axis, and then rotated through angle θ r , about the x″ axis. The matrix on the right side of the equal sign can be multiplied out to yield:
 
                     [           a   u               a   v                 a   w     ⁢                   ]     =       [           a   x   ′′′               a   y   ′′′               a     z   ⁢             ′′′           ]     =             [             cos   ⁡     (     θ   p     )       ⁢     cos   ⁡     (     θ   y     )                 -     cos   ⁡     (     θ   p     )         ⁢     sin   ⁡     (     θ   y     )               sin   (     θ   p     ⁢           )                         cos   ⁡     (     θ   r     )       ⁢     sin   ⁡     (     θ   y     )         -                 sin   ⁡     (     θ   r     )       ⁢     sin   ⁡     (     θ   p     )       ⁢     cos   ⁡     (     θ   y     )                               cos   ⁡     (     θ   r     )       ⁢     cos   ⁡     (     θ   y     )         +                 sin   ⁡     (     θ   r     )       ⁢     sin   ⁡     (     θ   p     )       ⁢     sin   ⁡     (     θ   y     )                       sin   ⁡     (     θ   r     )       ⁢     cos   ⁡     (     θ   p     )                             -     sin   ⁡     (     θ   r     )         ⁢     sin   ⁡     (     θ   y     )         -                 cos   (     θ   r     ⁢           )     ⁢     sin   ⁡     (     θ   p     )       ⁢     cos   ⁡     (     θ   y     )                               -     sin   ⁡     (     θ   r     )         ⁢     cos   ⁡     (     θ   y     )         +                 cos   ⁡     (     θ   r     )       ⁢     sin   ⁡     (     θ   p     )       ⁢     sin   ⁡     (     θ   y     )                       cos   ⁡     (     θ   r     )       ⁢     cos   ⁡     (     θ   p     )               ]     ⁢             [           a   x               a   y               a   z           ]     ,     
     ⁢   or                     (   4   )                   [           a   u               a   v               a   w           ]     =     M   ⁡     [           a   x               a   y               a   z           ]         ,           (   5   )               
where a T =[a u  a v  a w ] T  is the vector a expressed in the rotated coordinate system of the device.
 
     Equation (4) can be used to calculate elements of the calibration matrix M for the posture sensor of the medical device. To determine the calibration matrix, a two posture manual calibration is performed. Additional postures (e.g., three) can be used, but two postures are sufficient. The subject assumes the first known posture and sensor data (e.g., acceleration data) is collected from the device which is mounted (e.g., implanted or worn) on the body. The subject then assumes a second posture and sensor data is collected while the subject is in the second posture. Calculations performed by the medical device on the sensor data collected from the two postures can be used to specify and correct for the orientation of the device in or on the body. These calculations need not involve trigonometric calculations. Non-trigonometric calculations can be useful on a device where processor power to perform the calculations is limited, or for a device where energy to perform processor calculations is limited (e.g., a battery powered device). 
     To construct the calibration matrix, a combination of direct insertion of sensor data and knowledge of the form of the calibration rotation matrix is used. A first sensor output for a first device axis is measured while the subject is in a first specified posture. In some examples, an upright posture is used and data [a u  a v  a w ] T  is collected from the mounted device. For the upright posture, the gravity vector in body coordinates is [a u  a v  a w ] T =[0 0 1] T . The matrix equation for this situation is: 
     
       
         
           
             
               
                 
                   
                     
                       [ 
                       
                         
                           
                             
                               a 
                               u 
                             
                           
                         
                         
                           
                             
                               a 
                               v 
                             
                           
                         
                         
                           
                             
                               a 
                               w 
                             
                           
                         
                       
                       ] 
                     
                     Upright 
                   
                   = 
                   
                       
                     
                       
                         [ 
                         
                           
                             
                               
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       p 
                                     
                                     ) 
                                   
                                 
                                 ⁢ 
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       y 
                                     
                                     ) 
                                   
                                 
                               
                             
                             
                               
                                 
                                   - 
                                   
                                     cos 
                                     ⁡ 
                                     
                                       ( 
                                       
                                         θ 
                                         p 
                                       
                                       ) 
                                     
                                   
                                 
                                 ⁢ 
                                 
                                   sin 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       y 
                                     
                                     ) 
                                   
                                 
                               
                             
                             
                               
                                 sin 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     θ 
                                     p 
                                   
                                   ) 
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     
                                       
                                         
                                           - 
                                           
                                             cos 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 r 
                                               
                                               ) 
                                             
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               y 
                                             
                                             ) 
                                           
                                         
                                       
                                       - 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             r 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             p 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             y 
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     
                                       
                                         cos 
                                         ⁢ 
                                         
                                           ( 
                                           
                                             θ 
                                             r 
                                           
                                           ) 
                                         
                                         ⁢ 
                                         
                                           cos 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               y 
                                             
                                             ) 
                                           
                                         
                                       
                                       + 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             r 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             p 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             y 
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   sin 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       r 
                                     
                                     ) 
                                   
                                 
                                 ⁢ 
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       p 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     
                                       
                                         
                                           - 
                                           
                                             sin 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 r 
                                               
                                               ) 
                                             
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               y 
                                             
                                             ) 
                                           
                                         
                                       
                                       - 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             r 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             p 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             y 
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     
                                       
                                         
                                           - 
                                           
                                             sin 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 r 
                                               
                                               ) 
                                             
                                           
                                         
                                         ⁢ 
                                         
                                           cos 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               y 
                                             
                                             ) 
                                           
                                         
                                       
                                       + 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         cos 
                                         ( 
                                         
                                           θ 
                                           r 
                                         
                                         ⁢ 
                                         
                                             
                                         
                                         ) 
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             p 
                                           
                                           ) 
                                         
                                       
                                       ⁢ 
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             y 
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       r 
                                     
                                     ) 
                                   
                                 
                                 ⁢ 
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       p 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                         ] 
                       
                       ⁢ 
                       
                           
                         
                           
                             [ 
                             
                               
                                 
                                   0 
                                 
                               
                               
                                 
                                   0 
                                 
                               
                               
                                 
                                   1 
                                 
                               
                             
                             ] 
                           
                           , 
                           
                             
 
                           
                           ⁢ 
                           or 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       [ 
                       
                         
                           
                             
                               a 
                               u 
                             
                           
                         
                         
                           
                             
                               a 
                               v 
                             
                           
                         
                         
                           
                             
                               a 
                               w 
                             
                           
                         
                       
                       ] 
                     
                     Upright 
                   
                   = 
                   
                     
                       [ 
                       
                         
                           
                             
                               sin 
                               ⁡ 
                               
                                 ( 
                                 
                                   θ 
                                   p 
                                 
                                 ) 
                               
                             
                           
                         
                         
                           
                             
                               
                                 sin 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     θ 
                                     r 
                                   
                                   ) 
                                 
                               
                               ⁢ 
                               
                                 cos 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     θ 
                                     p 
                                   
                                   ) 
                                 
                               
                             
                           
                         
                         
                           
                             
                               
                                 cos 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     θ 
                                     r 
                                   
                                   ) 
                                 
                               
                               ⁢ 
                               
                                 cos 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     θ 
                                     p 
                                   
                                   ) 
                                 
                               
                             
                           
                         
                       
                       ] 
                     
                     . 
                   
                 
               
               
                 
                   ( 
                   7 
                   ) 
                 
               
             
           
         
       
     
     If the components of the rotation matrix, M, are denoted as follows, 
                     M   =     [           m   11           m   12           m   13               m   21           m   22           m   23               m   31           m   32           m   33           ]       ,           (   8   )               
then by inspection, m 13 =a u,Upright. , m 23 =a v,Upright. , m 33 =a w,Upright. , where a u,Upright  refers to the sensor output from the “u” device axis when the patient is in the upright position.
 
Pitch Angle (P) Coefficients
 
     To calculate the calibration matrix elements associated with the pitch angle, it can be seen from the form of the matrix that m 13 =a u,Upright =sin(θ p ). The term a u, Upright  can be measured directly by the sensor with the patient in the Upright posture. If sin(θ p )=a u,Upright , then using the trigonometric identity cos(θ p )=±√{square root over (1−sin 2 (θ p ))}, cos(θ p ) can be computed from the measured quantities cos(θ p )=±√{square root over (1−a u,Upright   2 )}. 
     Roll Angle (R) Coefficients 
     This expression for cos(θ p ) can be used to calculate the calibration matrix elements associated with the roll angle. Two separate equations can be used to characterize the roll rotation: sin(θ r )=a v,Upright /±√{square root over (1−a u,Upright   2 )}, and cos(θ r )=a w,Upright /±±√{square root over (1−a u,Upright   2 )}. Either of the equations can be used to calculate the roll rotation matrix components. However, due to one or both of inaccuracies in the patient maneuver and noise in the measurements during the maneuver, the results may not be identical in practice. Either of these equations can be used, or both of these equations can be used, to calculate the roll rotation matrix components to enhance the accuracy of the results. 
     To simplify the description, the notation for cosine and sine in the matrix above can be changed to: 
                         [           a   u               a   v               a   w           ]     Upright     =       [             c   p     ⁢     c   y               -     c     p   ⁢                 ⁢     s   y             s   p                   c   r     ⁢     s   y       -       s   r     ⁢     s   p     ⁢     c   y                   c   r     ⁢     c   y       +       s   r     ⁢     s   p     ⁢     s   y                 s   r     ⁢     c   p                     -     s   r       ⁢     s   y       -       c   r     ⁢     s   p     ⁢     c   y                   -     s   r       ⁢     c   y       +       c   r     ⁢     s   p     ⁢     s   y                 c   r     ⁢     c   p             ]     ⁡     [         0           0           1         ]         ,           (   9   )               
where, e.g., cos(θ p ) is equal to c p . It can be seen that the nine components of the matrix are composed of the six coefficients s r , c r , s p , c p , and s y , c y . The “s” and “c” coefficients or matrix components are also related to one another as discussed previously.
 
     The only trigonometric relationships needed are s i =±√{square root over (1−c i   2 )}, and c i =±√{square root over (1−s i   2 )}, for i∈(y, p, r), which relate the components of matrix by algebraic equations. Thus, whenever we know a “c” term, we also know (within a sign ambiguity) the corresponding “s” term and vice-versa using algebraic expressions, and there is no need for trigonometric functions to compute the components of the matrix. Specifically, the equations are
 
 s   p   =a   u,Upright  
 
 c   p =±√{square root over (1 −s   p   2 )}
 
 s   ra   =a   v,Upright   /c   p   , c   ra =±√{square root over (1− s   ra   2 )},
 
 c   rb   =a   w,Upright   /c   p   , s   rb =±√{square root over (1− c   rb   2 )},  (10)
 
where the additional “a” and “b” in the subscripts denote that these are two alternative sets of calculations that, as noted previously, may give different results in practice. Either the set “a” or the set “b” equations can be used. Note that s r , c r  should be calculated from the same set of equations so that s r  and c r  are calculated from complementary angles. This ensures that the rotation matrix is unitary (i.e., its inverse is equal to its transpose). Thus, by knowing a u,Upright  and a v,Upright , or knowing a u,Upright  and a w,Upright , four of the six coefficients can be calculated.
 
Yaw Angle (Y) Coefficients
 
     Remaining to be computed are the two coefficients related to the yaw rotation, s y  and c y . In some examples, to determine this rotation, the patient assumes a second posture orthogonal to the first. For instance, the first position can be the upright posture and the second posture is the supine posture where the patient lies on his or her back. Similar to the upright posture, the gravity vector in body coordinates for the supine posture is [a u  a v  a w ] T =[1 0 0] T . This leads to the equation: 
     
       
         
           
             
               
                 
                   
                     
                       
                         [ 
                         
                           
                             
                               
                                 a 
                                 u 
                               
                             
                           
                           
                             
                               
                                 a 
                                 v 
                               
                             
                           
                           
                             
                               
                                 a 
                                 w 
                               
                             
                           
                         
                         ] 
                       
                       Supine 
                     
                     = 
                     
                       
                         [ 
                         
                           
                             
                               
                                 
                                   c 
                                   p 
                                 
                                 ⁢ 
                                 
                                   c 
                                   y 
                                 
                               
                             
                             
                               
                                 
                                   - 
                                   
                                     c 
                                     p 
                                   
                                 
                                 ⁢ 
                                 
                                   s 
                                   y 
                                 
                               
                             
                             
                               
                                 s 
                                 p 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     c 
                                     r 
                                   
                                   ⁢ 
                                   
                                     s 
                                     y 
                                   
                                 
                                 - 
                                 
                                   
                                     s 
                                     r 
                                   
                                   ⁢ 
                                   
                                     s 
                                     p 
                                   
                                   ⁢ 
                                   
                                     c 
                                     y 
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     c 
                                     r 
                                   
                                   ⁢ 
                                   
                                     c 
                                     y 
                                   
                                 
                                 + 
                                 
                                   
                                     s 
                                     r 
                                   
                                   ⁢ 
                                   
                                     s 
                                     p 
                                   
                                   ⁢ 
                                   
                                     s 
                                     y 
                                   
                                 
                               
                             
                             
                               
                                 
                                   s 
                                   r 
                                 
                                 ⁢ 
                                 
                                   c 
                                   p 
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     - 
                                     
                                       s 
                                       r 
                                     
                                   
                                   ⁢ 
                                   
                                     s 
                                     y 
                                   
                                 
                                 - 
                                 
                                   
                                     c 
                                     r 
                                   
                                   ⁢ 
                                   
                                     s 
                                     p 
                                   
                                   ⁢ 
                                   
                                     c 
                                     y 
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     - 
                                     
                                       s 
                                       r 
                                     
                                   
                                   ⁢ 
                                   
                                     c 
                                     y 
                                   
                                 
                                 + 
                                 
                                   
                                     c 
                                     r 
                                   
                                   ⁢ 
                                   
                                     s 
                                     p 
                                   
                                   ⁢ 
                                   
                                     s 
                                     
                                       y 
                                       ⁢ 
                                       
                                           
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   c 
                                   r 
                                 
                                 ⁢ 
                                 
                                   c 
                                   p 
                                 
                               
                             
                           
                         
                         ] 
                       
                       ⁡ 
                       
                         [ 
                         
                           
                             
                               1 
                             
                           
                           
                             
                               0 
                             
                           
                           
                             
                               0 
                             
                           
                         
                         ] 
                       
                     
                   
                   , 
                   
                     
 
                   
                   ⁢ 
                   or 
                 
               
               
                 
                   ( 
                   11 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       [ 
                       
                         
                           
                             
                               a 
                               u 
                             
                           
                         
                         
                           
                             
                               a 
                               v 
                             
                           
                         
                         
                           
                             
                               a 
                               w 
                             
                           
                         
                       
                       ] 
                     
                     Supine 
                   
                   = 
                   
                     
                       [ 
                       
                         
                           
                             
                               
                                 c 
                                 p 
                               
                               ⁢ 
                               
                                 c 
                                 y 
                               
                             
                           
                         
                         
                           
                             
                               
                                 
                                   c 
                                   r 
                                 
                                 ⁢ 
                                 
                                   s 
                                   y 
                                 
                               
                               - 
                               
                                 
                                   s 
                                   r 
                                 
                                 ⁢ 
                                 
                                   s 
                                   p 
                                 
                                 ⁢ 
                                 
                                   c 
                                   y 
                                 
                               
                             
                           
                         
                         
                           
                             
                               
                                 
                                   - 
                                   
                                     s 
                                     r 
                                   
                                 
                                 ⁢ 
                                 
                                   s 
                                   y 
                                 
                               
                               - 
                               
                                 
                                   c 
                                   r 
                                 
                                 ⁢ 
                                 
                                   s 
                                   p 
                                 
                                 ⁢ 
                                 
                                   c 
                                   y 
                                 
                               
                             
                           
                         
                       
                       ] 
                     
                     . 
                   
                 
               
               
                 
                   ( 
                   12 
                   ) 
                 
               
             
           
         
       
     
     The simplest set of calculations for the yaw rotation coefficients is c y =a u,Supine /c p , s y =±√{square root over (1−c y   2 )}, which again does not need to be computed using trigonometric functions. Thus, all six of the coefficients can be calculated using the outputs of the posture sensor, and therefore all nine elements of the calibration matrix M can be calculated. Thus, the calibration matrix can be calculated without actually calculating a rotation angle, such as one or more of a yaw, pitch, and roll angle, and can be calculated without calculating a trigonometric function. 
     When the calibration matrix M is calculated, the inverse of the calibration matrix M −1  can be used to translate the posture sensor output in device coordinates to the posture sensor output in body coordinates, such as by 
                       [           a   x               a   y               a   z           ]     =       M     -   1       ⁡     [           a   u               a   v               a     w   ⁢                     ]         ,           (   13   )               
where [a u  a v  a w ] is the output of the posture sensor in device coordinates and [a x  a y  a z ] is the output of the posture sensor in body coordinates.
 
Alternate Coordinate Transformation
 
     The examples of calibrating the device for orientation in or on the body has been described in regard to the patient first assuming an upright position and then assuming a supine position. Other calibration maneuvers can be useful, such as starting with the supine posture or with the patient lying on his or side. Sometimes it can be desirable to begin the calibration maneuvers from the supine posture and finish the calibration with the upright posture. This may be if calibration maneuvers starting from a fully upright posture are difficult to repeat. The maneuvers can be performed in either order. It is the choice of the order of the processing of the two maneuvers that allows choosing which maneuver needs to be fully aligned with gravity (that is, fully upright or fully supine). 
     To start from the supine position, the order of rotations used to calculate the calibration matrix are reversed. Because of the different order of the rotation, the rotation is not in the order of the Tait-Bryan formulation. This results in rotations that do not correspond directly to the roll, pitch, and yaw angles, but the roll, pitch, and yaw angles are still useful for describing the calculations of the elements of the calibration matrix. 
     As before, an arbitrary coordinate rotation of the device on the body can be determined by three consecutive rotations. The first rotation can be about the anterior-posterior (x) body axis. In  FIG. 4  it can be seen that this angle is similar to the roll angle, and is denoted as θ r′ . 
     If the device is mounted on the body with angle, θ r′ , any vector, a, originally expressed in body coordinates can be expressed in the rotated coordinate system as: 
                       a   ′     =       [           a   x   ′               a   y   ′               a   z   ′           ]     =       [         1       0       0           0         cos   ⁡     (     θ     r   ′       )             sin   ⁡     (     θ     r   ′       )               0         -     sin   ⁡     (     θ     r   ′       )               cos   ⁡     (     θ     r   ′       )             ]     ⁡     [           a   x               a   y               a   z           ]           ,           (   14   )               
where a′ represents the vector expressed in the coordinate system rotated through angle θ r′  about the x axis.
 
     This first rotation results in a new rotated y axis y′. The second rotation is about this y′ axis, through an angle θ p′  which for small roll angles is an angle similar to the pitch angle: 
                           a   ′′     =     [           a   x   ′′               a   y   ′′               a   z   ′′           ]                 =       [           cos   ⁡     (     θ     p   ′       )           0         sin   ⁡     (     θ     p   ′       )               0       1       0             -     sin   ⁡     (     θ     p   ′       )             0         cos   ⁡     (     θ     p   ′       )             ]     ⁡     [           a   x   ′               a   y   ′               a   z   ′           ]                   =         [           cos   ⁡     (     θ     p   ′       )           0         sin   ⁡     (     θ     p   ′       )               0       1       0             -     sin   ⁡     (     θ     p   ′       )             0         cos   ⁡     (     θ     p   ′       )             ]     ⁡     [         1       0       0           0         cos   ⁡     (     θ     r   ′       )             sin   ⁡     (     θ     r   ′       )               0         -     sin   ⁡     (     θ     r   ′       )               cos   ⁡     (     θ     r   ′       )             ]       ⁡     [           a   x               a   y               a   z           ]                     (   15   )               
where a″ represents the vector expressed in the coordinate system rotated through angle θ r′  about the x axis and then rotated through θ p′ , about the y′ axis.
 
     These two rotations result in a new rotated z axis z″. The third rotation is about this z″ axis, through an angle θ y′ , which for small roll angles is an angle similar to the yaw angle. 
                           [           a   x   ′′′               a   y   ′′′               a   z   ′′′           ]     =       ⁢       [           cos   ⁡     (     θ     y   ′       )             -     sin   ⁡     (     θ     y   ′       )             0             sin   ⁡     (     θ     y   ′       )             cos   ⁡     (     θ     y   ′       )           0           0       0       1         ]     ⁡     [           a   x   ′′               a   y   ′′               a   z   ′′           ]                   =       ⁢       [           cos   ⁡     (     θ     y   ′       )             -     sin   ⁡     (     θ     y   ′       )             0             sin   ⁡     (     θ     y   ′       )             cos   ⁡     (     θ     y   ′       )           0           0       0       1         ]     ⁡     [           cos   ⁡     (     θ     p   ′       )           0         sin   ⁡     (     θ     p   ′       )               0       1       0             -     sin   ⁡     (     θ     p   ′       )             0         cos   ⁡     (     θ     p   ′       )             ]                       ⁢         [         1       0       0           0         cos   ⁡     (     θ     r   ′       )             sin   ⁡     (     θ     r   ′       )               0         -     sin   ⁡     (     θ     r   ′       )               cos   ⁡     (     θ     r   ′       )             ]     ⁡     [           a   x               a   y               a   z           ]       ,                   (   16   )               
where a′″=[a x ′″ a y ′″ a z ′″] represents the vector expressed in the coordinate system rotated through angle θ′ r′ , about the x axis, rotated through θ p′ , about the y′ axis, and then rotated through angle θ y′  about the z″ axis. The matrix on the right side of the equal sign can be multiplied out to yield:
 
                           [           a   u               a   v               a   w           ]     =       ⁢     [           a   x   ′′′               a   y   ′′′               a   z   ′′′           ]                 =       ⁢     [             cos   ⁡     (     θ     y   ′       )       ⁢     cos   ⁡     (     θ     p   ′       )                         -     sin   ⁡     (     θ     y   ′       )         ⁢     cos   ⁡     (     θ   r     )         -                 cos   ⁡     (     θ     y   ′       )       ⁢     sin   ⁡     (     θ     p   ′       )                   sin   ⁡     (     θ     r   ′       )                             -     sin   ⁡     (     θ     r   ′       )         ⁢     sin   ⁡     (     θ     y   ′       )         +                 cos   ⁡     (     θ     r   ′       )       ⁢     sin   ⁡     (     θ     p   ′       )                   cos   ⁡     (     θ     y   ′       )                         sin   ⁡     (     θ     y   ′       )       ⁢     cos   ⁡     (     θ     p   ′       )                         cos   ⁡     (     θ     r   ′       )       ⁢     cos   ⁡     (     θ   y     )         -                 sin   ⁡     (     θ   r     )       ⁢     sin   ⁡     (     θ     p   ′       )                   sin   ⁡     (     θ     y   ′       )                             sin   ⁡     (     θ     r   ′       )       ⁢     cos   ⁡     (     θ     y   ′       )         +                 sin   ⁡     (     θ   y     )       ⁢     sin   ⁡     (     θ   p     )                   cos   ⁡     (     θ     r   ′       )                       -     sin   ⁡     (     θ     p   ′       )                 -     cos   ⁡     (     θ     p   ′       )         ⁢     sin   ⁡     (     θ     r   ′       )                 cos   ⁡     (     θ   p     )       ⁢     cos   ⁡     (     θ     r   ′       )               ]                     ⁢       [           a   x               a   y               a   z           ]     ,                   (   17   )                       ⁢   or                                   ⁢         [           a   u               a   v               a   w           ]     =     M   ⁡     [           a   x               a   y               a   z           ]         ,             (   18   )               
where a T =[a u  a v  a w ] T  is the vector a expressed in the device coordinates.
 
     A two posture manual calibration is again performed to determine the calibration matrix. The subject first assumes the supine posture and sensor data [a u  a v  a w ] T  is collected from the mounted device. The subject then assumes a second posture and sensor data is collected while the subject is in the second posture. For the supine posture, the gravity vector in body coordinates is [a u  a v  a w ] T =[1 0 0] T . The matrix equation for this situation is: 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           
                             [ 
                             
                               
                                 
                                   
                                     a 
                                     u 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     v 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     w 
                                   
                                 
                               
                             
                             ] 
                           
                           Supine 
                         
                         = 
                           
                         ⁢ 
                         
                           [ 
                           
                             
                               
                                 
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               y 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               p 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     
                                       
                                         
                                           
                                             - 
                                             
                                               sin 
                                               ⁡ 
                                               
                                                 ( 
                                                 
                                                   θ 
                                                   
                                                     y 
                                                     ′ 
                                                   
                                                 
                                                 ) 
                                               
                                             
                                           
                                           ⁢ 
                                           
                                             cos 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 
                                                   r 
                                                   ′ 
                                                 
                                               
                                               ) 
                                             
                                           
                                         
                                         - 
                                       
                                     
                                   
                                   
                                     
                                       
                                         
                                           cos 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 y 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 p 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               r 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     
                                       
                                         
                                           
                                             - 
                                             
                                               sin 
                                               ⁡ 
                                               
                                                 ( 
                                                 
                                                   θ 
                                                   
                                                     r 
                                                     ′ 
                                                   
                                                 
                                                 ) 
                                               
                                             
                                           
                                           ⁢ 
                                           
                                             sin 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 
                                                   y 
                                                   ′ 
                                                 
                                               
                                               ) 
                                             
                                           
                                         
                                         + 
                                       
                                     
                                   
                                   
                                     
                                       
                                         
                                           cos 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 r 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 p 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               y 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               y 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               p 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     
                                       
                                         
                                           
                                             cos 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 r 
                                               
                                               ) 
                                             
                                           
                                           ⁢ 
                                           
                                             cos 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 y 
                                               
                                               ) 
                                             
                                           
                                         
                                         - 
                                       
                                     
                                   
                                   
                                     
                                       
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               r 
                                             
                                             ) 
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 p 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         sin 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               y 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     
                                       
                                         
                                           
                                             sin 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 
                                                   r 
                                                   ′ 
                                                 
                                               
                                               ) 
                                             
                                           
                                           ⁢ 
                                           
                                             cos 
                                             ⁡ 
                                             
                                               ( 
                                               
                                                 θ 
                                                 y 
                                               
                                               ) 
                                             
                                           
                                         
                                         + 
                                       
                                     
                                   
                                   
                                     
                                       
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 y 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                         ⁢ 
                                         
                                           sin 
                                           ⁡ 
                                           
                                             ( 
                                             
                                               θ 
                                               
                                                 p 
                                                 ′ 
                                               
                                             
                                             ) 
                                           
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         cos 
                                         ⁡ 
                                         
                                           ( 
                                           
                                             θ 
                                             
                                               r 
                                               ′ 
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                             
                             
                               
                                 
                                   - 
                                   
                                     sin 
                                     ⁡ 
                                     
                                       ( 
                                       
                                         θ 
                                         
                                           p 
                                           ′ 
                                         
                                       
                                       ) 
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     - 
                                     
                                       cos 
                                       ⁡ 
                                       
                                         ( 
                                         
                                           θ 
                                           p 
                                         
                                         ) 
                                       
                                     
                                   
                                   ⁢ 
                                   
                                     sin 
                                     ⁡ 
                                     
                                       ( 
                                       
                                         θ 
                                         
                                           r 
                                           ′ 
                                         
                                       
                                       ) 
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     cos 
                                     ⁡ 
                                     
                                       ( 
                                       
                                         θ 
                                         
                                           p 
                                           ′ 
                                         
                                       
                                       ) 
                                     
                                   
                                   ⁢ 
                                   
                                     cos 
                                     ⁡ 
                                     
                                       ( 
                                       
                                         θ 
                                         
                                           r 
                                           ′ 
                                         
                                       
                                       ) 
                                     
                                   
                                 
                               
                             
                           
                           ] 
                         
                       
                     
                   
                   
                     
                       
                           
                         ⁢ 
                         
                           
                             [ 
                             
                               
                                 
                                   1 
                                 
                               
                               
                                 
                                   0 
                                 
                               
                               
                                 
                                   0 
                                 
                               
                             
                             ] 
                           
                           , 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   19 
                   ) 
                 
               
             
             
               
                 
                   
                       
                   
                   ⁢ 
                   or 
                 
               
               
                 
                     
                 
               
             
             
               
                 
                   
                       
                   
                   ⁢ 
                   
                     
                       
                         [ 
                         
                           
                             
                               
                                 a 
                                 u 
                               
                             
                           
                           
                             
                               
                                 a 
                                 v 
                               
                             
                           
                           
                             
                               
                                 a 
                                 w 
                               
                             
                           
                         
                         ] 
                       
                       Supine 
                     
                     = 
                     
                       
                         [ 
                         
                           
                             
                               
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       
                                         y 
                                         ′ 
                                       
                                     
                                     ) 
                                   
                                 
                                 ⁢ 
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       
                                         p 
                                         ′ 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   sin 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       
                                         y 
                                         ′ 
                                       
                                     
                                     ) 
                                   
                                 
                                 ⁢ 
                                 
                                   cos 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       
                                         p 
                                         ′ 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               
                                 - 
                                 
                                   sin 
                                   ⁡ 
                                   
                                     ( 
                                     
                                       θ 
                                       
                                         p 
                                         ′ 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                         ] 
                       
                       . 
                     
                   
                 
               
               
                 
                   ( 
                   20 
                   ) 
                 
               
             
           
         
       
     
     The components of the rotation matrix, M, are denoted as follows, 
                     M   =     [           m   11           m   12           m   13               m   21           m   22           m   23               m   31           m   32           m   33           ]       ,           (   21   )               
and by inspection m 11 =a u, Supine. , m 21 =a v, Supine , m 31 =a w, Supine , where a u, Supine . refers to the sensor output from the “u” device axis when the patient is in the supine position.
 
P′ Angle Coefficients
 
     To calculate the calibration matrix elements associated with θ p′ , it can be seen from the form of the matrix that m 31 =−sin(θ p′ ), so that sin(θ p′ )=−a w, Supine . The term a w, Supine  can be measured directly by the sensor with the patient in the Supine posture. If sin(θ p′ )=−a w, Supine , then using the trigonometric identity cos(θ p′ )=±√{square root over (1−sin 2 (θ p′ ))}, cos(θ p′ ) can be computed from the measured quantities cos(θ p )=a w,Supine   2 . 
     Y′ Angle Coefficients 
     This expression for cos(θ p′ ) can be used to calculate the calibration matrix elements associated with θ y′ . Two separate equations that can be used to characterize the roll rotation are: sin(θ y′ )=a v,Supine /±√{square root over ( 1 −a w,Supine   2 )}, and cos(θ y′ )=a u,Supine /±√{square root over (1−a w,Supine   2 )}. As before, either of the equations can be used to calculate the roll rotation matrix components but the results may not be identical in practice. Both of these equations can be used to calculate the θ y′ , rotation matrix components to enhance the accuracy of the results. 
     Again, simplifying the notation leads to the equation: 
                       [           a   u               a   v               a   w           ]     Supine     =         [             c   p     ⁢     c   y                 -     c   r       ⁢     s   y       -       s   r     ⁢     s   p     ⁢     c   y                   -     s   r       ⁢     s   y       +       c   r     ⁢     s   p     ⁢     c   y                     c   p     ⁢     s   y                 c   r     ⁢     c   y       -       s   r     ⁢     s   p     ⁢     s   y                   c   y     ⁢     s   r       +       c   r     ⁢     s   p     ⁢     s   y                   -     s   p               -     s   r       ⁢     c   p               c   r     ⁢     c   p             ]     ⁡     [         1           0           0         ]       .             (   22   )               
In simplified notation, the non-trigonometric equations are:
 
 s   p   =−a   w,Supine  
 
 c   P =±√{square root over ( 1 − s   p   2 )},
 
 s   ya   =a   v,Supine   /c   p   , c   ya =±√{square root over ( 1 − s   ya   2 )},
 
 c   yb   =a   u,Supine   /c   p   , s   yb =±√{square root over (1 −c   yb   2 )},  (23)
 
where the additional “a” and “b” in the subscripts denote that these are two alternative sets of calculations may give different results in practice. Either the set “a” or the set “b” equations should be used and s y , c y  calculated from the same set of equations. Thus, by knowing a w, Supine  and a v, Supine , or knowing a w, Supine  and a u, Supine , four of the six coefficients can be calculated.
 
R′ Angle Coefficients
 
     Remaining to be computed are the two coefficients related to θ r′ ; namely s r  and c r . In some examples, to determine this rotation, the patient assumes an upright posture (e.g., standing). The gravity vector in body coordinates for the upright posture is [a u  a v  a w ] T =[0 0 1] T . This leads to the equation: 
                         [           a   u               a   v               a   w           ]     Upright     =       [             c   p     ⁢     c   y                 -     c   r       ⁢     s   y       -       s   r     ⁢     s   p     ⁢     c   y                   -     s   r       ⁢     s   y       +       c   r     ⁢     s   p     ⁢     c   y                     c   p     ⁢     s   y                 c   r     ⁢     c   y       -       s   r     ⁢     s   p     ⁢     s   y                   c   y     ⁢     s   r       +       c   r     ⁢     s   p     ⁢     s   y                   -     s   p               -     s   r       ⁢     c   p               c   r     ⁢     c   p             ]     ⁡     [         0           0           1         ]         ,           (   24   )             or                             [           a   u               a   v               a   w           ]     Upright     =       [               -     s   r       ⁢     s   y       +       c   r     ⁢     s   p     ⁢     c   y                       c   y     ⁢     s   r       +       c   r     ⁢     s   p     ⁢     s   y                     c   r     ⁢     c   p             ]     .             (   25   )               
The simplest set of calculations for the θ r′  coefficients is c r =a w,Upright /c p ,s r =±√{square root over (1−c r   2 )}. All six of the coefficients can be calculated and therefore all nine elements of the calibration matrix M can be calculated. As with the first example where the subject is first upright and is supine second, the elements of the calibration matrix are calculated without using a trigonometric function and without expressly calculating an orientation angle.
 
       FIG. 6  is a flow diagram of a method  600  of determining a calibration matrix for a multi-dimensional posture sensor. At block  605 , a first sensor output is measured for a first device axis while the subject is in a first specified posture. The first device axis can be the u axis, v axis, or w axis. In some examples, the first specified posture is the upright posture and the first sensor output can be a u,Upright . In some examples, the first specified posture is the supine posture and the first sensor output can be a w, Supine . Other postures (e.g., lying on one&#39;s side) can be used for the first posture. 
     At block  610 , a second sensor output is measured for one of a second device axis or a third device axis while the subject is in the first specified posture. In some examples, the first sensor output can be a u,Upright  and the second sensor output can be a v,Upright  or a w,Upright . In some examples, the first sensor output can be a w, Supine  and the second sensor output can be a v, Supine  or a u, Supine . In certain examples, a sensor output is measured for both the second device axis and the third device axis. 
     At block  615 , at least a third sensor output is measured for the first device axis while the subject is in a second specified posture. The second specified posture can be orthogonal to the first specified posture. As an example, the first sensor output can be a u,Upright  and the third sensor output can be a u, Supine . In another example, the first sensor output can be a w, Supine  and the third can be a w,Upright . 
     At block  620 , the posture sensor is calibrated by calculating a calibration transform using the first, second, and third sensor outputs without determining an orientation angle of the device. In some examples, elements of a matrix to calibrate the posture sensor are calculated using the first, second, and third sensor outputs. For example, components of the elements can be calculated using the algebraic (and non-trigonometric) equations:
 
 s   p   =a   ,Upright  
 
 c   p =±√{square root over (1 −s   p   2 )}
 
 s   ra   =a   v,Upright   /c   p   , c   ra =±√{square root over (1 −s   ra   2 )},
 
 c   rb   =a   w,Upright   /c   p   , s   rb =±√{square root over (1 −c   rb   2 )},
 
 c   y   =a   u,Supine   /c   p ,
 
 s   y =±√{square root over (1 −c   y   2 )},  (26)
 
without expressly calculating any of the orientation angles θ p , θ r , or θ y . The first set of matrix components s p , c p , is related to a first orientation angle θ p , and are calculated using the first sensor output a u,Upright . The second set of matrix components s r , c r , is related to a second orientation angle θ r , and are calculated using the first sensor output a u,Upright  (from s p , c p ), and a second sensor output; either a v,Upright  or a w,Upright . The third set of matrix components s y , c y , is related to a third orientation angle θ y , and is calculated using a third sensor output a u, Supine . The matrix components s p , c p , s r , c r , s y , and c y  are then used to calculate the matrix elements of the calibration matrix M.
 
     In another example, the matrix elements can be calculated using the algebraic equations:
 
 s   p   =−a   w,Supine  
 
 c   p =±√{square root over ( 1 − s   p   2 )}
 
 s   ya   =a   v,Supine   /c   p   , c   ya =±√{square root over (1 −s   ya   2 )},
 
 c   yb   =a   u,Supine   /c   p   ,s   yb =±√{square root over ( 1 − c   yb   2 )},
 
 c   r   =a   w,Upright   /c   p ,
 
 s   r =±√{square root over ( 1 − c   r   2 )},  (27)
 
without expressly calculating any of the orientation angles θ p′ , θ r′ , or θ y′ .
 
     At block  625 , the calibration can be used to determine subsequent subject posture from subsequent sensor output. In some examples, a calibration matrix is used to determine the posture. In some examples, the output of the posture sensor is compared to one or more thresholds to determine the posture or approximate posture of the subject. 
     If the posture sensor is a multi-dimensional posture sensor where the axes are aligned with the body axes, the outputs of the posture sensor would be [a u  a v  a w ]=[1 0 0] in body coordinates when the subject is upright and would be [a u  a v  a w ]=[0 0 1] when the subject is supine. However, the outputs will differ from these values when the device coordinates are different from the body coordinates. 
     The output of the multi-dimensional posture sensor can be viewed as a vector (e.g., a g vector). To transform the sensor outputs from device coordinates to body coordinates, the sensor output, or g vector, is multiplied by the calibration matrix. For instance, if a u , a v , a w , are the sensor outputs for each of three orthogonal axes of the multi-dimensional sensor in device coordinates and M is the calibration matrix, then 
                       [           a   x               a   y               a   z           ]     =       M     -   1       ⁡     [           a   u               a   v               a   w           ]         ,           (   28   )               
where a x , a y , a z  are the corresponding sensor measurements, or g vector, in the body coordinate system. The converted or transformed sensor outputs a x , a y , a z  are compared to specified thresholds (e.g., programmed into a medical device) to determine posture.
 
     In some examples, one or more angles are calculated from the transformed sensor outputs. The calculated angles are compared to specified threshold angles to determine patient posture. An approach for determining patient posture from a calibrated multi-dimensional posture sensor can be found in Wang et al., “Posture Detector Calibration and Use,” U.S. Patent Pub. No. US 2007/0118056, filed Nov. 18, 2005, which is incorporated herein by reference in its entirety. 
     Non-orthogonal Calibration Maneuvers 
     Sometimes having to use mutually orthogonal postures is not desirable. In some situations it may not be advisable to place the patient in a fully recumbent or supine posture, such as when the patient has orthopnea and lying flat is difficult. This can make calibration of the sensor difficult to perform. In some situations it may be difficult for the patient to remain perfectly still while being perfectly upright. This can lead to inaccuracy in the calibration. Thus, it would be desirable to have expressions for components of the elements of the calibration matrix that don&#39;t require two mutually orthogonal postures for calibration. 
     Alternative Calculations for the Yaw Angle (Y) Coefficients 
     For the examples where the calibration maneuver includes the patient first in an upright posture and second in a supine posture, the same expressions are used for the pitch and roll components s p , c p , s r , and c r , but different expressions are used for the yaw components, s y  and c y , that allow the patient to be in a second posture that is more supine than the upright posture but is less than fully supine. 
     Rewriting Equation (3) in the simplified notation yields: 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   u 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   v 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   w 
                                 
                               
                             
                           
                           ] 
                         
                         = 
                         
                           M 
                           ⁡ 
                           
                             [ 
                             
                               
                                 
                                   
                                     a 
                                     x 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     y 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     z 
                                   
                                 
                               
                             
                             ] 
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             M 
                             r 
                           
                           ⁢ 
                           
                             M 
                             p 
                           
                           ⁢ 
                           
                             
                               M 
                               y 
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       x 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       y 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       z 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 
                                   [ 
                                   
                                     
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           r 
                                         
                                       
                                       
                                         
                                           s 
                                           r 
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         
                                           - 
                                           
                                             s 
                                             r 
                                           
                                         
                                       
                                       
                                         
                                           c 
                                           r 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                                 ⁡ 
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           s 
                                           p 
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           - 
                                           
                                             s 
                                             p 
                                           
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           y 
                                         
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       
                                         s 
                                         y 
                                       
                                     
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                     
                                       1 
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       x 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       y 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       z 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   29 
                   ) 
                 
               
             
           
         
       
     
     The inverse of the matrix M (M 1 ) is calculated to rotate back from device toward body coordinates. The inverse of the product of matrices is the product of the inverses of the matrices in reversed (left-to-right) order. Also, because the use of the “s” and “c” values are consistent, the individual rotation matrices are unitary, and the inverses of the rotation matrices are equal to the transposes of the matrices. Thus, fully rotating from body to device coordinates involves 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   x 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   y 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   z 
                                 
                               
                             
                           
                           ] 
                         
                         = 
                         
                           
                             M 
                             
                               - 
                               1 
                             
                           
                           ⁡ 
                           
                             [ 
                             
                               
                                 
                                   
                                     a 
                                     u 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     v 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     w 
                                   
                                 
                               
                             
                             ] 
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             M 
                             y 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             M 
                             p 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             
                               M 
                               r 
                               
                                 - 
                                 1 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           y 
                                         
                                       
                                       
                                         
                                           s 
                                           y 
                                         
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           - 
                                           
                                             s 
                                             y 
                                           
                                         
                                       
                                       
                                         
                                           c 
                                           y 
                                         
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                     
                                   
                                   ] 
                                 
                                 ⁡ 
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           - 
                                           
                                             s 
                                             p 
                                           
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           s 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       1 
                                     
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           r 
                                         
                                       
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         s 
                                         r 
                                       
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   30 
                   ) 
                 
               
             
           
         
       
     
     The first two (right-most) rotations or transformations on [a u  a v  a w ] T  result in 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   x 
                                   ′ 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   y 
                                   ′ 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   z 
                                   ′ 
                                 
                               
                             
                           
                           ] 
                         
                         == 
                         
                           
                             M 
                             p 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             
                               M 
                               r 
                               
                                 - 
                                 1 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 [ 
                                 
                                   
                                     
                                       
                                         c 
                                         p 
                                       
                                     
                                     
                                       0 
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           p 
                                         
                                       
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       1 
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       
                                         s 
                                         p 
                                       
                                     
                                     
                                       0 
                                     
                                     
                                       
                                         c 
                                         p 
                                       
                                     
                                   
                                 
                                 ] 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       1 
                                     
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           r 
                                         
                                       
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         s 
                                         r 
                                       
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   31 
                   ) 
                 
               
             
           
         
       
     
     In this coordinate system, the z′ axis is aligned with the body&#39;s inferior-superior (z) axis, and it merely remains to rotate about the z′ axis to align the x′ and y′ axes with the x and y axes, respectively. If the patient reclines straight back (e.g., not tilting to either side but not necessarily fully supine), then there will be a projection of the gravity vector perpendicular to the z′ axis, that is in the (x′, y′) plane. 
       FIG. 7  graphically shows the component of the g force that is in the (x′, y′) plane as radius r. It can be seen from the triangles in the Figure that the yaw components s y  and c y  can be computed from the x′ and y′ components as follows:
 
 r =√{square root over ( a   x   ′2   +a   ′2 )},
 
 c   y   =a   x′   /r  
 
 s   y   =a   y′   /r.   (32)
 
     To calculate s y  and c y , the outputs of the posture sensor for the supine position a u,Supine , a v,Supine , a w,Supine  are multiplied by the rotation matrices in the equation above to obtain a y ′, a y ′, and a z ′. The transformed outputs a y ′, a y ′, and a z ′ are then used to calculate s y  and c y . Note that in the previous calibration method a u,Supine  is already measured. Thus, only two additional measurements are needed a v,Supine  and a w,Supine  in this calibration method. 
     Alternative Calculations for the R′ Angle Coefficients 
     If it is desired to calibrate by placing the patient first in a supine posture and second in an upright posture, the same expressions are used for the yaw and pitch components s y , c y , s p , and  c   p , but different expressions are used for the roll components, s r  and c r , that allow the patient to be in a second posture that is more upright than the supine posture but is less than fully upright. 
     Rewriting the Equation (16) in the simplified notation yields: 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   u 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   v 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   w 
                                 
                               
                             
                           
                           ] 
                         
                         = 
                         
                           M 
                           ⁡ 
                           
                             [ 
                             
                               
                                 
                                   
                                     a 
                                     x 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     y 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     z 
                                   
                                 
                               
                             
                             ] 
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             M 
                             y 
                           
                           ⁢ 
                           
                             M 
                             p 
                           
                           ⁢ 
                           
                             
                               M 
                               r 
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       x 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       y 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       z 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           y 
                                         
                                       
                                       
                                         
                                           - 
                                           
                                             s 
                                             y 
                                           
                                         
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           s 
                                           y 
                                         
                                       
                                       
                                         
                                           c 
                                           y 
                                         
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                     
                                   
                                   ] 
                                 
                                 ⁡ 
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           s 
                                           p 
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           - 
                                           
                                             s 
                                             p 
                                           
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       1 
                                     
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                     
                                       
                                         s 
                                         r 
                                       
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           r 
                                         
                                       
                                     
                                     
                                       
                                         c 
                                         r 
                                       
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       x 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       y 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       z 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   33 
                   ) 
                 
               
             
           
         
       
     
     The matrix inverse M 1  is calculated to rotate back from device toward body coordinates. As before, because the inverse of the product of matrices is the product of the inverses of the matrices in reversed (left-to-right) order, and because the inverses of the rotation matrices are equal to the transposes of the matrices, rotating from body to device coordinates involves 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   x 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   y 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   z 
                                 
                               
                             
                           
                           ] 
                         
                         = 
                         
                           
                             M 
                             
                               - 
                               1 
                             
                           
                           ⁡ 
                           
                             [ 
                             
                               
                                 
                                   
                                     a 
                                     u 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     v 
                                   
                                 
                               
                               
                                 
                                   
                                     a 
                                     w 
                                   
                                 
                               
                             
                             ] 
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             M 
                             r 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             M 
                             p 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             
                               M 
                               y 
                               
                                 - 
                                 1 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 
                                   [ 
                                   
                                     
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           r 
                                         
                                       
                                       
                                         
                                           - 
                                           
                                             s 
                                             r 
                                           
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         
                                           s 
                                           r 
                                         
                                       
                                       
                                         
                                           c 
                                           r 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                                 ⁡ 
                                 
                                   [ 
                                   
                                     
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           - 
                                           
                                             s 
                                             p 
                                           
                                         
                                       
                                     
                                     
                                       
                                         0 
                                       
                                       
                                         1 
                                       
                                       
                                         0 
                                       
                                     
                                     
                                       
                                         
                                           s 
                                           p 
                                         
                                       
                                       
                                         0 
                                       
                                       
                                         
                                           c 
                                           p 
                                         
                                       
                                     
                                   
                                   ] 
                                 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       
                                         s 
                                         y 
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       
                                         - 
                                         
                                           s 
                                           y 
                                         
                                       
                                     
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                     
                                       1 
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   34 
                   ) 
                 
               
             
           
         
       
     
     The first two (right-most) rotations on [a u , a v  a w ] T  result in 
     
       
         
           
             
               
                 
                   
                     
                       
                         
                           [ 
                           
                             
                               
                                 
                                   a 
                                   x 
                                   ′ 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   y 
                                   ′ 
                                 
                               
                             
                             
                               
                                 
                                   a 
                                   z 
                                   ′ 
                                 
                               
                             
                           
                           ] 
                         
                         == 
                         
                           
                             M 
                             p 
                             
                               - 
                               1 
                             
                           
                           ⁢ 
                           
                             
                               M 
                               y 
                               
                                 - 
                                 1 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                         
                           
                             
                               
                                 [ 
                                 
                                   
                                     
                                       
                                         c 
                                         p 
                                       
                                     
                                     
                                       0 
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           p 
                                         
                                       
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       1 
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       
                                         s 
                                         p 
                                       
                                     
                                     
                                       0 
                                     
                                     
                                       
                                         c 
                                         p 
                                       
                                     
                                   
                                 
                                 ] 
                               
                               ⁡ 
                               
                                 [ 
                                 
                                   
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       
                                         - 
                                         
                                           s 
                                           y 
                                         
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       
                                         s 
                                         y 
                                       
                                     
                                     
                                       
                                         c 
                                         y 
                                       
                                     
                                     
                                       0 
                                     
                                   
                                   
                                     
                                       0 
                                     
                                     
                                       0 
                                     
                                     
                                       1 
                                     
                                   
                                 
                                 ] 
                               
                             
                             ⁡ 
                             
                               [ 
                               
                                 
                                   
                                     
                                       a 
                                       u 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       v 
                                     
                                   
                                 
                                 
                                   
                                     
                                       a 
                                       w 
                                     
                                   
                                 
                               
                               ] 
                             
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   35 
                   ) 
                 
               
             
           
         
       
     
     This time, the x′ axis is aligned with the body&#39;s anterior-posterior (x) axis, and it merely remains to rotate about the x′ axis to align the y′ and z′ axes with the y and z axes, respectively. If the patient is mostly upright (e.g., not tilting to either side but not necessarily fully upright), then there will be a projection of the gravity vector perpendicular to the x′ (x) axis, that is in the (y′, z′) plane. 
       FIG. 8  graphically shows the component of the g force that is in the (y′, z′) plane as radius r. It can be seen from the triangles in the Figure that the yaw components s r  and c, can be computed from the x′ and z′ components as follows:
 
 r =√{square root over ( a   y   ′2   +a   z   ′2 )},
 
 s   r   =a   y′   /r,  
 
 c   r   =a   z′   /r   (36)
 
     To calculate s r  and c r , the outputs of the posture sensor for the supine position right a u,Upright , a v,Upright , a w,Upright , are multiplied by the rotation matrices in the equation above to obtain a x ′, a y ′, and a z ′. The transformed outputs a x ′, a y ′, and a z ′ are then used to calculate s r  and c r . As in the alternate Yaw angle example, two additional measurements are needed a v,Upright  and a w,Upright  in this calibration method. 
       FIG. 9  is a flow diagram of another method  900  of determining a calibration matrix for a multi-dimensional posture sensor. Similar to the method  600  of  FIG. 6 , at block  905 , a first sensor output is measured for a first device axis while the subject is in a first specified posture. In some examples, the first specified posture is the upright posture and the first sensor output can be a u,Upright . In some examples, the first specified posture is the supine posture and the first sensor output can be a w, Supine . Other postures (e.g., lying on one&#39;s side) can be used for the first posture. 
     At block  910 , a second sensor output is measured for one of a second device axis or a third device axis while the subject is in the first specified posture. In some examples, the first sensor output can be a u,Upright  and the second sensor output can be a v,Upright  or a w,Upright . In some examples, the first sensor output can be a w, Supine  and the second sensor output can be a v, Supine  or a u, Supine . In certain examples, a sensor output is measured for both the second device axis and the third device axis. 
     At block  915 , a third sensor output is measured for the first device axis while the subject is in a second specified posture. The second specified posture can be non-orthogonal to the first specified posture. As an example, the first posture can be the upright posture, the first sensor output can be a u,Upright , the second specified posture can be more supine than the first posture and less than fully supine, and the third sensor output may be a u, less than Supine . In another example, the first specified posture can be the supine posture, the first sensor output may be a w, Supine , the second posture can be more upright than the first posture and less than fully upright, and the third sensor output may be a w, less than Upright . 
     At block  920 , a fourth sensor output for the second device axis is measured while the subject is in the second specified posture. In some examples, the fourth sensor output may be a v, less than Supine . In some examples, the fourth sensor output may be a v, less than Upright . 
     At block  925 , a fifth sensor output for the third device axis measured while the subject is in the second specified posture. In some examples, the fifth sensor output may be a w, less than supine . In some examples, the fifth sensor output may be a u, less than Upright . 
     At block  930 , a first coordinate transformation associated with a first orientation angle is calculated, and at block  935 , a second coordinate transformation associated with a second orientation angle is calculated using the first sensor output and the second sensor output. In some examples, the first and second transformations include the two (right-most) rotations on [a u  a v  a w ] T  in equations (30) or (34). 
     At block  940 , transformed third, fourth, and fifth sensor outputs are generated using the first and second coordinate transformations. In some examples, transformed sensor outputs a x ′, a y ′, and a z ′ are generated from sensor outputs a u , a y , a w , using the rotations as in equation (31) or in equation (35). 
     At block  945 , elements of the calibration matrix are calculated using the first and second sensor outputs and the transformed sensor outputs. In some examples, the first posture maneuver is upright and the second maneuver is less than fully supine and the elements of the calibration matrix are calculated using s p , c p , s r , and c r  using equations (26), and using s y , c y  using the equations (32). In some examples, the first posture maneuver is supine and the second maneuver is less than fully upright and the elements of the calibration matrix are calculated using s p , c p , s r , and c r  using equations (27), and using s y , c y  using the equations (36). At block  950 , the calibration matrix can be used to determine subsequent subject posture from subsequent sensor output. 
       FIG. 10  is a block diagram of an example of portions of a device  1000  capable of determining a calibration matrix for a multi-dimensional posture sensor. In some examples, the device can be an implantable medical device, and in some examples the device  1000  can be a wearable medical device. The multi-dimensional posture sensor  1005  provides an electrical sensor output representative of alignment of respective first, second, and third non-parallel axes of the device  1000  with the gravitational field of the earth. In some examples the posture sensor  1005  provides an output for each of the first, second, and third non-parallel axes of the device  1000 . The device  1000  includes a processor  1010 , such as a microprocessor, digital signal processor (DSP), or other kind of processor. In certain examples, the processor  1010  can be an application specific integrated circuit (ASIC). 
     The processor  1010  can be communicatively coupled to the posture sensor  1005 . The communicative coupling allows the processor  1010  to transmit and/or receive signals to or from the posture sensor  1005  even though there may be intervening circuitry. The processor  1010  includes circuits to perform the functions described herein. The circuits can be hardware, firmware, or software, or any combination of hardware, firmware, and software. In certain examples, the processor  1010  performs instructions embodied in software, firmware, or hardware. In certain examples, the processor  1010  includes a sequencer that proceeds through logic functions implemented by hardware. One or more functions may be performed by one circuit. 
     The processor  1010  includes a calibration circuit  1015  and a posture circuit  1020 . According to some examples, the calibration circuit  1015  and the posture circuit  1020  are configured to perform any of the methods described in regard to  FIG. 6 . In some examples, the calibration circuit  1015  measures a first sensor output for the first device axis while the subject is in a first specified posture, measures a second sensor output for one of the second device axis or the third device axis while the subject is in the first specified posture, and measures a third sensor output for the first device axis while the subject is in a second specified posture. 
     In certain examples, the first posture can be an upright posture and the second posture can be the supine posture. The first device axis can be the “u” device axis of  FIG. 4  and the second and third device axes can be the “v” and “w” device axes. In certain examples, the first posture is the supine posture and the second posture is an upright posture. The first device axis can be the “w” device axis of  FIG. 4  and the second and third device axes can be the “u” and “v” device axes. 
     The calibration circuit  1015  calculates the posture sensor  1005  by calculating a calibration transformation using the first and second sensor outputs and transformed sensor outputs. In some examples, the calibration circuit  1015  calculates elements of a matrix used to calibrate the posture sensor  1005  using the first, second, and third sensor outputs. As shown above in regards to equations (26) and (27) the calibration circuit  1015  is able to calculate the elements without determining an orientation angle of the device and without using trigonometric functions. After calibration, the posture circuit  1020  determines a subsequent posture of the subject using the posture sensor  1005 . 
     According to some examples, the calibration circuit  1015  and the posture circuit  1020  are configured to perform any of the methods described in regard to  FIG. 9 . As before, the calibration circuit  1015  measures a first sensor output for the first device axis while the subject is in a first specified posture, measure a second sensor output for one of the second device axis or the third device axis while the subject is in the first specified posture, and measure a third sensor output for the first device axis while the subject is in a second specified posture. 
     The two specified postures can be non-orthogonal. In certain examples, the first posture can be an upright posture and the second posture can be a posture more supine than the upright posture but less than fully supine. In certain examples, the first posture can be the supine posture and the second posture can be a posture more upright than the supine posture but less than fully upright. 
     In addition to the first three measurements the calibration circuit measures a fourth sensor output for the second device axis while the subject is in the second specified posture and measures a fifth sensor output for the third device axis while the subject is in the second specified posture. The calibration circuit  1015  then performs coordinate transformations to generate transformed sensor outputs for the second specified posture. 
     In some examples, the calibration circuit  1015  calculates a first coordinate transformation associated with a first orientation angle using a first sensor output, and calculates a second coordinate transformation associated with a second orientation angle using the first sensor output and a second sensor output. In certain examples, the transformations are performed using first and second rotation matrices. The transformed sensor outputs are generated by multiplying the third, fourth, and fifth sensor outputs by the first and second rotation matrices. Examples are described above in regard to equations (31) and (35). In certain examples, the calibration circuit  1015  calculates elements of the first rotation matrix using the first sensor output and calculates elements of the second rotation matrix using the first sensor output and the second sensor output. 
     The calibration circuit  1015  then calculates the elements of the calibration matrix using the first and second sensor outputs and using the transformed sensor outputs. In some examples, the calibration circuit calculates the matrix elements using matrix components (or coefficients) s p , c p , s r , c r , s y , and c y . The first set of matrix components, s p  and c p , is associated a first orientation angle (e.g., θ p , or θ p′ ) and is calculated using the first sensor output, such as by equations (26) or equations (27). 
     Depending on which set of postures, and therefore which set of equations are used, the second set of matrix components can be either s r  and c r , or  s   y  and c y , associated with a second orientation angle (e.g., θ r  or θ y′  respectively). The second set of matrix components is calculated using the first sensor output and the second sensor output, such as by equations (26) or (27). Note that the equations indicate that there is a choice over which sensor measurement to use as the second sensor output. Theoretically, either choice should produce identical results, but in practice one choice can be more desirable due to inaccuracies in the patient maneuver or noise in the measurements during the maneuver. 
     The third set of matrix components can be either s y  and c y , or s r  and c r , associated with a second orientation angle (e.g., θ y  or θ r ′ respectively). The third set of components is calculated using the transformed sensor outputs, such as by equations (32) or (36). The first, second, and third sets of matrix components s p , c p , s r , c r , s y , and c y  are then used to calculate the matrix elements of the calibration matrix M, such as the matrix elements in equations (9) and (11), or equations (22) and (24). Note that the matrix components, and therefore the matrix elements, are calculated using the resulting algebraic equations, and are calculated without a determination of any of the orientation angles of the device  1000  or using trigonometric functions. This can reduce the amount of processing power required by the processor  1010 . 
     According to some examples, the posture circuit  1020  receives a sensor output (e.g., a DC-responsive voltage level) for each of the three non-parallel axes of the posture sensor  1005  and compares the sensor outputs to specified sensor output thresholds to determine posture of the subject. The calibration circuit  1015  adjusts the specified sensor output thresholds using the calculated elements of the calibration matrix. 
     In some examples, the posture circuit  1020  determines subject posture by calculating 
                       [           a   x               a   y               a   z           ]     =       M     -   1       ⁡     [           a   u               a   v               a   w           ]         ,           (   37   )               
where M −1  is the inverse of the calibration matrix determined by the calibration circuit, a u , a v , a w , are the sensor outputs for each of three orthogonal axes of the multi-dimensional sensor, and a x , a y , a z , are the corresponding measurements or values in the body coordinate system. The posture circuit  1020  compares the body coordinate measurements to specified thresholds to determine the posture of the subject.
 
     According to some examples, the processor  1010  includes a trend circuit  1025  that trends a posture of the subject. The device  1000  provides an indication of progression of heart disease of the subject at least in part according to the trend. For example, a patient may, due to progression of heart disease, assume a more upright resting position over time. The processor  1010  can initiate sending an indication (e.g., an alert or alarm) to a user or process (e.g., a process executing in an external programmer or at a remote system) of the progression of the disease. 
     In some examples, the device  1000  includes a respiration sensor  1030  communicatively coupled to the processor  1010 . An example of a respiration sensor is a transthoracic impedance sensor used to measure minute respiration volume or tidal volume. An approach to measuring transthoracic impedance is described in Hartley et al.,U.S. Pat. No. 6,076,015 “Rate Adaptive Cardiac Rhythm Management Device Using Transthoracic Impedance,” filed Feb. 27, 1998, which is incorporated herein by reference in its entirety. The respiration sensor provides a signal representative of respiration of the subject. The processor  1010  calculates tidal volume of the subject using the respiration signal. The trend circuit  1025  trends the tidal volume of the subject according to a determined posture of the subject. 
     In some examples, the device  1000  includes an arterial pressure sensor  1035  communicatively coupled to the processor  1010 . An example of an arterial pressure sensor includes a pulmonary arterial (PA) pressure sensor. PA pressure includes the pressure within a pulmonary artery due to blood leaving the right ventricle through the pulmonary valve and going to the lungs. In some examples, the arterial pressure sensor provides a signal representative of PA pressure of the subject. The trend circuit  1025  trends PA pressure of the subject according to a determined posture of the subject. In some examples, the processor  1010  detects episodes of low blood pressure or high blood pressure using the pressure signal. The trend circuit  1025  trends episodes of low or high blood pressure according to a determined posture of the subject. 
     Posture sensing in an implantable or a wearable medical device allows improved monitoring of heart failure patients. Proper calibration of the posture sensor removes variation of the orientation of the sensor due to patient anatomy and due to device migration. 
     ADDITIONAL NOTES 
     The above detailed description includes references to the accompanying drawings, which form a part of the detailed description. The drawings show, by way of illustration, specific embodiments in which the invention can be practiced. 
     These embodiments are also referred to herein as “examples.” All publications, patents, and patent documents referred to in this document are incorporated by reference herein in their entirety, as though individually incorporated by reference. In the event of inconsistent usages between this document and those documents so incorporated by reference, the usage in the incorporated reference(s) should be considered supplementary to that of this document; for irreconcilable inconsistencies, the usage in this document controls. 
     In this document, the terms “a” or “an” are used, as is common in patent documents, to include one or more than one, independent of any other instances or usages of “at least one” or “one or more.” In this document, the term “or” is used to refer to a nonexclusive or, such that “A or B” includes “A but not B,” “B but not A,” and “A and B,” unless otherwise indicated. In the appended claims, the terms “including” and “in which” are used as the plain-English equivalents of the respective terms “comprising” and “wherein.” Also, in the following claims, the terms “including” and “comprising” are open-ended, that is, a system, device, article, or process that includes elements in addition to those listed after such a term in a claim are still deemed to fall within the scope of that claim. Moreover, in the following claims, the terms “first,” “second,” and “third,” etc. are used merely as labels, and are not intended to impose numerical requirements on their objects. 
     Method examples described herein can be machine or computer-implemented at least in part. Some examples can include a computer-readable medium or machine-readable medium encoded with instructions operable to configure an electronic device to perform methods as described in the above examples. An implementation of such methods can include code, such as microcode, assembly language code, a higher-level language code, or the like. Such code can include computer readable instructions for performing various methods. The code can form portions of computer program products. Further, the code can be tangibly stored on one or more volatile or non-volatile computer-readable media during execution or at other times. These computer-readable media can include, but are not limited to, hard disks, removable magnetic disks, removable optical disks (e.g., compact disks and digital video disks), magnetic cassettes, memory cards or sticks, random access memories (RAM&#39;s), read only memories (ROM&#39;s), and the like. 
     The above description is intended to be illustrative, and not restrictive. For example, the above-described examples (or one or more aspects thereof) may be used in combination with each other. Other embodiments can be used, such as by one of ordinary skill in the art upon reviewing the above description. The Abstract is provided to comply with 37 C.F.R. § 1.72(b), to allow the reader to quickly ascertain the nature of the technical disclosure. It is submitted with the understanding that it will not be used to interpret or limit the scope or meaning of the claims. Also, in the above Detailed Description, various features may be grouped together to streamline the disclosure. This should not be interpreted as intending that an unclaimed disclosed feature is essential to any claim. Rather, inventive subject matter may lie in less than all features of a particular disclosed embodiment. Thus, the following claims are hereby incorporated into the Detailed Description, with each claim standing on its own as a separate embodiment. The scope of the invention should be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.