Göğüs kafesi röntgen görüntülerinde derin öğrenme metoduyla zatürre hastalığının tanısı
Pneumonia detection using deep learning on chest X-ray images
Yazar: MUAZZEZ BUKET DARICI
Danışman: PROF. DR. ZÜMRAY ÖLMEZ
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Elektronik ve Haberleşme Mühendisliği Ana Bilim Dalı / Elektronik Mühendisliği Bilim Dalı
Derece: Yüksek Lisans, 2020
Konu: Elektrik ve Elektronik Mühendisliği = Electrical and Electronics Engineering

Özet:
Bu çalışmada göğüs kafesi radyografik görüntüleri kullanılarak ilk olarak pnömoni (zatürre) ve sağlıklı olmak üzere ikili sınıflama yapılarak hastalığın varlığı tespit edilmeye çalışılmıştır. Buna ek olarak ise aynı veri kümesi üzerinden  zatürrenin  iki farklı çeşidi olan bakteriyel ve viral zatürre sınıfları da kullanılarak, sağlıklı, viral zatürre ve bakteriyel zatürre olmak üzere üçlü sınıflama yapılarak incelenen görüntünün hangi sınıfa ait olduğu tespit edilmeye çalışılmıştır.  Her iki çalışmada da iki farklı derin öğrenme metodu kullanılmıştır. Bunlar Evrişimsel Sinir Ağları (ESA) ve  Topluluk Öğrenimi modelidir. Bu çalışma için Topluluk Öğrenimi modeli üç farklı ağı içeren bir modeldir. Bu ağlar iki farklı ESA modeli ve öğrenme aktarımı yoluyla kullanılan Inception-V3'tür. Topluluk Öğrenimi modelinde her ağ ayrı ayrı eğitildikten sonra çoğunluk oylaması yöntemiyle incelenen görüntünün sınıfına karar verilir. İkili sınıflamada kullanılan veri kümesi normal ve zatürre olmak üzere  iki ayrı sınıf etiketi  içermektedir. Üçlü sınıflama için ise zatürre olarak etiketlenen görüntüler dikkatli incelendiğinde bu sınıfın da kendi içinde ikiye ayrıldığı görülmüştür. Bunlar virus zatürre ve bakteriyel zatürredir. Zatürre sınıfı da bunlar dikkate alınarak ikiye ayrılmış ve toplamda normal, virüs zatürre ve bakteriyel zatürre olmak üzere üç sınıf içeren bir veri kümesi elde edilmiştir. Kullanılan veri kümesi sınıflar üzerinde dengeli bir dağılıma sahip olmadığı için eğitilen modelin,  görüntü sayısı fazla olan sınıfa doğru eğilimini engellemek amacıyla her iki sınıflama türü için de kullanılan sınıflar Smote metoduyla dengelenmiştir. Smote metodu bir aşırı örnekleme algoritmasıdır. Bu yöntemle görüntü sayıları, çoğunluğu içeren sınıf baz alınarak sentetik veriler üretimiyle dengelenir. Smote metodu uygulanmadan önce veri kümesi eğitim ve test kümelerine ayrılır. Test kümesi tüm veri kümesinin %20'sini oluşturmaktadır. Test kümesi ayrıldıktan sonra eğitim kümesine Smote metodu uygulanır ve böylece sınıflardaki görüntü sayıları sadece eğitim kümesinde dengelenmiş olur. Bu çalışmada kullanılan 1 ile 5 yaş arasındaki çocuklardan elde edilen toplam göğüs kafesi röntgen görüntüsü sayısı 5840'tır. Bu görüntülerin 4265'i zatürre, 1575'i ise normal olarak etiketlenmiştir. Her modelde ve her bir sınıflama probleminde eğitime başlamadan önce sahip olunan görüntülerin 1168'i test kümesi için ayrılmıştır. Sınıflardaki görüntü sayıları dengelendiğinde ikili sınıflamada ESA modeli %95, Topluluk Öğrenimi modeli %95 doğruluk oranına ulaşmıştır. Dengeli dağılımdaki üçlü sınıflamada ise ESA %78, Topluluk Öğrenimi modeli ise %75 ortalama doğruluk oranına ulaşmıştır. Doğruluk metriği literatürdeki benzer çalışmalarla karşılaştırma yapabilmek amacıyla tercih edilmiştir. Ayrıca sonuçlar kesinlik, duyarlılık ve F1 skoru parametreleriyle ayrı ayrı incelenmiştir. Bu üç farklı metrik ise kullanılan modellerin başarı sonuçlarının farklı şekilde yorumlanabilmesi amacıyla tercih edilmiştir. Kullanılan bütün derin öğrenme modellerinin Python'ın derin öğrenme uygulamaları için geliştirilmiş Keras kütüphanesi kullanılarak eğitildiği bu çalışmada, göğüs kafesi görüntüleri değerlendirilirken sınıf sayısının ve sınıflar içindeki görüntü sayısının farklı derin öğrenme modellerindeki etkisi araştırılmıştır.

