Derin öğrenme ile pnömoni hastalığını tespit etme
Determining of pneumonia disease with deep learning
Yazar: GAMZE AKPOLAT
Danışman: ÖĞR. GÖR. HÜLYA YALÇIN
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Elektronik ve Haberleşme Mühendisliği Ana Bilim Dalı / Telekomünikasyon Mühendisliği Bilim Dalı
Derece: Yüksek Lisans, 2019
Konu: Elektrik ve Elektronik Mühendisliği = Electrical and Electronics Engineering

Özet:
Dünya da en yaygın ve ölümle sonuçlanabilir hastalıklar arasında yer alan pnömoni hastalığı, Türkiye'de de ölümle sonuçlanan hastalıklar arasında üst sıralarda yer almaktadır. Erken teşhis ölüm oranını azaltmadaki öncelikli etkendir.Teşhis de en büyük yardımcı yöntem ise görüntüleme teknikleridir. Bu hastalığın teşhisinde en sık kullanılan yöntem ise görüntüleme tekniği olan röntgenlerdir. 
Akciğer röntgeni ile hastalık tek başına çok büyük oranda tespit edilebilmektedir. Pnömoni ile benzer hastalıklar  benzer desenler oluşturduğundan frontal yani önden çekilmiş görüntü, tanı ve tedavide tek başına yeterli olmayabilir. Lateral denilen yan taraftan çekilmiş görüntüler de gerekebilir. 
Teşhiste doğruluk ve hızın artmasına katkıda bulunmak için birçok mühendislik uygulamalarına başvurulmaktadır. Bu uygulamalardan biri de makine öğrenmesi ile hastalık teşhis etmektir. Dünya da en popüler olan alanlardan biri veri bilimi ve makine öğrenmesi algoritmalarıdır. Medikal alanda bu konuya çok fazla ilgi gösterilmektedir. Gelişmiş ülkelerde  makine öğrenmesi destekli hastaneler oluşturulmaktadır, var olan hastanelerin alt yapısı ise buna uygun hale dönüştürülmektedir. 
Bu alana bu kadar yatırım yapılmasının başlıca nedenleri şunlardır; 
•	Makine öğrenmesi destekli hastaneler ile hastanın, şikayet ve belirtileri göz önünde bulundurularak, görüntüleme yöntemleri ve tahliller ile  hastanın öncelik durumunu belirleme,
•	 Doğru ve hızlı aksiyon alınarak doktorların üzerindeki yükü azaltma,
•	Yeterli hastane ve doktorun olmadığı bölgelerde, merkezi bir görüntüleme ve laboratuvarın olması, buraya  gelen hastaların gerekli bilgilerinin alındıktan sonra verilerin makine öğrenmesi algoritmalarından geçirilip, kişinin hasta olup olmadığının tespitinin yapılması,
•	Hastada görülen belirtilere göre kullanabileceği ilaçların verilmesi,
•	Tespit edilen hastalık için ilgili alana ve uzmana yönlendirilmesi,
•	Veride yeterli kalite sağlandığında hastalıkların segmentasyonu ve detaylı analizlerinin yapılabilmesi.
Hedeflenen bu modern hastanelerin alt yapısının sağlanabilmesi öncelikli olarak geçmiş verilerin etiketlenmesi ve depolanmasına bağlıdır. 
Bu çalışmanın öncülerinden olan The NIH Clinical Center akciğer röntgenlerini etiketlemiş ve hasta kimliğini koruyarak bu verilerin işlenebilmesi için veriler herkese açık hale getirmiştir. Klinik düzenli olarak sağladığı etiketli verilerin sayısını ve çeşidini artırmaktadır.
Bu tez çalışmasında derin öğrenme metodu kullanılarak röntgen görüntülerinden pnömoni hastalığını teşhis etmek için, kliniğin sağladığı veriler kullanılarak bir sınıflandırma modeli oluşturulmuştur. Bu model oluşturulurken aynı ve benzer veri kümesi üzerinde yapılmış çalışmalar incelenmiş ve o çalışmaların üzerine ek çalışmalar yapılarak başarı oranları artırılmıştır. Performans ve hız sorununa yeni bir çözüm sunulmuştur. 
Medikal veri kümelerinde genel olarak hasta etiketli veriler çoğunlukta olduğundan, bu tür veri  setlerinde sağlıklı ve hasta etiketli veriler arasında ciddi bir dengesiz dağılım olur. Bu çalışmada kullanılan veri kümesinde de dengesiz dağılım mevcut olduğundan, bu sorun veri artırma yöntemi ile giderilmiştir. Veri artırma yöntemi sadece sağlıklı etiketli verilere uygulanmıştır. Veri hazırlama sürecinde, uygun olmayan veriler, kanal sayısı üç olmayan görüntüler gibi, veri kümesinden çıkarılmamış, bunun yerine uygun hale gelecek şekilde dönüştürülmüştür. 
Makine öğrenmesinde karşılaşılan en büyük sıkıntılardan biri olan aşırı öğrenmeyi engellemek için verilerde normalizasyon, seyreltme, erken durdurma gibi tekniklere başvurulmuştur. 
Modeller oluşturulurken konvolüsyonel sinir ağları ile derinlemesine ayrılabilir konvolüsyonel ağlar kullanılmıştır. Model çıktıları çeşitli başarı ölçüm yöntemleri ile incelenmiş olup, başarı oranının artırılması için değiştirilebilir  hiper parametreler belirtilmiştir.  Tüm çıktılar yorumlanmış ve ileride yapılacak çalışmalarda dikkate alınması gereken bulgular detaylıca açıklanmıştır.

