# Inference of mechanical states of intestinal motor activity using hidden Markov models

- Lukasz Wiklendt
^{1}, - Marcello Costa
^{1}and - Phil G Dinning
^{1, 2}Email author

**13**:14

https://doi.org/10.1186/1472-6793-13-14

© Wiklendt et al.; licensee BioMed Central Ltd. 2013

**Received: **30 July 2013

**Accepted: **5 December 2013

**Published: **11 December 2013

## Abstract

### Background

Contractions and relaxations of the muscle layers within the digestive tract alter the external diameter and the internal pressures. These changes in diameter and pressure move digesting food and waste products. Defining these complex relationships is a fundamental step for neurogastroenterologists to be able define normal and abnormal gut motility.

### Results

Utilising an in vitro technique that allows for the simultaneous recording of intraluminal pressure (manometry) and gut diameter (video) in an isolated section of rabbit colon, we developed a technique to help define the mechanical states of the muscle at any point in space and time during actual peristaltic movements. This was achieved by directly relating the changes in pressure to the changes in diameter along the length of the gut studied. For each individual measure of pressure or diameter, 3 dynamic state components were identified; increasing or decreasing changes or a stable period. Two additional static state components, fully contracted and fully distended, were defined for the diameter. Then qualitative mechanical states of the muscle activity were defined as combinations of these state components. A hidden Markov model was used to correlate adjacent-in-time samples, and the Viterbi algorithm was used to infer the most likely sequence of mechanical states based on the observed data. From this a spatiotemporal map of the mechanical states was produced, showing the regions of active contractions, active relaxations, or passive states along the length of the gut throughout the entire recording period.

### Conclusions

The identification of mechanical muscles states based on gut diameter and intraluminal pressure was possible by modelling muscle activation with a hidden Markov model.

## Keywords

## Background

*in vivo*is problematic; ethical constraints prevent detailed examination of real-time movement of the gut wall. To overcome this problem we developed an

*in vitro*animal preparation that allowed us to record simultaneously, both intraluminal pressure (high-resolution manometry) and gut diameter (video) in real time, across varying length (15–90 cm) of intestine [3] (Figure 1a,b).

In the next stage of this research we published a theory based paper in which we developed a strategy based on simple principle of biomechanics to deduce the mechanical state of the muscle (active contraction or relaxation, passive dilation, periods of quiescence, etc.) by calculating the relation between pressure and diameter at every point along the gut segment, and establishing where and when the muscle is actively contracting or relaxing [4] (Figure 1c,d). In that paper, space prevented a detailed description of the mathematical model involved in developing this process. In this work we address the details of the strategy that enabled us to confidently identify, for the first time, the mechanical states of the muscle during peristaltic contractions, and plot them as a functional spatiotemporal map.

A major factor in our work involved the use of hidden Markov models (HMM). The HMM have found extensive use in a variety of fields, stemming from their seminal application in speech recognition in the 1970s [5]. In gastroenterology, HMMs have been used to classify the location of a video capsule in the gastrointestinal tract [6]. In their application to hand written recognition, HMMs were utilized by observing lines and curves drawn on a 2D plane and inferring the most probable characters they represent [7]. In developing our intestinal model of mechanical states, one of the major challenges we faced was how to identify the beginning and the end of the periods of the various different states of the muscle. However, analogous to hand written recognition, our diameter-pressure plots can be observed as lines in the 2D plane. Therefore the HMM was adapted to infer the most probable muscles states at any given point in time along the length of the studies gut segment. A description of the steps involved in this process are detailed here.

### Identification of muscle states

**Occluded isometric contraction**(

*oimc*): active; occurs with an increase in pressure, with no change in diameter, when the gut is at its minimum diameter.

**Occluded isometric relaxation**(

*oimr*): passive; occurs with a decrease in pressure and no change in diameter, when the gut is at its minimum diameter.

**Distended isometric pressure increase**(

*dipi*): passive; occurs with an increase in pressure, no change in diameter, when the gut is at its maximum diameter.

**Distended isometric pressure decrease**(

*dipd*): passive; occurs with a decrease in pressure, no change in diameter, and a maximum diameter.

**Isotonic contraction**(

*itc*): active; occurs with a decrease in diameter and no change in pressure.

