# Detection of Pediatric Femur Configuration on X-ray Images
## 2 Materials and Methods
### Training Stage: CNN Estimator  
The CNN estimator is designed to detect the positions of three keypoints \(\mathbf{k}_{1}\), \(\mathbf{k}_{2}\), and \(\mathbf{k}_{3}\). Those keypoints correspond to PS, which is located in the less salient region of the X-ray image. The correctly designed estimator should assign keypoints in the positions of the manually marked keypoints. For example, for every image frame, the expected output of CNN is given by  
\[\mathbf{\varphi}=[\mathbf{k}_{1}\;\mathbf{k}_{2}\;\mathbf{k}_{3}]^{\top}\;\in\mathbb{R}^{6}. \tag{6}\]  
First, X-ray images with corresponding keypoints described in the previous section were preprocessed to constitute valid CNN data. The work-flow of this part is presented in Figure 6. Note that, all of the presented transformations are conducted simultaneously on images and corresponding keypoint positions. Thus, keypoints reflect the configuration of PS on the source image. As a first stage, due to the small dataset size, the original data were augmented with typical image transformations (rotation, translation, scale, reflection, contrast change [26]). Second, image frames were cropped to size 178 \(\times\) 178 px. The smaller resolution was selected as a trade off between hardware requirements (memory limitation) and minimizing the loss of information. The example of cropping operation is presented in Figure 7a. The position of the cropping window was chosen randomly with the assumption that it contained all of the keypoints. The third step consists of shuffling data to avoid local minima in the learning process. Note that, after shuffling, the input and output pair remains the same. Finally, the images are normalized to unify the significance of each input feature on the output. The learning data are sequentially divided between the train and development sets, as described in Table 1. Note that images of one subject constitute exclusively one of the sets. To evaluate the performance of CNN architecture, a separate test set is formed. In this study, a slice of the publicly available LERA dataset [3] is used, consisting of knee joint images in the lateral view. The whole dataset consists of 182 images of different joints of the upper and lower limb, collected between 2003 and 2014. Note that the dataset includes radiographs varying in size and quality; therefore, a proper preprocessing and standardization of resolution is needed. Figure 6: Generation of CNN learning sets. This study focuses on classic feedforward networks, i.e., without feedback connections. It is assumed that the values of the weights and biases are trained in the stochastic gradient descent learning process. The chosen optimization criterion is given by mean squared error value  
\[L\triangleq\widehat{\mathbf{\varphi}}^{\top}\widehat{\mathbf{\varphi}},\quad\widehat{ \mathbf{\varphi}}\triangleq\widehat{\mathbf{\varphi}}-\mathbf{\varphi}, \tag{7}\]  
where \(\widehat{\mathbf{\varphi}}\) is the estimated output of CNN and \(\mathbf{\varphi}\) is the expected output of CNN given by Equation (6). Note that, contrary to most medical image oriented CNN scenarios, here CNN is designed to solve regression task, i.e., keypoint coordinates are given in real numbers. Importantly, the loss function (7) gradient is calculated with a modified backpropagation process, i.e., ADAptive Moment estimation [27]. Due to the large complexity of the considered problem, CNN architecture, as well as learning parameters, will be optimized. The optimal network architecture, among different possible structures, will ensure the lowest loss function value (7). The optimization procedure is described in Appendix A. We acknowledge that collected datasets (Table 1) are limited in size. Nevertheless, we are convinced that proper regularization will assure an appropriate learning process. Following the work presented in [26], we have applied:  
1. \(L_{2}\) Regularization: enforcing a sparsity constraint on CNN parameters;
2.