Abstract:
In the world, the most common and fatal diseases is the pneumonia disease, it is situated at the top among the fatal disease in Turkey. Early diagnosis and treatment are the primary factors in reducing the death rate. One of the most important methods of diagnosis is imaging techniques, which one is  X-ray. This is the most commonly used method in the diagnosis of the disease. The disease can be detected correctly with using only chest x-ray in high probability.
Similar diseases with pneumonia create similar patterns in lungs. Because of that the frontal image may not be sufficient for diagnosis and detection alone. It may be required the lateral images for correct disease diagnosis.
In the medical field, many engineering applications are used to contribute to increase accuracy and speed in diagnosis.One of these applications is to diagnose various diseases and find the relationship between them through machine learning.
One of the most popular areas in the world is data science and artificial intelligence. Much attention has been paid to this issue in the medical field. In developed countries, hospitals with artificial intelligence support are formed.  The infrastructure of the existing hospitals is transformed into the corresponding state.
The main reasons for investing in this area are as follows;
•	With the help of artificial intelligence-supported hospitals, the patient's priority status is determined with imaging methods by assays and taking into account the symptoms.
•	This algorithms taking correct and quick action, which is provides to reduce the overtime hours of doctors
•	In a region where there is a central imaging and laboratory, but where there is no comprehensive hospital and a sufficient number of physicians, the data of the patients are passed through artificial intelligence algorithms and it is determined whether the person is ill or not,
•	Giving the medicine to be used according to the symptoms seen in the patient,
•	The patient is referred to the relevant field and specialist for the problem detected. 
•	When sufficient quality is achieved, segmentation and detailed analysis of diseases can be performed.
The provision of the infrastructure of these targeted modern hospitals depends primarily on the labeling and storage of historical data.
This clinic labeled lung X-rays and kept the data public for the purpose of processing this data while preserving patient identity. Clinical staff label data on a regular basis. In this way, the number and variety of data is increasing. The clinic updates data sets periodically.
In this thesis, a classification model was formed by using the data provided by the clinic in order to diagnose pneumonia from the X-ray images using deep learning method.
In this model, the studies on the same data set were examined and additional studies were performed on these studies and the performance rates were increased. A new solution to the problem of performance and speed in model training is presented. 
In general, patient-labeled data are predominant in medical data sets. In such data sets, there is a serious unbalanced distribution between healthy and unhealthy labeled data. Since the unbalanced distribution is present in the data set used in this study, this problem has been solved with the data increment method which is called data augmentation. The data enhancement method was applied only to healthy labeled data. In the process of preparing data, inappropriate data was transformed so that the number of channels was not subtracted from the data set, such as non-three images, instead being appropriate.
In order to prevent overfitting, which is one of the biggest problems encountered in machine learning, techniques such as normalization, dilution and early stop were applied.
When forming the model, convolutional neural networks and depthwise separable convolution has been used. One of the biggest challenges in machine learning is the need for a longer time requirement to teach, as well as the need for more computationally sophisticated computers due to processing and calculation overhead. The most important feature that distinguishes depthwise separable convolution from other convolutions is that it reduces the number of calculated parameters from millions number to thousands number and provides a great speed.
The model outputs have been investigated by various performance measurement methods and changeable hyperparameters have been stated to increase the performance rate.  Some one of them are recall, precision, accuracy and f1 score.
All outputs were interpreted according to these measurement methods. 
It is seen that the results of this study have higher performance rates compared to the previous studies. All methods and terms used in this study are explained firstly with cause and effect relationship and then step by step methods are explained. The findings to be taken into consideration in future studies are explained in detail. 
In previous studies, CNN and RNN networks were formed with different models and parameters. Although the same neural networks and the same activation function were used in the same data set, better performance rates were obtained by the design of the intermediate layers and the differentiation of the hyper parameter values. This means that the performance ratio of the model can be higher with the appropriate hyper-parameter values. It is thought that performance rates can be increased to higher values with different classification methods. 
In addition to this information, the images in the data set examined are frontal shots. That is, it consists only of views taken from the front.Some diseases can produce similar patterns in the lungs. In order to avoid confusion of different diseases with similar images, lung X-rays should consist of more extensive images called lateral. In machine learning algorithms, the distribution of images in the data set to be trained should be balanced. Any tagged data should not be too dense from any other data. The number of different labeled data should be close to one another. In order to diagnose the disease, the symptoms, patient demographic information, X-rays and other diagnostic methods should be evaluated together. Therefore, this data set provided by the clinic and used in the thesis study will be more modern and accurate when enriched with other data of the patient.
Early diagnosis is of great importance for the treatment of this health problem. Many engineering applications are used to help improve accuracy and speed in diagnostics. One of these applications is to diagnose disease with machine learning. In this thesis, using deep learning methods, classification models will be developed to diagnose pneumonia from X-ray images.
In this thesis, the data set consisting of lung images of patients and healthy people was examined and models were formed to classify the diagnosis of disease with deep learning. The models created were based on previous studies and exceeded the achievements achieved.
Detected data imbalance in distribution when examining dataset data has been exceeded with the increase method. Although the data set was limited, 10% to 20% higher success was achieved than previous studies. In addition, the success of the data enhancement process on the model was measured by experiments. It is thought that the success rate in each model will increase when the number of data in the data set is increased to be balanced. Since the number of data was low, data with one channel number (one channel in grayscale) was converted to processable for each model by adding the number of channels (RGB three channels) instead of being removed from the cluster. 
Early stop, data dilution and normalization procedures were applied to avoid excessive learning. In order to overcome the performance problem, in-depth separable convolution is used. With this convolution method, high computational processes were avoided and more performance and faster results were obtained. It has been observed that the success rate can be increased by changing the hyper parameters. 
In addition, different classification methods can be used in imaging techniques to achieve higher success rates. In addition to the random division of the data set, the k-fold method was also applied and the results of the measurement were compared and the models for which the k-fold method was successful were determined.