**Isotonic relaxation**(

*itr*): active; occurs with an increase in diameter and no change in pressure.

**Auxotonic contraction**(

*atc*): active: occurs with a decrease in diameter and an increase in pressure.

**Auxotonic relaxation**(

*atr*): active: occurs with an increase in diameter and a decrease in pressure.

**Passive shortening**(

*ps*): passive; occurs with a decrease in diameter and pressure.

**Passive dilation**(

*pd*): passive; occurs with an increase in diameter and pressure.

**Occluded quiescence**(

*oq*): passive; occurs with no change in diameter nor pressure, when the gut is at its minimum diameter.

**Distended quiescence**(

*dq*): passive; occurs with no change in diameter nor pressure, when the gut is at a non-minimum diameter.

Having established that 12 mechanical states exist we then need to develop a means to determine when and where each state existed along the gut in an automated fashion. In addition we had to detect both the changes in the mechanical states (transitions of direction of the linear segments of the orbits) and the permanence in that state (the beginning and end of the linear segment).

## Methods

The intraluminal pressures were recorded by a manometry catheter with pressure sensors spaced at 10 mm intervals and each of these was considered independent for modelling purposes. At each sensor location, diameter and pressure values were recorded continuously.

### Data acquisition

A detailed description of the techniques used to collate the data has been published elsewhere [4]. Here we will provide a brief overview.

Rabbits were euthanized humanely by intravenous injection of pentobarbitone sodium (0.5 ml kg^{−1}) in accordance with approval by the Animal Welfare Committee of Flinders University.

The gut diameter and internal pressure were recorded using two different methods, at different sampling rates, spacial resolutions, and offsets in time and space. Resampling and spatiotemporal alignment was required to coincide values of pressure and diameter for use as a single observation vector for each node in the Markov chain. Each spatial location was assigned its own Markov chain.

A spatiotemporal map of colonic diameter was based on techniques developed in our lab [9]. Briefly the spatiotemporal maps were obtained by recording a top-down video of the colon suspended in a bath of Krebs solution, such that the length of the colon appeared horizontally in the video, and the number of pixels that the colon spans for each vertical pixel line in each frame was counted. Using a reference ruler visible in the recorded video, the colonic diameter in millimetres was obtained.

Pressures were recorded by 10 mm-spaced sensors at 10 Hz with a catheter inserted into the colon. Baseline drift was removed with iterated Gaussian minima smoothing [10].

Different spatiotemporal resolutions and offsets required resampling and alignment. A diameter map and a pressure map were combined by creating a grid of coordinates using the coarsest resolution in time and space from either map aligned with an adjustable spatiotemporal offset, and then binning the original maps into the grid. This resulted in a spatial and time resolution of 10 mm and 0.25 s respectively.

The alignment resulted in a single set of spatiotemporal coordinates that map to coincident diameter and pressure values, allowing diameters and pressures to be quickly compared for analysis without further interpolation. The temporal offset was determined by aligning events that were synchronously recorded by video as flashes from a light bulb (for diameter data) and embedded into the pressure recording as meta-data. The spatial offset was manually obtained by observing overlapping images of the two maps, while adjusting the offset to a value best representative of correct alignment that correlates with the video.

The entire data set consisted of 6 rabbits recorded with approximately 20 sensors over periods of 10 to 20 minutes each, resulting in just over 420,000 samples (almost 30 hours); orbits were created for each sensor.

### Hidden Markov model

Given a sequence of observations of diameter and pressure at a single location in the colon, our objective was to infer the most-likely sequence of mechanical muscle states that could have resulted in those observations. Each mechanical muscle state was directly represented as a hidden state in the hidden Markov model. In our application, the dependence of a state on the previous state in the Markov chain was required as an implicit smoothing technique.

#### Observations

*d*and pressure

*p*, sampled at a frequency of 4 Hz. Sample

*i*of the diameter and pressure is given by

*d*

_{ i }and

*p*

_{ i }, where

*i*∈{1…

*N*}. The time derivatives of those values are denoted with an overdot and estimated using central differences as

where *Δ* *t*=0.25*s* for the 4 Hz sampling, and $\stackrel{\u0307}{p}$ defined in the same manner as $\stackrel{\u0307}{d}$.

*i*is defined as the vector

