Diagnosing corneal diseases with CNN-LSTM — a sequence classification problem

--

Introduction

Keratoconus is a disorder of the cornea of unknown cause. It is characterized by progressive thinning and cone-shaped protrusion of the cornea leading to visual impairment.

Patients may present with blurry vision or a sudden decrease in visual acuity and the prevalence reported in the general population can range from 50 to 230 cases per 100,000 people.

As the prevalence of keratoconus in the general population is low, the precision of diagnostic tests tends to be low with an increased number of false positives, although early diagnosis is very important as patients that undergo corneal refractive surgery can remain asymptomatic afterwards whereas its morbidity rate is high when it is not treated

Slit-lamp photograph of an eye with keratoconus demonstrating increased corneal curvature.

How is the diagnosis currently made?

Several tests can be performed to diagnose keratoconus, being the most advanced ones mainly based on the Scheimpflug principle for mapping the corneal topography, which can also be used for planning LASIK, a popular surgery to correct vision in people who are nearsighted or farsighted.

The angles of the Scheimpflug principle, using the example of a photographic lens.
Topographic Patterns, representing heatmaps from 3D scanners.

The Galilei G6 Dual Scheimpflug Analyzer (Ziemer, Port, Switzerland) combines 20 Placido rings based topography with a dual rotating Scheimpflug camera and is considered gold standard in corneal measurements. It provides a 3D mapping of the cornea from 18 000 actual lifting points and gives 15 different measurements that include all the segments of the eye.

Big Data Jobs

Diagnostic challanges

Although a skilled physician can readily recognize moderate and advanced stages of keratoconus, even in slit-lamp examination, the identification of milder or sub-clinical forms of the disease remains challenging.

The vast amount of novel information and diagnostic methods currently available can make it difficult to understand and efficiently interpret all the data.

A more accurate method for diagnosing keratoconus as well as other corneal diseases may be developed as it can facilitate early diagnosis and further interventions. Also, a faster and less human-dependable analysis is needed for screening patients on bigger numbers.

Those facts make machine learning a promising approach for sharpening diagnosis rates using already available methods.

Objective

The aim of this work is to develop a highly accurate neural network for diagnosing keratoconus, trained on optical topography raw data.

Development

Data source

Twenty-four eye scans from Galilei G6 were initially gathered for analysis and training, all coming from participants on a research project for keratoconus diagnosis currently undergoing at the University Hospital of UFPR (University of Parana, Curitiba, Brazil).

Trending AI Articles:

1. Why Corporate AI projects fail?

2. How AI Will Power the Next Wave of Healthcare Innovation?

3. Machine Learning by Using Regression Model

4. Top Data Science Platforms in 2021 Other than Kaggle

Data description

Each examination contains 15 different .csv tables with the same shape (4 columns x 18000 rows). The first 3 columns are Scheimpflug coordinates and angles — indexed equally in all tables — and the last column is the measurement, the only true variable.

Disclaimers: All data is anonymized from source and, when we gather more data for retraining and validation, a paper will be submitted to a trusted scientific journal.

Data processing

For joining the variables’ columns, a Python script was developed.

The first step was to recursively scavenge the examinations opening every .csv and listing all columns.

For that, I start listing all the directories containing the examination folder:

Then, we concatenate the columns and return only the measurements table:

Finally, I call a function to save the dataframe in a new .csv file:

You can see I pass the input and output paths as arguments.

Finally, we loop through every folder and create a final .csv file:

Model architecture decision

Sequence classification is a predictive modeling problem where you have some sequence of inputs over space or time and the task is to predict a category for the sequence.

This is exactly what we are dealing with here. Each examination is comprised of a 2D matrix each labeled as positive or negative/healthy for keratoconus. For predictions, we’d like to input a same-shape matrix and see a prediction output ranging from 0 (negative) to 1 (positive).

Eye topography data has a three-dimensional spatial structure in the sequence of measurements and the CNN may be able to pick out invariant features for keratoconus, because convolutional neural networks excel at learning the spatial structure on input data.

This learned spatial features can then be inputted as sequences to a LSTM (Long-Short Term Memory) layer using 100 units composed of a cell, an input gate, an output gate and a forget gate.

An example of a LSTM layer unit.

The cell remembers values over arbitrary time intervals and the three gates regulate the flow of information into and out of the cell. Basically, this is a RNN with a long-term memory added on top of it.

That means the LSTM can remember old values when facing a new decision. Below, you can see the final model architecture.

Data preparation for training

All .csv tables were divided into two folders: a ‘positive folder’, containing all the exams positive for keratoconus, and a ‘negative folder’, containing healthy eyes only. Then, I created an input function for the network and listed the files in both folders also creating empty lists that will contain our samples and labels (X and Y).

The dataset was balanced 50/50 before the processing, with a total of 130 examinations divided between positives and negatives for the training and validation sets. 69 examinations were gathered for the test set.

I then looped into both folders, getting the files and transforming into dataframes. Afterwards, the dataframes are converted and reshaped into a 3-dimensional numpy array of shape (1, 18000, 15), representing 1 sample, 18k space-points and 15 features.

I then append it all in the X list and the correspondent label on the Y list, also reshaped:

Splitting data

Data split was made as the following, with a 20% proportion on test data:

