# Diabetic Macular Edema Characterization and Visualization Using Optical Coherence Tomography Images
## 2 Materials and Methods
### Map Generation  
After the candidate models were trained for each type of DME and we had our chosen classifiers, we can now proceed to use them to generate the intuitive visualizations and characterizations of the DME types. These maps are generated by thoroughly sampling OCT images. The first step, as mentioned, consists in extracting the ROI from the image and completely dividing it into samples of a given size. These samples are extracted all centered inside the ROI, equally spaced and with a previously configured overlap (the higher the overlap, the higher the granularity the maps will have). The same way as in the training process, if any sample falls outside the ROI albeit being centered in it, the biggest rectangular subsample that contains only relevant patterns is extracted from these samples. From each of these samples, then, three feature vectors are generated. Each feature vector corresponds to the descriptors the feature selection technique considered important to classify each different type of DME during their respective training steps. By doing so, we can obtain a matrix composed by three feature vectors (one for each type of DME and optimal features defined by the SFS algorithm for each class). These classifications are used by two different complementary algorithms, the _Confidence map_ and the _Binary map_. Finally, when the two types of maps are generated, its information is used to generate an intuitive visualization of the detection and characterization of the different ME types to facilitate their inspection by the specialists. This visualization consists in a 5-window representation of different points of view of the detections with two main representations:  
* The \"CONFIDENCE\" window shows a merged representation of all the pathology confidences and the interactions between them. This window allows experts to study the possible overlap between the types of pathology that cannot be achieved through segmentation. In addition, it clearly presents the interactions that cannot be observed in the windows of the other types on their own. With this same idea (displaying the confidence on the detections), the 3 right-sided windows show, independently, each of the confidences given by the confidence map algorithm, but using a color map with a higher degree of granularity (so an expert clinician can see the nuances between in the confidence levels). * The \"DETECTIONS\" window represents all the detections, without displaying the confidence the system infers in them. This allows the experts to have a different perspective of the detections,showing a more explicit representation of the independent regions that have tested as positive (as well as an interpolation of the surrounding regions that may also be candidates). In doing so, it complements the information shown in the \"CONFIDENCE\" window. To create the confidence map, we use the windows as ballots to calculate the confidence of the overlapped area of belonging to a given positive class. As an example, in Figure 7b, a representation of the overlapping windows in a given image with multiple pathological positive samples is shown. Each sample that overlaps a pixel increases in one the number of \"ballots\", finally generating a map of the number of votes per pixel. Depending on the morphology of the retina, overlap and certain regions close to the image borders, the weight of each vote over the total is different (that is, in some regions, the number of windows that overlap an area is lesser than in the internal ones; thus increasing the relevance of each ballot for the final confidence value). This effect can be seen in Figure 7c, where the ROI borders present less intensity than other areas with (in reality) similar confidence levels. To compensate for this difference, the results are normalized dividing by the total number of windows that contained each pixel (Figure 7c vs. Figure 7d). Moreover, as the system supports images of any size, some rounding errors may appear depending on the width and height of the image when sampling.