Any general sequence (*x*_{
a
}, *x*_{a+1}, …, *x*_{b−1}, *x*_{
b
}) will be written as *x*_{a:b} for the sake of brevity.

#### States

The conceptual directions and positions of subsequences of observations on a diameter-pressure plot representing examples of each of the twelves states is depicted in Figure 2 and described in Figure 1a. The state-observation model is based on developing a quantitative model for classifying the dynamics depicted in that figure.

#### State-observation model

The state-observation model defines the conditional probabilities of observations and states. The goal is to arrive at a formula describing the distribution of possible observations, under the assumption that they were produced while the muscle was in any given mechanical state. The sample subscript *i* is omitted for brevity in this section, since the state-observation model is independent of the sample number.

Each state in *S* is composed of 3 state components, where each component *c*_{
o
} corresponds to an element *o* of the observation **o**, and non corresponding components and elements are considered independent. The components *quiet*, *pos*, and *neg* correspond to the $\stackrel{\u0307}{d}$ and $\stackrel{\u0307}{p}$ velocity elements. The *quiet* component corresponds to a value of the velocity element close to 0, and *pos* and *neg* represent the positive and negative values. The components *occ*, *dis*, and *any* correspond to the diameter *d*, where *occ* represents an occluded diameter, *dis* a distended diameter, and *any* if the diameter is irrelevent. For example, the state *dipd* is composed of *dis*, ${\mathit{\text{quiet}}}_{\stackrel{\u0307}{d}}$, and ${\mathit{\text{neg}}}_{\stackrel{\u0307}{p}}$, where the subscripts disambiguate the corresponding velocity elements.

*S*can be considered a vector of state components $({c}_{d},{c}_{\stackrel{\u0307}{d}},{c}_{\stackrel{\u0307}{p}})$, where

*quiet*is modelled on the basis of a normal distribution located at 0 with width free parameters ${\sigma}_{\stackrel{\u0307}{d}}$ and ${\sigma}_{\stackrel{\u0307}{p}}$. The normal distribution is the most common way to model noise and errors, justified by the central limit theorem. Since very low speeds are considered quiescent, slow tonic muscle activity will be absorbed into passive states, with only phasic contractions exposed as active states. The probability of the state component being

*pos*or

*neg*is modelled on the basis of normal cumulative distribution functions with the same parameters. Probability mass functions are normalised to ensure

*d*, the probability of the corresponding state component being

*occ*or

*dis*is modelled on the basis of a normal cumulative distribution function and its complement, located at

*μ*

_{ d }+min

_{ d }with width

*σ*

_{ d }, where min

_{ d }is the value of the minimum recorded diameter. The value

*d*−min

_{ d }is referred to as “dilation”, and

*μ*

_{ d }represents the amount of dilation that separates occluded and distended states. The probability of the state being

*any*given

*d*is a constant. The probability mass functions are normalised to ensure

See (13)–(15) for the formulae, and Figure 3 (b) for a visual example.

*f*(

*c*

_{ o }|

*o*) are given by

where *Φ* is the cumulative standard normal distribution function, *v* is an alias for either $\stackrel{\u0307}{d}$ or $\stackrel{\u0307}{p}$, and *Z*_{
v
} and *Z*_{
d
} are normalisation constants ensuring the probabilities sum to 1 for any given observation and all corresponding states.

*c*

_{ o }, is known as the

*emission PDF*, which can be obtained from Bayes’ theorem

*f*(

*o*) can be removed which is independent of state and so does not change which state is most likely to have produced a given observation. In a similar way, if we approximate the state component prior distribution

*f*(

*c*

_{ o }) with a constant, then it can also be removed resulting in the following practical approximation

Note that under this approximation, *f*(*o*|*c*_{
o
}) no longer represents a PDF, that is, $\int f\left(o\right|{c}_{o})\mathit{\text{do}}\ne 1$.

This approximation isn’t necessary for performance, since finding the priors numerically is straight forward with Gaussian kernel density estimation of *f*(*o*) and the marginalization $f\left({c}_{o}\right)=\int f\left({c}_{o}\right|o\left)f\right(o)\mathit{\text{do}}$, which resulted in priors of *f*(*c*_{
o
}) = 0.33 ± 0.09 for our data. Rather it is our desire to keep the emission PDFs free of any other data-based attributes besides the few parameters that were chosen by hand. This allows for the consistent interpretation of results by having a homogeneous muscle mechanics model which is comparable among different preparations and recordings.

