# Segmentation of Preretinal Space in Optical Coherence Tomography Images Using Deep Neural Networks
## 5 Experiment Design
### Training  
The goal of the segmentation task is to predict 4 separate areas in the image, further described as set of classes \(C=\{0\text{: }\mathit{Vitreous},1\text{: }\mathit{Preretinal Space},2\text{: }\mathit{Retina},3\text{: }\mathit{Space}\) under \(\mathit{Retina}\}\). The training network's task of multi-class classification is to assign each pixel of the image to one of these classes.  
Bearing in mind the specificity of preretinal space, we consider the possibility that the PCV line is not sufficiently visible throughout the scan or is partially connected to the ILM. In such a situation, using narrow patches could mislead the network. Hence, we input to the network an entire B-scan (e.g., gray-scale image) with the resolution of \(640\times 384\) px, what encourages a smoother layer surface across the image. In addition, each image before processing was subjected to a standard \(z\)-score normalization.  
All neural networks described in this paper were implemented using Python 3.7 with PyTorch 1.8.1 and NVIDIA CUDA 11.2 libraries. The experiments were conducted on a 64-bit Ubuntu operating system with an Intel Core i7-7700K 4.20 GHz computing processor and 32 GB RAM. The NVIDIA GeForce GTX 1080 Ti GPU card with 11 GB memory was used during training and evaluation.  
The CAVRI dataset was randomly split into training, validation, and testing subsets with the ratio of 80%, 10%, and 10%, respectively. The images in the training set were used to learn the neural network weights. The validation set was used at the end of each epoch to check the model's accuracy and validation loss. Finally, the test set contains images previously unseen by the network and is used to evaluate all segmentation methods.  
Using the PyTorch Lightning 1.3.5 library, we trained each network with an Adam optimizer and the following parameters: learning rate \(l_{r}=5\cdot 10^{-6}\), \(\beta_{1}=0.9\), \(\beta_{2}=0.999\). Due to the random cropping procedure used for data augmentation, which produces images of various sizes, the batch size was set to one. Each network was trained for at least 50 epochs, and the training was stopped if the validation loss did not decay for the last five epochs. Models were evaluated on the best checkpoint corresponding to the lowest validation loss value. It should also be noted that due to memory constraints, all networks were implemented with 32 initial feature vectors instead of the original 64. According to the initial experiments, this change, however, does not have a significant degrading impact on model accuracy. The hyper-parameters of the model (i.e., weights of the loss function, data augmentation techniques) were chosen experimentally, and the best values and techniques were used to obtain the presented results. The implementation code is available online at [[https://github.com/krzyk87/pcv_segmentation](https://github.com/krzyk87/pcv_segmentation)]([https://github.com/krzyk87/pcv_segmentation](https://github.com/krzyk87/pcv_segmentation)), (accessed on 5 November 2021).  
The graph search algorithm was implemented in the Matlab/Simulink environment [76] on a 64-bit PC workstation with Windows 10 operating system, Intel Core i7-3770 3.40 GHz processor, and 8 GB RAM.