## 2 Methodology
### Training Res U-Net  
The Res U-Net model was trained using 214 CT scans from the VerSe'20 dataset, which provided a comprehensive and diverse set of images, crucial for achieving high model accuracy. The training data were split into 171 scans for training (80% of the dataset) and 43 scans for validation (20% of the dataset). During training several hyperparameters were optimized, such as learning rate and batch size, as well as the number of epochs. Data augmentation techniques, including rotation and scaling along with flipping, were employed to enhance the model's robustness and generalization capabilities. The validation strategy involved monitoring the Dice Similarity Coefficient (DSC) and other performance metrics. The model was validated using both the VerSe'20 dataset and a separate dataset of 25 patient scans collected from Kasturba Medical College. These datasets represent a wide range of anatomical and imaging variations, ensuring that the model is robust across different clinical settings. The validation strategy involved monitoring the Dice Similarity  
Figure 2: Architecture of the Res U-Net model for vertebrae segmentation. The model includes Convolutional Blocks (CA Blocks), Max-Pooling Layers for down-sampling, Up-Convolution Layers for up-sampling, and a Hierarchical Dense Aggregation (HDAC) Layer for efficient multi-scale feature aggregation. Input CT scans with a resolution of 512 \(\times\) 512 pixels are processed through this network to generate segmented images. Coefficient (DSC) and other performance metrics to prevent overfitting and ensure stable and consistent model performance across different datasets. The network is trained using input images and their corresponding segmentation maps. The unpadded convolutions result in the output image being smaller than the input by a fixed border width. To maximize GPU memory efficiency, we use large input tiles and reduce the batch size to a single image. Maintaining a momentum value of 0.99 allows numerous previously encountered training samples to impact the current optimization process. The energy function is determined by applying a pixel-wise softmax operation on the final feature map and integrating it with the cross-entropy loss function. The softmax function is expressed as:  
\[\mathbf{p_{k}}(\mathbf{x})=\frac{\mathbf{exp}(\mathbf{a_{k}}(\mathbf{x}))}{\sum_{\mathbf{k}^{1}=1}^{ \mathbf{K}}\mathbf{exp}(\mathbf{a_{k^{1}}}(\mathbf{x}))} \tag{1}\]  
where \(\mathbf{a_{k}}(\mathbf{x})\) represents the activation in feature channel \(\mathbf{k}\) at pixel position \(\mathbf{x}\). \(\mathbf{K}\) is the number of classes and \(\mathbf{p_{k}}(\mathbf{x})\) approximates the maximum function. The cross entropy penalizes the deviation of \(\mathbf{p_{l(x)}}(\mathbf{x})\) from \(1\) at each position using:  
\[\mathbf{E}=\sum\
olimits_{\mathbf{x}\in\mathbf{\Omega}}\mathbf{w}(\mathbf{x})\mathbf{log}(\mathbf{p_{l(x )}}(\mathbf{x}))\,. \tag{2}\]  
Here, \(\mathbf{\ell(x)}\) denotes the true label of each pixel, and \(\mathbf{w(x)}\) represents a weight map assigning different importance levels to certain pixels during training. To balance class frequencies within the training dataset and assist the network in distinguishing the small borders between adjacent cells, we pre-calculate the weight map for each ground truth segmentation. Proper initialization of weights is essential for deep networks with numerous convolutional layers and various paths. The initial weights need to ensure that each feature map in the network maintains approximate unit variance. This is accomplished by selecting initial weights from a Gaussian distribution with a standard deviation of \(\sqrt{\frac{2}{N}}\) where \(\mathbf{N}\) is the number of incoming nodes for a neuron. Figure 3 illustrates the training accuracy of the Res U-Net model over multiple iterations for three different datasets. Three different datasets were used to evaluate the training accuracy of the Res U-Net model.