*d*, $\stackrel{\u0307}{d}$, and $\stackrel{\u0307}{p}$, the joint emission PDF can be factorized into

with implicit substitutions of (10)–(12) and (13)–(15) to be made in (18) due the approximation (17). The independence assumption is a model simplification rather than an observed independence in the data, and allows for the factorization of the joint emission PDF into component emission PDFs. Making such an independence assumption, where none exists in reality, is common practice in machine learning for simplifying models and algorithms used to make inference. In practice, inference algorithms are often robust despite such assumptions, and we observe that inferences obtained by our technique remain consistent with expected states.

#### Optimal state sequence

**o**

_{1:N}, our goal is to find the optimal sequence of states

*s*

_{1:N}that explains the observations. The joint PDF of the observation and state sequences is given by a hidden Markov model [5], which subsumes the following factorisation

where *γ* ∈ (0, 1) is a free parameter that represents a penalty (when $\gamma >\frac{1}{\left|S\right|}$) for changing states between samples. Such a penalty allows the inferred state sequence to be desensitised to noisy observations, resulting in practical smoothing of the sequence. It is important to include this implicit smoothing so that linear segments of orbits containing undulations are not subdivided, which may result in incorrect state inferences based on arbitrary angles of small subsegments of the undulated linear segment. A value of $\gamma =\frac{1}{\left|S\right|}$ would result in modelling the states in adjacent samples as independent, effectively eliminating the links in the Markov chain.

where *f*(*s*_{1:N} | **o**_{1:N}) is proportional over *s*_{1:N} to (19), and the solution can be found by applying the Viterbi algorithm. The Viterbi algorithm works by calculating the most likely sequence of states based on a sequence of discrete observations. To handle continuous observations we used the value of the emission PDF at each observation as a substitute for the probability of making that observation.

#### Parameters

**Parameter values used in inference and analysis**

Parameter | Values for inference | Analysis range |
---|---|---|

| 2.5 mm | 0–7.5 mm |

| 0.4 mm | 0–1.2 mm |

${\sigma}_{\stackrel{\u0307}{d}}$ | 0.4 mm/s | 0–1.2 mm/s |

${\sigma}_{\stackrel{\u0307}{p}}$ | 3 mmHg/s | 0–9 mmHg/s |

| 0.5 | 0.255–0.99 |

*reference*classification, considered as ground-truth, was performed with the manually selected parameter values (middle column in Table 1). The reference classification was compared to many

*comparison*classifications with the varied parameter values. A ratio

*ε*of the number of incorrect active-state classifications to the total number of states which were active in both reference and comparison classification over the entire spatiotemporal map was given by the equation

where the square brackets denote Iverson brackets^{a}, **1** is the indicator function^{b}, *i* and *j* denote the sample and sensor number (horizontal and vertical position in the spatiotemporal map) respectively. A simplified state ${\u015d}_{j,i}\in \{\mathit{\text{ac}},\mathit{\text{ar}},\mathit{\text{ps}}\}$ is one of: active contraction *ac* = {*oimr*, *itc*, *act*}, active relaxation *ar* = {*itr*, *atr*}, or passive states *ps* = {*oimr*, *dipi*, *dipd*, *ps*, *pd*, *oq*, *dq*}. A simplified state in the comparison classification is denoted with a prime ${\u015d}_{j,i}^{\prime}$.

*ε*as parameter values vary (Figure 5) shows that the model is adequately robust to variations in the parameters, as the errors are qualitatively considered small. The test was performed on a 10-minute recording with 26 sensors of a single isolated rabbit colon which exhibited typical activity (for a combined 62400 samples in total).

## Results and discussion

Parameters of the hidden Markov model were chosen manually, giving robust results with respect to variations in the parameters, shown in Figure 5. The *γ* parameter specifying transition probabilities should be adjusted to account for variations in time sampling frequency, which was not required here as our data consisted entirely of 4 Hz sampling.

The states inferred by our method coincided with hypothesised states based on manual observation of orbital plots and the expected mechanical function of the colon. This allowed qualitative analysis of colon dynamics as given in the description of Figure 6(d)–(f). A more detailed description of these finding can be found in our previous paper [4].

