## 2 Materials and Methods
### Cyst Detection and Motion Artifacts Elimination Algorithm
Appendix A shows an example of how a different threshold value impacts the final classification. Figure 2: Example of two enface structural and two enface flow SCP and DCP images. (**A**) SCP image containing only cysts. (**B**) DCP image containing both cysts and a motion artifact. The biggest cysts are highlighted by blue boxes, while the motion artifact by a red box. (**C**) enface flow image corresponding to the enface structural image A. (**D**) enface flow image corresponding to the enface structural image B. The next step concerns the elimination of isolated pixels, eventually due to noise. This task is performed by applying an image erosion followed by an image dilation with a suitable structuring element (lines 3-4). In this case, the structuring element has been chosen after several experiments, which indicated a square of size \(2\times 2\) as the best structuring element. The output produced by these phases is shown in Figure 3, considering as input the same images shown in Figure 2.  
By analyzing the outputs shown in Figure 3, it is possible to distinguish between two main cases. In the first case, when the input image does not present motion artifacts, the output of the first two phases is sufficient to correctly identify the cyst area (Figure 3B). On the other hand, if the input image contains a motion artifact, the output does not highlight just the cysts, since the motion artifact also appears as a black area. To identify and remove these artifacts, the algorithm searches the horizontal long lines which characterize the superior and inferior edges of the motion artifact, employing the Canny filter (line 5) to enhance the detection quality [17]. This filter searches for local maxima in the image gradient, which is computed using a second derivative of the Gaussian filter. The authors chose this filter since it performs non-maximum suppression on the image gradient, in order to delete spurious edges. The remaining maximum values in the gradient images are then processed with the double threshold method [18]. Finally, the edges are tracked through the hysteresis method. The obtained image is then elaborated through the Hough transform (line 6), which finds all the line-shaped edges. However, this does not mean that all those edges are related to a motion artifact. In fact, some cysts can have edges with shapes similar to a line, and can be identified by the Hough transform as lines. In order to avoid the misclassification of these edges, authors performed several experiments in order to identify suitable thresholds, to discriminate between the edges related to the motion artifacts and those related to the cysts. In particular, the characteristics that can discriminate between two kinds of edges are the slope and the length of the lines. Analyzing the dataset, authors noticed that motion artifacts are horizontal bands that occupy almost one third of the image. Therefore, we defined suitable thresholds for the line's slope and length. In particular, the images analysis showed that the shortest motion artifact extends for approximately 1 mm of length, while the longest one extends for the whole image length (3 mm). Therefore, authors chose to set the length threshold to 1 mm, which is one third of the image length. Only the lines with the correct slope and lengths are considered as motion artifact edges (lines 7-11). An example of typical edges in a motion artifact is shown in Figure 4, where the lines obtained with the proposed method are highlighted in green. At this point, the algorithm checks if the previous step has found edges related to motion artifacts. If it has, the motion artifacts are eliminated from the image by the forcing to the white value of the pixel included between the edges. Otherwise, no modifications are applied to the image (lines 12-16). Figure 4: Edges of the motion artifact detected through the proposed method. The lines obtained with the proposed thresholding method are highlighted in green. Figure 3: Inputs and outputs of the first two phases.