I then trained the model using 500 epochs with a batch-size of 32 and a learning-rate of 0.0001 on the RMSprop optmizer. I also used the Binary Crossentropy as the loss function and plotted both accuracy and AUC metrics for train and validation data:

Training results

After 40 epochs, we can see an extraordinary accuracy on both train and validation data with a converging loss :

AUC after 500 epochs
Accuracy after 500 epochs
Converging loss after 500 epochs

Testing the model

The last step was evaluating the model with a batch prediction on 69 totally new examinations:

The yielded standard metrics for diagnostic tests — with a threshold of 0.4 — are the following:

Metrics on the testset with 69 samples.

We can see the model has a good sensitivity while keeping its precision, possibly allowing it to be explored as a screening method.

A good screening method usually meets the following requirements:

  1. Disease Has Serious Consequences
  2. Screening Population Has High Prevalence of Detectable Preclinical Phase
  3. Screening Test Detects Little Pseudodisease
  4. Screening Test Has High Accuracy for Detecting the Detectable Preclinical Phase
  5. Screening Test Detects Disease Before Critical Point
  6. Screening Test Causes Little Morbidity
  7. Screening Test Is Affordable and Available
  8. Treatment Exists
  9. Treatment Is More Effective When Applied Before Symptoms Begin
  10. Treatment Is Not Too Risky or Toxic

Conclusion

This article shows how we got topographic data from eye scans and inputted it on a Long-Short Term Memory Neural Network (LSTM) for accomplishing the classification task of distinguishing eyes affected by keratoconus — a corneal disease that can lead to loss of visual acuity — from healthy eyes.

We then stated the preliminary metrics of the trained model are promising and further data collection will be made for validation and retraining purposes.

Finally, if we achieve a good level of validation and evidences it can improve clinical practice somehow, either enhancing disease progression or boosting productivity on screening tasks, we could then assure it can be used in practical scenarios.

The most important limitation is our dataset size, but also the restrained analysis from a single equipment. Besides collecting more Galilei G6 data, we will expand the research for other similar products in the future.

Also, other problems such as cataract and refractive disturbs will be further explored.

Code

All code is in my GitHub, in the following repository:

github.com/solanovisitor/biometrics_lstm

Sources:
Vazirani J, Basu S. Keratoconus: current perspectives. Clin Ophthalmol 2013; 7:2019.
Jhanji V, Sharma N, Vajpayee RB. Management of keratoconus: current scenario. Br J Ophthalmol 2011; 95:1044.
Fernández Pérez J, Valero Marcos A, Martínez Peña FJ. Early diagnosis of keratoconus: what difference is it making? Br J Ophthalmol 2014; 98:1465.
Salomão M, Hoffling-Lima AL, Lopes B, Belin MW, Sena N, Dawson DG, et al. Recent developments in keratoconus diagnosis. Expert Rev Ophthalmol. 2018;13(6):329–41.
https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/

Don’t forget to give us your 👏 !

Metrics on the testset with 69 samples.

We can see the model has a good sensitivity while keeping its precision, possibly allowing it to be explored as a screening method.

A good screening method usually meets the following requirements:

  1. Disease Has Serious Consequences
  2. Screening Population Has High Prevalence of Detectable Preclinical Phase
  3. Screening Test Detects Little Pseudodisease
  4. Screening Test Has High Accuracy for Detecting the Detectable Preclinical Phase
  5. Screening Test Detects Disease Before Critical Point
  6. Screening Test Causes Little Morbidity
  7. Screening Test Is Affordable and Available
  8. Treatment Exists
  9. Treatment Is More Effective When Applied Before Symptoms Begin
  10. Treatment Is Not Too Risky or Toxic

Conclusion

This article shows how we got topographic data from eye scans and inputted it on a Long-Short Term Memory Neural Network (LSTM) for accomplishing the classification task of distinguishing eyes affected by keratoconus — a corneal disease that can lead to loss of visual acuity — from healthy eyes.

We then stated the preliminary metrics of the trained model are promising and further data collection will be made for validation and retraining purposes.

Finally, if we achieve a good level of validation and evidences it can improve clinical practice somehow, either enhancing disease progression or boosting productivity on screening tasks, we could then assure it can be used in practical scenarios.

The most important limitation is our dataset size, but also the restrained analysis from a single equipment. Besides collecting more Galilei G6 data, we will expand the research for other similar products in the future.

Also, other problems such as cataract and refractive disturbs will be further explored.

Code

All code is in my GitHub, in the following repository:

github.com/solanovisitor/biometrics_lstm

Sources:
Vazirani J, Basu S. Keratoconus: current perspectives. Clin Ophthalmol 2013; 7:2019.
Jhanji V, Sharma N, Vajpayee RB. Management of keratoconus: current scenario. Br J Ophthalmol 2011; 95:1044.
Fernández Pérez J, Valero Marcos A, Martínez Peña FJ. Early diagnosis of keratoconus: what difference is it making? Br J Ophthalmol 2014; 98:1465.
Salomão M, Hoffling-Lima AL, Lopes B, Belin MW, Sena N, Dawson DG, et al. Recent developments in keratoconus diagnosis. Expert Rev Ophthalmol. 2018;13(6):329–41.
https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/

Don’t forget to give us your 👏 !

--

--