## Conclusions

The use of the hidden Markov model to discriminate mechanical states of the intestinal muscle in an isolated preparation of the rabbit colon has given experimental neurogastroenterologists a novel powerful tool to identify the active and passive states of the intestinal muscle.

The graphic representation of where the active contractions and relaxations occur in the intestine at any particular time (Figure 6) will allow for the testing of many hypotheses currently proposed but not validated on the mechanisms responsible for the appropriate mixing and propulsive movements [4].

At the present the parameters described here have been shown to work with the rabbit distal colon. Whether or not the same criteria could be applied to different species with different sized diameters is still to be determined. It is likely that the parameter will need to be adjusted for each species (including human). We are currently setting up studies with different animal species to test this hypothesis.

## Endnotes

^{a} [P] = 1 if P is true, 0 if P is false.

^{b}**1**_{
A
}(*x*) = 1 if *x* ∈ *A*, and 0 otherwise.

## Declarations

### Acknowledgements

The work was supported by grants from the Australian Research Council (DP120102192), FMC research foundation and Clinician’s Special Purpose Fund of the Flinders Medical Centre.

## Authors’ Affiliations

## References

- Arkwright J, Dickson A, Maunder S, Blenman N, Lim J, O’Grady G, Archer R, Costa M, Spencer N, Brookes S, Pullan A, Dinning P: The effect of luminal content and rate of occlusion on the interpretation of colonic manometry. Neurogastroenterology Motil. 2013, 25: e52-e59. 10.1111/nmo.12051.View ArticleGoogle Scholar
- Everhart J, Ruhl C: Burden of digestive diseases in the United States part I: overall and upper gastrointestinal diseases. Gastroenterology. 2009, 136 (2): 376-386. 10.1053/j.gastro.2008.12.015.View ArticlePubMedGoogle Scholar
- Dinning PG, Arkwright JW, Costa M, Wiklendt L, Hennig G, Brookes SJ, Spencer NJ: Temporal relationships between wall motion, intraluminal pressure, and flow in the isolated rabbit small intestine. Am J Physiol-Gastrointest Liver Physiol. 2011, 300 (4): G577-G585. 10.1152/ajpgi.00532.2010.View ArticlePubMedGoogle Scholar
- Costa M, Wiklendt L, Arkwright J, Spencer N, Omari T, Brookes SJH, Dinning PG: An experimental method to identify neurogenic and myogenic active mechanical states of intestinal motility. Front Syst Neurosci. 2013, 7 (7): 1-18.Google Scholar
- Rabiner L: A tutorial on hidden Markov models and selected applications in speech recognition. Proc IEEE. 1989, 77 (2): 257-286. 10.1109/5.18626.View ArticleGoogle Scholar
- Mackiewicz M, Berens J, Fisher M: Wireless capsule endoscopy color video segmentation. Med Imaging, IEEE Trans. 2008, 27 (12): 1769-1781.View ArticleGoogle Scholar
- Xue H, Govindaraju V: Hidden Markov models combining discrete symbols and continuous attributes in handwriting recognition. Pattern Anal Mach Intell, IEEE Trans. 2006, 28 (3): 458-462.View ArticleGoogle Scholar
- Sinnott M, Cleary P, Arkwright J, Dinning P: Investigating the relationships between peristaltic contraction and fluid transport in the human colon using Smoothed Particle Hydrodynamics. Comput Biol Med. 2012, 42 (4): 492-503. 10.1016/j.compbiomed.2012.01.002.View ArticlePubMedGoogle Scholar
- Hennig G, Costa M, Chen B, Brookes S: Quantitative analysis of peristalsis in the guinea-pig small intestine using spatio-temporal maps. J Physiol. 1999, 517 (2): 575-590. 10.1111/j.1469-7793.1999.0575t.x.View ArticlePubMedPubMed CentralGoogle Scholar
- Wiklendt L, Mohammed SD, Scott SM, Dinning PG: Classification of normal and abnormal colonic motility based on cross-correlations of pancolonic manometry data. Neurogastroenterology Motil. 2013, 25 (3): e215-e223. 10.1111/nmo.12077.View ArticleGoogle Scholar

## Copyright

This article is published under license to BioMed Central Ltd. This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.