Abstract:
Pneumonia is an inflammation of the tissues in the lungs which people of all ages can experience with mild to severe levels, usually caused by a bacterial infection. In developing countries, this lung disease becomes one of the deadliest among children under the age of 5 and causes 15% of deaths recorded each year.
Pneumonia can be a disease that can be managed with early diagnosis and treatment. The best known and most common clinical method for the diagnosis of pneumonia is the chest X-ray imaging. But diagnosis of pneumonia from chest X-ray images is a difficult task even for specialist radiologists. The appearance of pneumonia in X-ray images is often ambiguous, it can be confused with other diseases and behave like many other benign abnormalities. These inconsistencies have caused important subjective decisions and variations among radiologists in the diagnosis of pneumonia. Therefore, computerized support systems are needed to help radiologists diagnose pneumonia from chest X-ray images. Artificial Intelligence which has become popular in recent years, tries to understand the nature of human intelligence and tries to make computers more useful. Machine learning and deep learning, which are the sub-branches of artificial intelligence used in many fields, also promise to help experts in early diagnosis of diseases.
The main purpose of this study is to diagnose and classify pneumonia by deep learning ways using chest X-ray images. The study consists of two stages. The first stage is to perform binary classification by classifying images labeled normal and pneumonia; the second step is to make multi-class classification. Multi classes consist of normal, bacterial pneumonia, virus pneumonia. Pneumonia has been divided into two different types as bacterial and virus pneumonia using information on used dataset. Two different deep learning models have been used for these two different classification types. These deep learning models are Convolutional Neural Network (CNN)  and Ensemble Learning. Convolutional Neural Network is a model in which the convolution process is performed consecutively. On the other hand Ensemble Learning is a model in which three different deep learning models make predictions using majority voting method for this study. In the Ensemble Learning model, a CNN model which is used in the first stage, another CNN model which is formed using different parameters, and InceptionV3 model  whose only last layers are changed using transfer learning method have been used. The original dataset comprises of 5840 X-ray images among which 4265 is labeled as pneumonia and 1575 is labeled as normal. Each  image is of different size and has three channels of red, green and blue. For both classification problems, before the training process, all images were resized to 112×112 which means their widths and heights are 112.
Since the distribution of the number of images between the classes in the data set is not equal, a balanced distribution between the classes is provided for both classification types by using SMOTE method which is an over-sampling method. In the SMOTE method, the nearest neighbors whose number is set by the user are used  and several operations are performed to generate the new and synthetic data. Thus, the tendency of the deep learning model towards the majority class during the training process is prevented. The feature that distinguishes SMOTE method from other over-sampling methods, when balancing the number of data, is that it produces synthetic images instead of using the same image several times. 
In both classification problems, 80% of the data is reserved for training and the remaining 20% for testing. The SMOTE method, which provides balanced distribution, was applied only to the data in the training set, and the data in the test set were left as original. Some metrics have been used such as precision, recall and F1-score to interpret the performance of two different deep learning models used for these two classification types. Also accuracy metric has been used to be able to make a comparison between similar works and this study. Accordingly, in the binary classification problem involving the Normal and Pneumonia classes, the CNN model has reached an average accuracy rate of 95%. The Ensemble Learning model, on the other hand, reached 95% accuracy, just like the CNN model for binary classification. In the multi class classification, the CNN model reached an average accuracy rate of 78%, on the other hand Ensemble Learning reached average accuracy rate of 75%. For the multi class classification, the average precision, recall and F1 scores for the CNN model are 80%, 78%, 78%; and 77%,  75%, 75% respectively for the Ensemble model. Considering the results, although the two models proposed in this study for the binary classification problem give the same success, the CNN model in the multi class classification model has a higher average accuracy rate than the Ensemble Learning model. Also, there are similar studies in the literature related to detection of pneumonia using deep learning models. We compared our binary classification results with five different studies and our results in multi class classification with a single study. In these studies, we have seen that transfer learning models are generally used instead of creating a deep learning model from scratch. Between these studies for binary classification problem, our study gives better accuracy results except one. For multi class classification problem, our accuracy results for normal and bacterial pneumonia classes are better than the study related to classification of pneumonia disease. 
In addition, the deep learning models in this study were applied using KERAS library designed for PYTHON's deep learning applications. The reason why KERAS is preferred is that it is an easy-to-use and user-friendly interface in deep learning studies. Since the data set size containing the chest X-ray images used in this study is quite large and speed is important in deep learning studies, it is required to run the algorithms on a powerful computer. However, since we did not have such an opportunity for this study, all the studies were carried out on the platform named GOOGLE COLAB. Google Colaboratory, known as Google Colab, is an open source service provided by Google to anyone with a Gmail account, where anyone can run deep learning and machine learning codes. It provides free GPU to people who need it in their research.
The training of deep learning models created using the Keras library in Colab which is a platform that provides free GPU, is less than half an hour for this study, which is quite a short time compared to our results when we consider the training processes that took weeks for some problems. The most difficult part in this study is the reading the images in dataset. Diagnosis of the diseases using the chest X-ray images is a difficult task even for specialists and radiologists in the classification and interpretation of X-ray images. Depending on the environment or image quality, even these experts can often make erroneous classifications. 
In conclusion, the study of classification of pneumonia, which is carried out with two different deep learning models as binary and multi class classification, gives very successful results considering that the data set is challenging to work on  even for the radiologists. In addition, SMOTE method has been observed to work properly in producing synthetic data for the chest X-ray images, and the training processes in deep learning have been completed in a very short time using Keras with the free GPU provided by Google Colab.