Detection of Cystic Fibrosis Symptoms Based on X-Ray Images Using Machine Learning- Pilot Study

Background: Cystic fibrosis is a multi-organ disease, inherited in an autosomal recessive manner, requires systematic imaging tests. The most commonly used diagnostic method due to the low cost and low radiation dose is classic X-ray imaging. For patients with cystic fibrosis, they are performed as part of the annual review, as well as in rapid diagnostics when complications are suspected. In this paper, we describe the use of machine learning in medicine to make a diagnosis with a small number of X-ray images. Methods: Our dataset contains 53 X-ray images of CF patients and 371 healthy patients. We use the Convolutional Neural Network (CNN) to classify X-ray images into two categories: CF patient / healthy one. The accuracy and loss function for training and validation were calculated as well as precision p, recall specificity s, and correlation coefficient M_cc for prediction. After training we get accuracy and loss function L=0.6 for training and accuracy of validation and loss function of validation. For predictions we calculated precision, recall r=1 and specificity s=0.63. We also calculated the Matthews correlation coefficient M_cc=0.46 especially, for testing the accuracy of predictions of deep neural networks. Conclusion: We have presented a method for classifying X-ray images of CF patients. The method can be used to automate screening, but much more data is needed for training to obtain reliable results. Future research will aim to increase network accuracy as well as training CNN to classify the correlation severity of CF.

