# Autonomous Prostate Segmentation in 2D B-Mode Ultrasound Images
## 3 Active Shape Prostate Contour Model
### 3D Prostate Contour Model Fitting  
To evaluate the proposed contour model, a constrained least-squares optimization will be used to fit manually segmented prostate contour points to the model. While the model is defined with respect to the prostate in a single image slice, \({}^{P}\mathcal{I}_{i}\), the model fitting optimization incorporates information from the entire patient dataset, where all \(nImg\) slice-based contours in \({}^{P}\mathbf{I}\) will be used. Each slice's contour will be represented through a model, \(R_{i}(\theta)\), with the parameters of the model being estimated for that particular slice. By evaluating the goodness-of-fit for all of the slice models across the patient image set, an optimal, patient-specific, centre point and rotation offset for the model will found. Contour points of the prostate, segmented by the clinician, are given in the point vector form described by (1). For contour fitting, a rotation offset \({}^{P}\phi_{c}\) is considered. This rotation offset aims to reduce any fitting artefacts caused by the chosen constant \(\phi_{j}\) values in the model and allows multiple prostate contours to be easily compared, which will be important when creating the statistical shape model. As the model is formulated in  
Figure 2: Ultrasound axial image slices being taken during the preplanning phase of prostate brachytherapy. Each axial slice is taken 5 mm apart as the probe is translated along the z-axis. cylindrical coordinates, the prostate contour points, for image slice \(i\), are defined in terms of the patient-attached frame and must be transformed by  
\[\vec{\theta}_{i} =\text{atan2}(\,^{P}\vec{y}_{i}-\,^{P}y_{c},\,^{P}\vec{x}_{i}-\,^{P}x _{c})-\,^{P}\phi_{c}\] \[\vec{r}_{i} =\sqrt{(\,^{P}\vec{y}_{i}-\,^{P}y_{c})^{2}+(\,^{P}\vec{x}_{i}-\,^{P }x_{c})^{2}} \tag{4}\] \[\vec{z}_{i} =\,^{P}\vec{z}_{i},\]  
with \(\,^{P}\vec{x}_{i},\,^{P}\vec{x}_{i}\), and \(\,^{P}\vec{z}_{i}\) being the clinician-segmented points; the values of \(\,^{P}x_{c},\,^{P}y_{c}\), and \(\,^{P}\phi_{c}\) come from the augmented centre point vector, and \(\vec{\theta}_{i},\,\vec{r}_{i}\), and \(\vec{z}_{i}\) are the transformed contour points. The individual elements of the transformed contour point vectors are given by  
\[\vec{\theta}_{i} =\,[\theta_{(0,i)},\theta_{(1,i)},...,\theta_{(n_{P},i)}]\] \[\vec{r}_{i} =\,[r_{(0,i)},r_{(1,i)},...,r_{(n_{P},i)}] \tag{5}\] \[\vec{z}_{i} =\,[z_{(0,i)},z_{(1,i)},...,z_{(n_{P},i)}],\]  
with each \(\left\{\theta_{(v,i)},r_{(v,i)},z_{(v,i)}\right\}\) set of points being mapped from the set \(\left\{\,^{P}x_{(v,i)},\,^{P}y_{(v,i)},\,^{P}z_{(v,i)}\right\}\) of contour points. The parameters of the model are denoted by \(\beta_{i}=[\alpha_{0},\alpha_{1},...,\alpha_{n_{\omega}}]\) and are found through the least squares optimization  
\[\underset{\beta_{i}}{\text{argmin}}\left\|\vec{r}_{i}-R_{i}(\vec{\theta}_{i}| \beta_{i})\right\| \tag{6}\]  
where \(R_{i}(\vec{\theta}_{i}|\beta_{i})\) is the model, incorporating parameters \(\beta_{i}\), and the optimization is constrained, such that  
\[R_{i}(\vec{\theta}_{i}|\beta_{i})>0,\,\,\forall\,\,-\pi\leq\theta<\pi, \tag{7}\]  
holds for the fit \(\beta_{i}\) parameters. A second least-squares optimization will be performed in order to find the optimal augmented centre point, \(\,^{P}c=[\,^{P}x_{c},\,^{P}y_{c},\,^{P}\phi_{c}]^{\top}\), for fitting the 3D model. The augmented centre point corresponds to the centre point of the prostate for each patient. Having an optimal \(\,^{P}c\) allows for the prostate shape model to be found directly, as finding \(\,^{P}c\) removes the relative translation and rotation between two prostate contours in different image sets. Here, the parameters to be optimized are \(\beta_{c}=[\,^{P}x_{c},\,^{P}y_{c},\,^{P}\phi_{c}]\).