Algorithm of segmentation of OCT macular images to analyze the results in patients with age-related macular degeneration

Ibragimova RR1, Gilmanov II2, Lopukhova EA2, Lakman IA1,2, Bilyalov AR1, Mukhamadeev TR1,3, Kutluyarov RV2, Idrisova GM1,3
About authors

1 Bashkir State Medical University, Ufa, Russia

2 Ufa State Aviation Technical University, Ufa, Russia

3 Optimedservice, Ufa, Russia

Correspondence should be addressed: Rada R. Ibragimova
Lenina, d. 3, Ufa, 450008, Russia; ur.xednay@6102adar.avomigarbi

About paper

Financing: the study was partially conducted as part of the State Assignment of the Ministry of Education and Science of the Russian Federation for the Ufa State Aviation Technical University (code of scientific assignment #FEUE-2021-0013, agreement № 075-03-2021-014) at the scientific research laboratory named ‘Sensor systems based on appliances of integrated photonics’ (sections ‘Materials and methods’, ‘Study results’, ‘Discussion of results’) and as part of the project backed by subsidies in the area of science taken from the budget of the Republic of Bashkortostan to ensure state support of scientific research conducted under the guidance of the leading scientists (НОЦ-РМГ-2021, agreement with the Ufa State Aviation Technical University) (Introduction section).

Author contribution: Ibragimova RR — review of literature, data acquisition and analysis, writing an article; Gilmanov II — development of software, searching a database, testing the existing code components; Lopukhova EA — development of software, writing an article, data acquisition and analysis; Lakman IA, Mukhamadeev TR, Kutluyarov RV — study concept and design, scientific editing; Bilyalov AR — scientific editing; Idrisova GM — data analysis, scientific editing.

Compliance with ethical standards: the study was performed in accordance with the principles of Declaration of Helsinki; all patients signed voluntary informed consent to OCT.

Received: 2022-11-03 Accepted: 2022-12-03 Published online: 2022-12-27

Age-related macular degeneration (AMD) is one of the main causes of loss of sight and hypovision in people aged 50 and over [13]. An annual growth of patients with this pathology is noted due to an increased expectation of life and upgrading the methods of diagnostics [4, 5]. Thus, based on prognosis of the World Health Organization, a number of people with AMD will be increased by 1.2 times from 2020 to 2030 (from 195.6 to 243.3 million of people) [6].

There exist various classifications of AMD: we differentiate between dry (non-exudative and atrophic in the late stage) and wet (exudative or neovascular) forms of AMD [7, 8]. According to the Age-Related Eye Disease Study (AREDS), an early, intermediate and late stages of age-related macular degeneration have been identified [9]. Based on literature data, in 10–20% of cases the non-exudative form of disease is transformed into the exudative one; in other cases, the course is slowly progressing and results in a geographic atrophy [1012]. Specific treatment of dry AMD is currently lacking, and the emphasis is on prevention measures [13]. Wet AMD leads to rapid and irreversible loss of central vision. Intravitreal injections of vascular endothelial growth factor (VEGF) inhibitors improve vision and reduce the possibility of blindness in wet AMD [14]. However, treatment success depends on many factors, one of which being modern diagnostics of the disease [3]. Optical coherence tomography (OCT) acquired the most widespread use both in clinical trials, and in real practice as a means of diagnostics and monitoring of patients with AMD [1516]. It is highly informative, contactless and allows to estimate the architecture of eye structures and retina, in particular, in real time [17]. A growing number of patients with this pathology is accompanied by an increased need in OCT studies, improved capacity of medical institutions and improved quality of the method.

Analysis and interpretation of large amounts of data is one of the issues [18, 19]. It can be solved using artificial intelligence (AI). AI intelligence becomes a perspective trend in diagnostics of ophthalmological diseases [20]. Thus, machine learning can be used to detect peculiarities of retinal tissue structure to evaluate the changes in it [21], detect vascular plexuses [22] and such retinal lesions as intraretinal cysts or subretinal fluid [23]. Methods of deep learning have recently become popular in the sphere of computer vision and are now included into the area of retinal image analysis. The methods of detecting retinal disease based on isolated biomarkers have gained special recognition; it enables close imitation of visual analysis by an expert and makes verification of a classifier easier [2430]. Latest studies in the area of integration of recommendation systems in ophthalmology reveal brilliant results regarding less time spent on diagnostics and influence of a human factor on the process of doctors’ working [31, 32]. These systems were operated based on the intellectual algorithms similar to previously available ones, which proves relevance of the search and development of new algorithms that could be used to determine the signs of AMD of various stages on OCT images with high sensitivity and specificity.

The purpose of the research is to develop an algorithm of segmentation to analyze macular OCT data in patients with AMD, that enables proper prediction of an AMD stage based on the form of extracted pathologies.


To solve the set task, supervised learning was used. During this training, the intellectual algorithm compares incoming and expert-labeled data increasing the generalization ability for unknown examples. At the stage of formation of three samples (training, validation and test ones), it was decided to use the database obtained during a standard ophthalmological examination and macular OCT using Avanti XR (Optovue; USA) and REVO NX (Optopol; Poland) at Optimed Center for Laser Eye Surgery (Ufa, Russia). Direct formation of a data set made it possible to regulate the parameters of the ratio of classes (stages) of the disease, gender and age-related distribution of patients and concomitant diseases, and a number of produced biomarkers, resulting in analysis of working algorithm outcomes in the presence of formerly known peculiarities of a set of OCT images. Incoming data included OCT macular images of 125 patients (197 eyes) with 89 women and 36 men having a mean age of 74.88 years (40–97). Inclusion criteria: patients with early (32%), intermediate (26%) and late (42%) stages AMD with sufficient transparency of optical media. Exclusion criteria: presence of diabetic retinopathy, retinal vessel occlusion; pachichoroid diseases; pathology of vitreomacular interface; and myopic choroidal neovascularization. The obtained set of OCT images consisted of training, validation and testing samples that account for 80, 10 and 10% respectively. Python programming language was a tool to develop an algorithm of image classification and formatting using TensorFlow and Pytorch libraries. Predictors of AMD stages were searched using the convolutional neural network segmenting the eye pathology. The operation principle of this neural networks was based on multi-layered successive convolution of an image with filters, whereas weight coefficients are selected while training an algorithm. These filters are intended to mark various image-located forms and textures in accordance with the principle of cerebral cortex operation having small parts of cells sensitive to certain areas of the field of vision. UNet initially created for segmentation of biomedical images was selected as architecture of a convolutional neural network. This architecture implements not only a slow increase of numerous signs (a tensor) that characterize the incoming image using four layers of convolution with filters and compression in encoder. It also preserves data related to their localization on the image by adhesion to parallel layers of convolution and use of operations reverse to file compression in a decoder.

ReLu was used as a function of activation. It provided qualitative training of a model using a relatively low amount of incoming data. OpenCV library was selected to ensure the best indicators of image processing and noise clearance.

To solve the issue of overfitting, several approaches were reviewed. Transfer learning, when the applied network is previously educated using a large set of data, is a popular method in this context [3335]. However, it should be taken into account that the biomarkers marked on an OCT image will have little correlation with entities produced by networks trained using common databases such as ImageNet. This can make the method less effective [36, 37]. Using methods of attention concentration is another approach that reduces the probability of network overfitting. For this, a block of attention was added to the neural network structure following every convolution layer. This block included searching of key points of the outcome of the layer process and increase of nearby values of network-processed tensor elements, on one hand, and a method of searching the adaptive limit value of tensor elements, on the other hand.

Classification based on segmented data was done by calculating the area of the largest pathologies of the same nature. The limit values were determined taking into consideration clinical signs of AMD by the size of concomitant pathologies [9].

It was estimated whether an AMD stage was classified properly based on the automatic recognition of OCT images and analysis of the nine-field coupling matrix, which is a matrix that provides correspondence between the actual and predicted AMD stages (early, intermediate, late). Three four-field coupling matrices developed using the principle of prediction of one AMD stages only were obtained. Thus, values of specificity and sensitivity for every AMD stages were calculated for every matrix. Sensitivity means a percentage of properly predicted cases of a certain stages of AMD, whereas specificity is a percentage of properly predicted cases not related to the AMD stages.

Weighted sensitivity (Sew) and specificity (Spw) of the entire classification algorithm were calculated using definite values


where Se1, Sр1 mean sensitivity and specificity of early AMD recognition; Se2, Sр2 denote sensitivity and specificity of late AMD recognition; Se3, Sр3 mean sensitivity and specificity of intermediate AMD recognition; n1 means a number of cases with early AMD; n2 means a number of cases with late AMD; n3 means a number of cases with intermediate AMD, where n = n1 + n2 + n3.


To develop a recommendation system determining AMD stages, an approach imitating a visual analysis made by an expert was selected. When it is used, position and form of disease pathologies can be found on an OCT image and they can be compared with a previous diagnostic experience. At the stage of detecting pathologies, the key issue consists in transfer of an expert’s experience in its differentiation with an intellectual algorithm. As use of methods of deep learning displays its effectiveness and immunity to the variety of incoming information only in the presence of a sufficient scope of the training samples, which is proportional to the algorithm complexity [38], a set of marked OCT images is required. Its generation is a resource-intensive task.

To avoid the limitation in the structure of UNet segmenting neural network, it was decided to include a block of additional treatment of a set of signs from an output of the convolution layer. This is how data about pathology contours were preserved, which could be reduced to the neural network attention concentration. The presented approach enables to decrease the complexity of the applied neural network algorithm by reducing a number of educated values while preserving exactness in a training sample. Effectiveness of the attention concentration approach was estimated by comparing the exact determination of segmented abnormal area borders using test data and analysis of class activation maps of abnormal retinal parts of UNet coder that visualizes the key areas of the images used for segmentation of this predictor.

During training of the neural network with a set of data formed by the authors with no involvement of the attention concentration block into UNet, the segmentation results amounted to 58.7% of properly segmented abnormal areas. The class activation maps presented in fig. 1A, display little concentration of attention on AMD signs. This is how low accuracy of pathology borderlines can be explained.

When selecting an algorithm of the attention concentration block it has been taken into account that retinal layers on OCT images have a properly marked difference in shades of gray. Deformation of pigmented epithelium and neuroepithelial edema are clearly seen. These shades, considering their difference in size during different stages of the disease, can be revealed by finding scale-invariant key points with ScaleInvariant Feature Transform (SIFT) [39]. They denote edges and angles and deformity margins on the image using the method of searching the adaptive limit value (SALV). The method proved to be effective while detecting pathologies [40].

The SIFT approach with a fixed lower threshold of key point scope, equal to the minimal sizes of drusen found in early stages of AMD [9] enabled to improve exactness of abnormal segmentation to 76.7%. However, the attention concentration block helps find key areas not related to pathologies (fig. 1B), decreasing the concentration of the neural network.

While using the attention concentration block based on the SALV method, accuracy of properly segmented abnormal areas was achieved in 98.1% of cases. Owing to the method, the entire attention of the neural network was concentrated on drusen (fig. 1C). When the rate of occurred pathologies was changed from equally likely to statistical [10, 11], exact detection of neuroepithelial edema was reduced by 15%. Thus, to increase effectiveness, a conclusion was made that distribution of all pathologies on the training sample should be regular.   

Segmentation results for predictors of dry intermediate AMD using the latest version of attention concentration block are well shown on fig. 2. Hard and soft drusen of Bruch’s membrane that deform the pigmented epithelium (displayed in arrows) are visualized on OCT macular images (fig. 2A). The layers that correspond to structural elements of photoreceptors are above the drusen. The internal layers of neuroepithelium are clear and not deformed. Foveolar deepening has a proper configuration. In fig. 2B these areas are segmented using the algorithm where the deformed pigmented epithelium is shown in yellow, just like the orange layers above the drusen. 

Retinal thickness is increased due to cystic edema of neuroepithelium (green arrow), local elevation of pigmented epithelium probably occurring due to the hidden neovascular membrane (red arrow) with accumulation of hyporeflective content found under the neuroepithelium (yellow arrow). The fovea is concave. On fig. 3B neuroepithelial edema is highlighted in dark red, elevation of pigmented epithelium in orange, and fluid accumulation under the neuroepithelium in blue. Predictors of late AMD are shown on fig. 3A. 

Automatic classification of AMD stages was done based on the obtained results, and values of specificity and sensitivity for each stage were calculated as well (table). Based on the acquired values, the weighted values of sensitivity and specificity of a stage classifier (Sew = 0.838 and Spw = 0.849) were calculated. 


The presented results were obtained while using OCT images from tomography scanners of several manufacturers. This produced a significant effect on accurate operation of segmentation algorithm due to differences in data visualization. Owing to specific block attention concentration methods when various labeling of OCT images is provided along with predictors, it is necessary to implement additional training of the recommendation system using new examples or remove the mentioned data. In this case, preliminary treatment of images can be required.

It should also be noted that the obtained forms of segmented areas will differ depending on the disease presence and stage. The data contain predictors needed for detection and determination of an AMD stage by the recommendation system. However, in some cases the limits of the ratio of abnormal area shape and proper diagnosis in an expert opinion can be rather blurred due to individual features of the disease course in a patient and in a different selection of eye radial scanning images.

Thus, a fully connected layer, which is the most frequently applied in computer vision tasks with neural networks, as a classifier of AMD stages will also require an extensive training sample to provide the indistinct borders. Considering statistics about an irregular frequency of AMD stage determination [10, 11], the task can’t be solved easily. Same conclusions will be just for the limit values of AMD stage determination by the area of pathologies. It means that their hard task can involve additional errors. It is advisable to use methods of imprecise logics that effectively display a doctor’s heuristic experience to analyze the signs resulting from the segmentation algorithm.

The obtained composite indices of specificity and sensitivity of the classification algorithm display proper quality of recognition of AMD stages (> 83%). Their values were mainly determined by a classification of OCT images from several tomography scanners with various imaging techniques. This occurs due to a wish to improve the generalizing capability of the algorithm for appliances from different manufacturers. It should also be noted that the average result of sensitivity is obtained for the intermediate AMD (58% only). It occurs because the stage of AMD is the most complicated one for recognition due to very similar forms of pathologies. It is suggested that methods of fuzzy logic should be applied to improve sensitivity while determining the stage of AMD during subsequent studies.


The machine learning algorithm was developed to segment the AMD pathologies based on OCT-images with attention concentration. A physician can apply the obtained results to focus on the most important for diagnostics areas or as part of the recommendation system of detection and determination of an AMD stage that has to be developed in subsequent studies. The algorithm displayed its perspectives regarding organizational issues associated with AMD diagnostics, less load on ophthalmologists, and effective recognition of AMD on OCT images with 98.1% of properly segmented abnormal areas.