of cystic fibrosis varies significantly between patients and cannot be predicted on the basis of the genotype, the treatment must be adjusted individually, hence it is necessary to frequently monitor changes in the respiratory system, including imaging studies. Imaging diagnostics in cystic fibrosis primarily concerns the organs of the chest and abdomen, collateral nasal sinuses and the spine. Imaging mainly uses methods using ionizing radiation (X-ray, CT), but also other methods, such as USG or MR not using ionizing radiation.
Radiological tests are based on the measurement of the attenuation of the ray beam after passing through the human body [1]. The X-ray image is a widely available method with a very low radiation dose and low cost. It allows to detect the macroscopic changes and gives insight into the physiology of the respiratory system [4].
Despite the low sensitivity in detecting early progression, it is still used by most centers, also in Poland, for regular monitoring of disease progression. It is usually performed as part of the annual medical check of patients with cystic fibrosis -during the period without infection. It is also used for quick diagnostics in the presence of suspected complications, monitoring of pleural drainage treatment, it is also recommended after chest procedures (e.g. establishing a vascular port). Although X-ray examination requires virtually no preparation, the technique of performing it is important [5]. Most often, an X-ray image is taken only in the anteroposterior projection-AP (in newborns and infants) and posterior-anterior-PA (in older children and adults. If the AP/ PA projection is difficult to interpret, the radiologist will order additional projections, usually lateral. In older children and adults, the picture is taken in a standing position, with the breath held at the top of the inspiratory phase, because then the assessment of the lungs and heart is most adequate, and in newborns and infants lying down. The main radiological symptoms are increased lung transparency, tightening of the pulmonary parenchyma, atelectasis, air bronchogram, silhouette symptom, and pleural fluid [6]. Peripheral pulmonary distension is the abnormality that is seen first in X-rays. The interpretation of the X-ray image includes familiarization with clinical referral data, assessment of the image in terms of technical correctness, assessment of pulmonary fields, identification of lesions, assessment of the mediastinum including heart and large vessels, assessment of the diaphragm and assessment of the chest wall. The study description and conclusions are formulated on the basis of clinical data and radiological images. The X-ray examination creates interpretation problems because there is a lack of standardization and validation in the assessment of an X-ray image (it is often subjective and depends on the experience of radiologists) [6][7][8].
Over the years, X-ray devices have undergone quite an evolution: the patient's exposure time has been significantly shortened, better methods of filtering and collimating the X-ray beam have been introduced, and the radiation dose has been significantly reduced, replacing the analog methods with digital ones, which give more possibilities not only for X-ray image processing but also for its archiving and distance consulting, not to mention the economic aspect. Currently used systems also give the opportunity to simultaneously take X-ray images using different values of lamp voltage and current. Radiographs made in this way provide more diagnostic information, and the radiation dose received by the patient is similar to the dose of a single image [7]. The importance of some diagnostic methods has now been reevaluated, while modern technologies are increasingly being used to help in the correct interpretation of test results. An important opportunity for medicine could be the use of artificial neural networks, acting similarly to synapses in the human brain. The purpose of this article was to investigate whether artificial neural networks can be used as an effective tool for diagnosing cystic fibrosis based on X-rays images and predicting patient prognosis, as well as whether they will reduce the frequency of taking X-rays.

Machine learning and image analysis -Convolutional Neural Networks (CNN)
Machine Learning (ML) is a science dealing with algorithms and statistical models that allow computer systems to perform certain tasks without giving exact instructions -they only use emerging patterns and dependencies. They are used in those areas for which the creation of a working and correct algorithm solving a given problem is very difficult, and sometimes even impossible.
Artificial Neural Networks (ANN) are one type of machine learning algorithms [9]. These are systems of elements (nodes) loosely inspired by biological neural networks. They work like synapses in the human brain -training data causes signals to be sent along a network -according to the appropriate mathematical function (usually non-linear) assigned to each of the neurons. ANN requires a large amount of "training" data to calculate the weights of nodes of the network [10]. From several to thousands of neurons can make up a single layer, each of which can serve different purposes and perform different operations on the input data. The basic algorithm that teaches neural networks is the backpropagation algorithm, which involves finding the weights of individual neurons moving from the final (output) layer through subsequent hidden layers to the input layer.

Image Analysis and Neural Networks
The main problem during the analysis and classification of images using neural networks is the fact that images are usually objects of large size (for an example image of size 224x224 pixels and 3 color channels can be stored using 224x224x3 = 150528 numbers). The result is that even a small picture requires a very large neural network -in this case, over 150 000 neurons in the input layer. It turns out that biology also encountered such a limitation and solved this problem. In 1950-1960, Hubel and Wiesel showed that the visual cortex of cats and monkeys contains neurons that individually respond to small fragments of the field of view. This area is called the receptive field. Adjacent neurons have similar and overlapping receptive fields. All neurons in the visual cortex together form a map of the entire visual space, which is observed by an animal [11].
Hubel and Wiesel also noticed that they are dealing with two types of neurons: a) Simple cells whose output is maximized by detecting edges in a specific orientation to the receptive field b) Complex cells -having a larger receptive field whose output is independent of the edge position in the receptive field.
The practical use of this discovery came much later in the form of Convolutional Neural Networks (CNN) [12].
The CNN is made up of many hidden layers, but the groups of neurons in some layers do not connect with each other (as in typical dense layers), but only a small number of input neurons creates a receptive field that connects to one or several hidden layer neurons.

Used Software
In the process of classification of RTG images, the opensource programming libraries were used to support the design, learning, and testing of convolutional neural networks. Due to the fact that Python has been chosen as the programming language for research, matter of a few commands. This library also provides loading and preprocessing images. This library can use Tensor Flow [14] as a backend engine or other low-level libraries (for example Theano or CNTK). In our research, we use TensorFlow, which provides computations on CPU, GPU as well as Tensor Processing Units (TPU) provided by Google. In addition, the cu DNN library [15] was used in our calculations to run the model training using the graphic accelerator and HDF5 to save the model on the hard disk for future reuse.

Data used during Training of CNN
The data used in training and testing the neural network are

