# Autonomous Prostate Segmentation in 2D B-Mode Ultrasound Images
## 3 Active Shape Prostate Contour Model  
For planning in a clinical prostate brachytherapy procedure, a series of ultrasound images are taken as a transrectal ultrasound (TRUS) probe is translated forward along the z-axis (towards the head of the patient); see Figure 2. The prostate images are taken at regular distances apart to obtain a 3D volume and shape of the prostate. The goal of this work is to automate the 3D prostate contouring process through segmentation of the prostate in all of the TRUS image slices, \({}^{P}\mathbf{I}_{i}\) for a particular patient. Each TRUS image, denoted by \({}^{P}\mathcal{I}_{i}\), within the image set captures an axial slice of the prostate (in the \({}^{P}x\)-\({}^{P}y\) plane). The image set is described in terms of its placement and size in the patient attached frame, \(\{P\}\), with distances measured using millimetres. Each axial image slice is taken at a depth \({}^{P}z_{i}\), where, for the patient image sets used in this work, the slices are spaced at 5 mm intervals. The placement of the patient-attached coordinate frame \(\{P\}\) is chosen such that the first image in the set \({}^{P}\mathcal{I}_{0}\) is located at \({}^{P}z_{0}=0\). When using axial US images to create the surgical plan, planning software allows the clinician to select points in each axial TRUS image which correspond to the edge of the prostate, thereby contouring the prostate. This prostate contour can, in general, be represented by a polygon that comprises a number of vertices, \(p_{(v_{j})}=[\,^{P}x_{(v_{j})},\,^{P}y_{(v_{j})},\,^{P}z_{(v_{j})}]^{\top}\), with \(v\) being an index for the vertices, in the axial image slice \(i\) (from the index of the TRUS image \({}^{P}\mathcal{I}_{i}\)). For each axial slice, the polygon can be represented by the vectors  
\[ \begin{split}\vec{x}_{i}&=[\,^{P}x_{(0,i)},\,^{P}x _{(1,i)},...,\,^{P}x_{(n_{v},i)}]\\ \vec{y}_{i}&=[\,^{P}y_{(0,i)},\,^{P}y_{(1,i)},...,\,^{P }y_{(n_{v},i)}]\\ \vec{z}_{i}&=[\,^{P}z_{(0,i)},\,^{P}z_{(1,i)},...,\,^{P }z_{(n_{v},i)}],\end{split}  \tag{1}\]  
where \(n_{v}\) is the number of the vertices in the polygon. The position point vector is defined in terms of the patient-attached frame, \(\{P\}\), and can be converted, for a particular image slice \(i\), to the pixel locations in the US image frame, denoted by \(\{U\}\), where the full set of image slices taken for a particular patient is given by \({}^{U}\mathbf{I}=\{\,^{U}\mathcal{I}_{0},\,^{U}\mathcal{I}_{1},...,\,^{U} \mathcal{I}_{nImg}\}\), and consists of a number, \(nImg\), of image slices taken at depths \({}^{P}d=\{\,0\,\text{mm},5\,\text{mm},...,\,nImg\cdot 5\,\text{mm}\}\), where \({}^{P}z_{i}\) is the \(i\)-th element of \({}^{P}d\). To smooth out the point-based contour, we propose a model which describes the shape of the prostate in an axial TRUS image. For each image slice \(i\), the prostate contour model, \(R_{i}(\theta_{i})\), describes the radius of a curve, within the cylindrical coordinate system, as a weighted sum-of-sines (a finite-length Fourier series). The general form of the model is given by  
\[R_{i}(\theta)=\alpha_{0}+\sum_{j=1}^{n_{\omega}}\alpha_{j}\sin(j\theta+\phi_{ j}), \tag{2}\]  
where \(n_{\omega}\) is the number of sine components in the model, \(j\) controls the frequency of sine components in the model (\(j=[1,2,...,n_{\omega}]\)), \(\alpha_{0}\) is a positive constant (\(\alpha_{0}>0\)), the \(\alpha_{j}\) terms weight the magnitude of each of the sine functions, and the \(\phi_{j}\) terms are phase offsets for the sine functions. The model consists of a number of modes, where the \(j\)-th mode refers either to the constant, \(\alpha_{0}\) for mode 0, or weighted sine component of the model (\(\alpha_{j}\sin(j\theta+\phi_{j})\)). In the patient frame, the model describes the curve  
\[ \begin{split}{}^{P}x_{i}&=R_{i}(\theta)\cdot\cos( \theta)+\,^{P}x_{c}\\ {}^{P}y_{i}&=R_{i}(\theta)\cdot\sin(\theta)+\,^{P}y_ {c}\\ {}^{P}z_{i}&=\,^{P}z_{i},\end{split}