# Autonomous Prostate Segmentation in 2D B-Mode Ultrasound Images
## 3 Active Shape Prostate Contour Model
### Statistical Prostate Shape Model  
For the prostate segmentation algorithm, a 3D probabilistic shape model of the prostate will be created. This shape model is used to find the likelihood of the edge of the prostate being at a particular point. To generate the prostate shape model, a statistical distribution of the prostate contour locations is found by analysis of the prostate shape information contained in a number of 3D contour models from different patients (image sets). The resulting shape model characterizes the average prostate shape, and variance of the prostate shape, measured across a large number of 3D contour models. After fitting in (8), a particular 3D contour model, given an index \(m\), will be denoted by  
\[R(\theta,i|\mathbf{\beta}_{m})=R_{i}(\theta|\mathbf{\beta}_{i}) \tag{12}\]  
where \(\mathbf{\beta}_{m}\) contains the model parameters of all the slices, \(m_{nImg}\) for a particular prostate, such that \(\mathbf{\beta}_{m}=[\mathbf{\beta}_{0},\mathbf{\beta}_{i},...,\mathbf{\beta}_{m_{nImg}}]\). The probabilistic prostate shape model will incorporate many, \(n_{Model}\), 3D contour models from different patient TRUS images, and is created using linear interpolation of Gaussian distributions. The radius \(R\), from the 3D contour models, will be evaluated at a discrete number of \(\theta_{c}\) points to build the probability model for each slice. The probabilistic prostate shape model will then be in the same slice-based 3D form as the contour model, in the cylindrical coordinate system. Each Gaussian component of the shape model will be centred at \(\overline{\theta}=[\theta_{1},\theta_{2},...,\theta_{n_{\theta}}]\) points with the vector  
\[\overline{\theta}=\left[-\pi,-\pi+2\pi\frac{1}{n_{\theta}-1},-\pi+2\pi\frac{ 2}{\theta-1},...,-\pi+2\pi\frac{n_{\theta}-1}{n_{\theta}-1}\right] \tag{13}\]  
giving \(n_{\theta}\) points sampled at regular intervals in the range \((-\pi,\pi]\). The Gaussian normal distribution for a single point, \(\theta_{c}\), in contour slice \(i\), is  
\[p_{c}(r|\theta_{c},i)=\frac{1}{w_{(c,i)}\sqrt{2\pi\sigma_{(c,i)}^{2}}}\exp \left(-\frac{(r-\mu_{(c,i)})^{2}}{2\sigma_{(c,i)}^{2}}\right), \tag{14}\]  
where \(w_{c,i}\) is a normalization constant, \(\mu_{(c,i)}\) is the mean radius, and \(\sigma_{(c,i)}\) is the standard deviation for all of the shape model at the \(\theta_{c}\) point. Note that the \(\theta_{c}\) points are used for all slices of the shape model. The CDF of this distribution is given by  
\[ \begin{split} P_{c}(R\leq r|\theta,i)=\int_{0}^{r}p(r|\theta,i) dr-\int_{-\infty}^{0}p(r|\theta,i)dr\\ P_{c}(R\leq r|\theta,i)=\frac{1}{2}\Bigg{[}\text{erf}\Bigg{(} \frac{(r-\mu_{(c,i)})}{\sigma_{(c,i)}\sqrt{2}}\Bigg{)}-\text{erf}\Bigg{(} \frac{(0-\mu_{(c,i)})}{\sigma_{(c,i)}\sqrt{2}}\Bigg{)}\Bigg{]}\end{split}  \tag{15}\]  
where \(\text{erf}()\) is the error function, and the normalization constant is given by  
\[w_{(c,i)}=\frac{1}{2}\Bigg{[}1-\text{erf}\Bigg{(}\frac{(0-\mu_{(c,i)})}{ \sigma_{(c,i)}\sqrt{2}}\Bigg{)}\Bigg{]} \tag{16}\]  
such that the probability of \(P_{c}(0\leq R\leq\infty|\theta_{c},i)=1\) as desired. With this normalization constant, the mean and standard deviation of the radius at \(\theta_{c}\), across all \(n_{Model}\) contour models, are calculated by  
\[\mu_{(c,i)}=\frac{1}{n_{Model}}\sum_{m=1}^{n_{Model}}R(\theta_{c},i|\mathbf{ \beta}_{m}) \tag{17}\]and  
\[\sigma_{(c,i)}=\frac{1}{n_{Model}+1}\sum_{m=1}^{n_{Model}}\left(R(\theta_{c},i| \boldsymbol{\beta}_{m})-\mu_{(c,i)}\right)^{2} \tag{18}\]  
in the same manner as a standard Gaussian distribution. To find the contour edge probability for any value of \(\theta\) in the slice, linear interpolation between the two closest \(\theta_{c}\) distributions is used. For a point \(\theta\), let \(\theta_{c}^{-}\) be the closest \(\theta_{c}\) point that is less than \(\theta\) and \(\theta_{c}^{+}\) be the closest \(\theta_{c}\) which is greater than \(\theta\).