The Network has been Trained for 50 Epochs
The Loss function has been calculated -it is a measure of the discrepancy between the predicted value for the input data and the actual value. Unlike Accuracy, this is not a percentage, but the sum of errors for each entry in a training or test set. For neural networks, the loss function usually behaves like a negative logarithm function. Thus, the main goal in model learning is to minimize the loss function through various optimization methods.
Ideally, we should get a result equal zero -the smaller the value of this function, the better and more accurate model. In the case of the Keras library, the loss function works within a single set of training data and considers, for example, the action of the Dropout layer, which adds additional "noise" to the data. After 50 epochs, we received the value of loss function equal to 0.6, which in this case is not very satisfactory. The second important parameter is Accuracy -the higher the value (optimally 1), the more accurate is the model and it performs better during calculations -it gives more accurate results. After 50 epochs, accuracy was equal to 0.72. Accuracy also considers the Dropout layer. Val_loss is a loss function but applied to a validation set created by the library automatically from some training data. In addition, the Dropout layer is not used in this case.
Val_loss has fallen to 0.37. Val_acc is accuracy calculated from data in the validation set -it reached the value of 1.00 but in the last few steps, it oscillated at 0.74. of these pictures were classified as pictures of healthy people.

Results
During the test of the trained neural network on a test set of 10 X-ray images of healthy people, all of these images were classified as healthy people. It should be remembered that the neural network always classifies a picture with a certain probability -if the probability of classifying a picture as a picture of a sick person is only slightly lower than the probability of classifying a picture as a picture of a healthy person, we will receive information on the output that it is a picture of a healthy person. The accuracy of a given neural network can be illustrated in Table 1 (the so-called confusion matrix. We also calculated predictions for the test set for healthy and CF patients. As one can see from the above images and the number of incorrectly classified cases of CF patients, the neural network trained on the selected data set doesn't deal very well with the correct classification of X-ray images of CF patients but doesn't make mistakes when it comes to classifying healthy people. After the calculation of the loss function and the accuracy for the test set, we can observe that the loss function in the test increased in relation to the one calculated during the training (L_ test=0.7415), which means that most likely the model is overfittedwhat was expected due to the small amount of data. The accuracy in the test is A_test=68.75. An overfitted model handles training data very well, but it is not flexible enough to properly analyze a test data set. It is probably related to the basic problem when it comes to the use of neural network algorithms -the lack of sufficient training data and a certain "imbalance" in the number of X-rays of sick and healthy people. We also calculated some coefficients describing the accuracy of predictions of CNN (Table 2) Matthews correlation coefficient is used in machine learning to measure the quality of binary classification. M_cc is better than F1score or accuracy in case of binary problems, because it considers the balance ratios of the four confusion matrix categories [16]. M_cc changes from -1 (worst) to +1 (best value) and consider sizes of all four classes of the confusion matrix.  gives enormous possibilities when it comes to a quick and accurate diagnosis. CNN is able to detect details that only an experienced expert will be able to find [21]. Our research shows that CNN is an excellent tool in the classification of X-ray images, even despite the fact that the amount of data used during the training of the neural network was very limited. A larger amount of data (mainly greater number of X-ray images of CF patients) and the use of data augmentation, knowledge transfer method and using other structures of the neural network will allow in the future to significantly increase the accuracy of neural network predictions and thus also the usefulness of this tool in medical diagnostics.
What's more, while the training of the neural network takes a long time, even with the use of tools such as specialized Tensor Processors (TPU) or Graphics Card Processors (GPU), the analysis of X-ray images using such a trained network takes a very short time, so CNN is also a very efficient tool. Future research. Undoubtedly, the main problem associated with the use of an artificial neural network to analyze X-ray images in the detection of cystic fibrosis is the small number of X-rays of patients.
One of solutions is to find more data -obtaining a large number of X-ray images of patients with cystic fibrosis, which, however, can be a very difficult task due to the limited access to medical data and legal issues. Another possibility to solve the problem of the correct operation of the neural network can be a change in its structure e.g.
adding layers or changing the activation function. Another possible solution is to use an already trained neural network (e.g. Google Net), which detects completely different types of objects, but it is possible to re-train several initial layers of such a network using training set of X-ray images, which will cause the network to classify this data with much greater accuracy than the network trained only with this training set of our X-ray images [22,23].

Disclosures
The authors declare that there is no conflict of interest regarding the publication of this research. This research did not receive any specific grant from funding agencies in the public, commercial, or not-for-profit sector. All data relevant to the study are included in the article or uploaded as supplementary information.