# Unsupervised Image Segmentation on 2D Echocardiogram
## 3 Methods
### Training Process  
Pre-Processing the Network Inputs  
The echocardiogram video dataset is first pre-processed to convert it into a format suitable for input into the deep learning model. The following steps describe this process:  
* Frame Selection: A subset of frames is extracted from each video sequence, ensuring they provide enough information for segmentation (frames in different phases of the cardiac cycle, EDV and ESV included). Since consecutive cardiac cycles within the same video exhibit minimal differences, increasing the number of frames significantly lengthens processing time without notable performance improvements.Therefore, selecting an appropriate number of frames that cover at least one complete cardiac cycle per video is sufficient for the training phase. * Pre-processing for Training: The selected frames are first resized to a resolution of 224 \(\times\) 224 to ensure uniform input size for the model. A series of transformations is applied to augment the data, including the random application of Gaussian blur with varying kernel sizes (3, 5, and 7) and sigma values (ranging from 0.1 to 2.0), as well as random rotations of up to 5 degrees. These transformations are applied with a probability of 0.5, adding variability to the training data to make the model more robust to noise and orientation changes. Finally, the frames are normalized using the mean and standard deviation values specific to the dataset, ensuring that pixel intensities are standardized for improved model performance. * Pre-processing for Validation and Testing: For validation and testing, only resizing to 224 \(\times\) 224 and tensor conversion are performed, without any additional augmentations, ensuring consistency in evaluation. To train, validate, and test our model, we used the EchoNet-Dynamic Dataset [7], with a total of 7465 training samples, 1288 validation samples, and 1277 test samples. Instead of using all frames from the videos, we opted to use 16 frames per video, which significantly improved both the training time and model performance. This decision was based on the comparison of models using 4, 8, and 32 frames, where the loss did not show significant improvement with either fewer or more frames Figure A2. Visual inspection further confirmed that the results with 16 frames provided more satisfactory segmentation, capturing key cardiac cycles effectively. Additionally, using 16 frames allowed us to perform a wider grid search for the optimal hyperparameters, as the training time per epoch averaged around 1 min (while if using 32 frames, we would exceed 20 min per epoch), making it more efficient than using 32 frames or more. This approach aligns with the findings in [7], which highlighted the impact of video length on model efficiency. To further enhance the quality of the data and minimize the number of samples used for training, we implemented a pre-processing pipeline that scored frames based on sharpness and contrast [18], utilizing techniques such as Contrast Limited Adaptive Histogram Equalization (CLAHE) for contrast enhancement and Laplacian variance for sharpness scoring. This allowed us to refine the dataset, before starting the actual pre-processing, by selecting the highest-quality videos for training, resulting in shorter training times and improved overall model performance. We assessed video quality using a range from 0 to 1, selecting only those videos with an average score of 0.8 or higher. As a result, out of 7465 training videos, 628 were selected based on this quality criterion. For the validation set, 118 out of 1288 videos met the threshold, and for the test set, 110 out of 1277 videos were selected. By focusing on these high-quality videos, we were able to ensure better training efficiency and performance [7]. The performance of CLAHE and Laplacian variance was evaluated through the calculation of a quality score for each video based on two key metrics: sharpness and contrast.