A Fully Automated Deep Learning-based Network For Detecting COVID-19 from a New And Large Lung CT Scan Dataset ============================================================================================================== * Mohammad Rahimzadeh * Abolfazl Attar * Seyed Mohammad Sakhaei ## Abstract COVID-19 is a severe global problem, and one of the primary ways to decrease its casualties is the infected person’s identification at the proper time. AI can play a significant role in these cases by monitoring and detecting infected persons in early-stage. In this paper, we aim to propose a high- speed and accurate fully-automated method to detect COVID-19 from the patient’s CT scan. We introduce a new dataset that contains 48260 CT scan images from 282 normal persons and 15589 images from 95 patients with COVID-19 infection. Our proposed automated system takes all the CT scan image sequences of a patient as the input and determines if the patient is infected with COVID-19. At the first stage, this system runs the proposed image processing algorithm to discard those CT images that inside the lung is not properly visible in them. This helps to reduce the number of images that shall be processed, so it reduces the processing time. Also, running this algorithm makes the deep network at the next stage to analyze only the proper images and thus reduces false detections. At the next stage, we propose a new modified deep convolutional network that is based on ResNet50V2 and is enhanced by the feature pyramid network for classifying the selected CT images into COVID-19 or normal. After running these two phases, if enough number of chosen CT scan images of a patient be identified as COVID-19, the system considers that patient, infected to this disease. In the single image classification stage, the ResNet50V2 with feature pyramid network achieved 98.49% accuracy on more than 7996 validation images. At the fully automated phase, the automated system correctly identified almost 237 patients from 245 patients on average between five-folds with high speed. In the end, we also investigate the classified images with a feature visualization algorithm to indicate the area of infections in each image. We are implementing these materials on some medical centers in Iran, and we hope that it would be a great help in Intelligence disease detection anywhere. *K*eywords * Deep learning * Convolutional Neural networks * COVID-19 * Coronavirus * radiology * CT scan * Medical image analysis * Automatic medical diagnosis * lung CT scan dataset ## 1 Introduction On January 30, 2020, the World Health Organization(WHO) announced the outbreak of a new viral disease as an international concern for public health, and on February 11, 2020, WHO named of the disease caused by the new coronavirus: COVID-19 [31]. The first patients with COVID-19 were observed in Wuhan, China. These people were associated with the local wild animal market, which indicates the possibility of transmitting the virus from animals to humans [28]. The severe outbreak of the new coronavirus spread rapidly throughout China and then spread to other countries. The virus disrupted many political, economic, and sporting events and affected the lives of many people worldwide. The most important feature of the new coronavirus is it’s fast and wide-spreading capability. The virus is mainly transmitted directly from people with the disease to others; It is transmitted indirectly through the surfaces and air in the environment in which the infected people come in contact with it [31]. As a result, correctly identifying the symptoms of people with the disease and quarantining them plays a significant role in preventing the disease. New coronavirus causes viral pneumonia in the lungs, which results in severe acute respiratory syndrome. The new coronavirus causes a variety of changes in the sufferer. The most common symptoms of new coronavirus are fever, dry cough, and tiredness [31]. The symptoms of this disease vary from person to person [19]. Other symptoms such as loss of sense of smell and taste, headache, and sore throat may occur in some patients, but severe symptoms that indicate the further progression of COVID-19 include shortness of breath, chest pain, and loss of ability to move or Talking [31]. There are several methods for definitive diagnosis of COVID-19, including reverse transcriptase-polymerase chain reaction (RT-PCR), Isothermal nucleic amplification test, Antibody test, Serology tests, and medical imaging [32]. RT-PCR is the primary method of diagnosing COVID-19 and many viral diseases. However, the method is restricted for some of the assays as higher expertise and experimentation are required to develop new assays [8]. Besides, the lack of diagnostic kits in most contaminated areas around the world is leading researchers to come up with new and easier ways to diagnose the disease. Due to the availability of medical imaging devices in most treatment centers, the researchers analyze CT scans and X-rays to detect COVID-19. In most patients with COVID-19, infections are found in the lungs of people with new coronavirus that can help diagnose the disease. Analysis of CT scans of patients with COVID-19 showed pneumonia caused by the new coronavirus [28]. With the approval of radiologists for the ability to use CT scans and X-rays to detect COVID-19, various methods have been proposed to use these images. Most patients who have COVID-19 symptoms at least four days later have X-rays and CT scans of their lungs, showing infections that confirm the presence of a new coronavirus in their body [3]. Although medical imaging is not recommended for definitive diagnosis, it can be used for early COVID-19 diagnosis due to the limitations of other methods [2]. In [33, 3], some patients with early-onset COVID-19 symptoms were found to have new coronavirus infections on their CT scans. At the same time, their RT-PCR test results were negative, then both tests were repeated several days later, and RT-PCR confirmed the CT scan’s diagnostic results. Although medical imaging is not recommended for the definitive diagnosis of COVID-19, it can be used as a primary diagnostic method for the COVID-19 to quarantine the Suspicious person and prevent the virus from being transmitted to others in the early stages of the disease. The advantage of using medical imaging is the ability to visualize viral infections by machine vision. Machine vision has many different methods, one of the best of which is deep learning [10]. Machine vision and deep learning have many applications in medicine [26], agriculture [22], economics [9], etc., which have eliminated human errors and created automation in various fields. The use of machine vision and deep learning is one of the best ways to diagnose tumors and infections caused by various diseases. This method has been used for various medical images, such as segmentation of lesions in the brain and skin [18], Applications to Breast Lesions, and Pulmonary Nodules [4], sperm detection and tracking [24] and state-of-the-art bone suppression in x-rays images[34]. On the other hand, diagnosing the disease by computer vision and deep learning is much more accurate than radiologists. For example, in [12], the accuracy of the method used is about 90%, while the accuracy of radiologists’ diagnosis is approximately 70%. Due to the effectiveness of machine vision and deep learning in medical imaging, especially CT scan and X-ray images, machine vision and deep learning have been used to diagnose COVID-19. In this paper, we introduce a fully-automated method for detecting COVID-19 cases from the output files(images) of the lung HRCT scan device. This system does not need any medical expert for system configuration and takes all the CT scans of a patient and clarifies if he is infected to COVID-19 or not. We also introduce and share a new dataset that we called COVID-CTset that contains 15589 COVID-19 images from 95 patients and 48260 normal images from 282 persons. At the first stage of our work, we apply an image processing algorithm for selecting those images of the patients, that inside the lung and the possible infections be observable in them. In this way, we speed up the process because the network does not have to analyze all the images. Also, we improve the accuracy by giving the network the proper images. After that, we will train and test three deep convolutional neural networks for classifying the selected images. One of them is our proposed enhanced version of ResNet50V2 with a feature pyramid network. At the final stage, after the deep network is ready, we evaluate our fully automated system in two different ways on more than 230 patients and 7996 images. We also investigate the infected areas of the COVID-19 classified images by segmenting the infections using a feature visualization algorithm. The general view of our work in this paper is represented in fig. 1. ![Figure 1:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F1.medium.gif) [Figure 1:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F1) Figure 1: General view of our proposed method for automated patients classification. In [21, 17], using existing deep learning networks, they have identified COVID-19 on chest X-ray images and introduced the network with high accuracy. In [23], by concatenating Xception and Resnet50v2 networks and using chest X-ray images, they were able to diagnose normal patients, pneumonia, and COVID-19, with an overall accuracy of 99.5 and 91.4 in the COVID-19 class, which was evaluated on 11302 images. In [14], 3322 eligible CT scans were selected from the 3506 CT scans of different persons and used to learn and evaluate the proposed network, COVNet. In another study, CT scans of 120 people (2482 CT scans) were collected, half of which (60 people) were COVID-19, and classified by different networks, which was the most accuracy equal to 97.38% [27]. In [12], CT scans of 287 patients were collected, including three classes of COVID-19, Community-acquired pneumonia (CAP), or other viral diseases in the lungs, and other diseases or healthy, and then, using the innovative algorithm called CovidCTNet, to classify the data with 90% accuracy. In [30], CT scans of 5372 patients have been collected in several hospitals in China, which have been used in learning and evaluating the presented Innovative Deep Learning Network to classify data into three classes. In [29], CT scans have been used to segment infections caused by the new coronavirus. The rest of the paper is organized as follows: In section 2, we will describe the dataset, neural networks, and proposed algorithm. In section 3, the experimental results are presented, and in section 4, the paper is discussed. In section 5, we have concluded our paper, and in the end, the links to the shared codes and dataset are provided. ## 2 Materials and methods ### 2.1 COVID-CTset COVID-CTset is our introduced dataset. It was gathered from Negin medical center located at Sari in Iran between March 5th to April 23rd, 2020. This medical center uses a SOMATOM Scope model and syngo CT VC30-easyIQ software version for capturing and visualizing the lung HRCT radiology images from the patients. The format of the exported radiology images was 16-bit grayscale DICOM format with 512*512 pixels resolution. As the patient’s information was accessible via the DICOM files, we converted them to TIFF format, which holds the same 16-bit grayscale data but does not conclude the patients’ private information. In the addressed link at the end of this paper, the general information (age, sex, time of radiology imaging) for each patient is available. One of our novelties is using a 16bit data format instead of converting it to 8bit data, which helps improve the method’s results. Converting the DICOM files to 8bit data may cause losing some data, especially when few infections exist in the image that is hard to detect even for clinical experts. This lost data may be the difference between different images or the values of the pixels of the same image. The pixels’ values of the images differ from 0 to almost 5000, and the maximum pixels values of the images are considerably different. So scaling them through a consistent value or scaling each image based on the maximum pixel value of itself can cause the mentioned problems and reduce the network accuracy. So each image of COVID-CTset is a TIFF format, 16bit grayscale image. In some stages of our work, we used the help of clinical experts under the supervision of the third author, a radiology specialist, to separate those images that the COVID-19 infections are clear. To make these images visible with regular monitors, we converted them to float by dividing each image’s pixel value by the maximum pixel value of that image. This way, the output images had a 32bit float type pixel values that could be visualized by regular monitors, and the quality of the images was good enough for analysis. Some of the images of our dataset are presented in fig. 2. ![Figure 2:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F2.medium.gif) [Figure 2:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F2) Figure 2: Some of the images in COVID-CTset COVID-CTset is made of 15589 images that belong to 95 patients infected to COVID-19 and 48260 images of 282 normal people (table 1). Each patient had 3 folders that each folder includes the image sequence of one time period that the lung opens and closes. View this table: [Table 1:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T1) Table 1: COVID-CTset data distribution The distribution of the patients in COVID-CTset is shown in fig. 3 ![Figure 3:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F3.medium.gif) [Figure 3:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F3) Figure 3: This figure shows the number of patients based on age, gender and infections. ### 2.2 CT scans Selection The lung HRCT scan device takes a sequence of consecutive images(we can call it a video or consecutive frames) from the chest of the patient that wants to check his infection to COVID-19. In an image sequence, the infection points may appear in some images and not be shown in other images. The clinical expert analyzes theses consecutive images and, if he finds the infections on some of them, indicates the patient as infected. Many previous methods selected an image of each patient’s lung HRCT images and then used them for training and validation. Here we decide to make the patient lung analysis fully automated. Consider we have a neural network that is trained for classifying CVOID-19 cases based on a selected data that inside the lung was obviously visible in them. If we test that network on each image of an image sequence the belongs to a patient, the network may fail. Because at the beginning and the end of each CT scan image sequence, the lung is closed as it is depicted in fig. 4. Hence, the network has not seen these cases while training; it may result in wrong detections, and so does not work well. ![Figure 4:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F4.medium.gif) [Figure 4:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F4) Figure 4: This figure presents some of the first, middle, and final images of a patient CT scans sequence. It is obvious from the images that in the first and the last images, inside the lung is not observable. To solve this, we can separate the dataset into three classes: infection-visible,no-infection, and lung-closed. Although this removes the problem but dividing the dataset into three classes has other costs like spending some time for making new labels, changing the network validation way. Also, it increases the processing time because the network shall see all the images of patient CT scans. But we propose some other techniques to discard the images that inside the lungs are not visible in them. Doing this also reduces performing time for good because, in the last method, the networks should have seen all the images, and now it only sees some selected images. Fig. 6 shows the steps of the image-selection algorithm. As it is evident from fig. 5, the main difference between an open lung and closed lung is that the open lung image has lower pixel values(near to black) in the middle of the lung. First, we set a region in the middle of the images for analyzing the pixel values in them. This region should be at the center of the lung in all the images, so open-lung and closed-lung show the differences in this area. Unfortunately, the images of the dataset were not on one scale, and the lung’s position differed for different patients; so after experiments and analysis, as the images have 512*512 pixels resolution, we set the region in the area of 120 to 370 pixels in the x-axis and 240 to 340 pixels in the y-axis ([120,240] to [370,340]). This area shall justify in containing the information of the middle of the lung in all the images. Fig. 7 shows the selected region in some different images. ![Figure 5:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F5.medium.gif) [Figure 5:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F5) Figure 5: It can be visualized from this figure that a closed-lung has higher pixels values in the middle of the image. ![Figure 6:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F6.medium.gif) [Figure 6:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F6) Figure 6: The flowchart of the proposed algorithm for selecting the efficient CT scan images of a sequence ![Figure 7:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F7.medium.gif) [Figure 7:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F7) Figure 7: The selected region in different images with different scales The images of our dataset are 16-bit grayscale images. The maximum pixel value between all the images is almost equal to 5000. This maximum value differs very much between different images. At the next step for discarding some images and selecting the rest of them from an image sequence that belongs to a patient, we aim to measure the pixels of each image in the indicated region that have less value than 300, which we call dark pixels. This number was chosen out of our experiments. For all the images in the sequence, we count the number of pixels in the region with less value than 300. After that, we would divide the difference between the maximum counted number, and the minimum counted number by 1.5. This calculated number is our threshold. For example, if a CT scan image sequence of a patient has 3030 pixels with a value of less than 300 in the region, and another has 30 pixels less than 300, the threshold becomes 2000. The image with less dark pixels in the region than the threshold is the image that the lung is almost closed in that, and the image with more dark pixels is the one that inside the lung is visible in it. We calculated this threshold in this manner that the images in a sequence (CT scans of a patient) be analyzed together because, in one sequence, the imaging scale does not differ. After that, we discard those images that have less counted dark pixels than the calculated threshold. So the images with more dark pixels than the computed threshold will be selected to be given to the network for classification. In fig. 8, the image sequence of one patient is depicted, where you can observe which of the images the algorithm discards and which will be selected. ![Figure 8:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F8.medium.gif) [Figure 8:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F8) Figure 8: The CT scan images of a patient are shown in this figure. The highlighted images are the ones that the algorithm discards. It is observable that those images that clearly show inside the lung are selected to be classified at the next stage. ### 2.3 Deep convolutional neural networks Machine Vision has been a superior method for advancing many fields like Agriculture [22], biomedical engineering[24, 20], industry [13] and others. Implementation of machine vision methods on the deep neural networks, especially using the convolution layers, has resulted in extremely accurate performing. In this research, at the next stage of our work, we used deep convolution networks to classify the selected image of the first stage into normal or COVID-19. We utilized Xception [5], ResNet50V2 [11] and a modified version of ResNet50V2 for running the classification. Xception introduced new inception modules constructed of depth-wise, separable convolution layers (depth-wise convolutional layers followed by a point-wise convolution layer). Xception achieved one of the best results on ImageNet [7] dataset. ResNet50V2, is a upgraded version of ResNet50 [10]. In this neural network, the authors made some changes in the connections and skip-connections between blocks and increased network performance in the ImageNet dataset. Feature pyramid network(FPN) was introduced by paper [15] and was utilized in RetinaNet [16] for enhancing object detection. FPN helps the network better learning and detecting the multi-scale objects that may exist in an image. Some of the previous methods worked by giving an image pyramid (that includes different scales of the input image) to the network as the input. Doing this indeed improves the feature extraction process but also increases the processing time and is not efficient. FPN solves this problem by generating a bottom-up and a top-down feature hierarchy with lateral connections from the network generated features at different scales. This helps the network generate more semantic features for objects at different scales. As it is described using FPN helps when there are objects with different scales in the image. Although here we investigate image classification, to do this, the network must learn about the infection points and classify the image based on them. Using FPN can help us better classify the images in our cases. In fig. 9 you can see the architecture of the proposed network. We used concatenation layers instead of adding layers in the default version of the feature pyramid network [15] due to the authors’ experience. At the end of the network, we concatenated the five classification results of the feature pyramid outputs(each output presents classification based on one scale features) and gave it to the classifier so that the network can use all of them for better classification. ![Figure 9:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F9.medium.gif) [Figure 9:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F9) Figure 9: This figure shows the enhanced version of ResNet50V2 with feature pyramid network for classification. ### 2.4 Training Phase Our dataset is constructed of two sections. The first section is the raw data for each person that is described in section 2.1. The second section includes training and validation data. We converted the images to 32-bit float types on the TIFF format so that we could visualize them with regular monitors. Then we took the help of the clinical experts under the supervision of the third author(Radiology Specialist) in the Negin medical center to select the infected patients’ images that the infections were clear on them. We used these data for training and validating the trained networks. To report more real and accurate results, we separated the dataset into five folds for training and validation. Almost 20 percent of the patients with COVID19 were allocated for validation in each fold, and the rest were considered for training. Because the number of normal patients and images was more than the infected ones, we almost chose the number of normal images equal to the COVID-19 images to make the dataset balanced. Therefore the number of normal images that were considered for network validation was higher than the training images. The details of the training and validation data are reported in table 2. View this table: [Table 2:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T2) Table 2: Training and Validation details of CT-COVID-Set From the information in table 2, the question may arise as to why the number of normal persons in the training set is less than the number of COVID-19 patients. Because in each image sequence of a patient with COVID-19, we allocated some of them with observable infections for training and validation. So the number of images for a COVID-19 patient is less than the number of images for a normal person. We selected enough number of normal patients that the number of normal images is almost equal to the number of images of COVID-19 class. This number was enough for the network to learn to classify the images correctly, and the achieved results were high. As we had more normal images left, We selected a large number of normal data for validation so that the actual performance of our trained networks be more clear. We trained our dataset on Xception[5], Resnet50V2[11] and the modified ResNet50V2(With FPN) until 50 epochs. For training the networks, we used transfer learning from the ImageNet [7] pre-trained weights to make the networks convergence faster. We chose the Nadam optimizer and the Categorical Cross-entropy loss function. We also used data augmentation methods to make learning more efficient and stop the network from overfitting. It is noteworthy that we did not resize the images for training or validation so as not to lose the small data of the infections. Our training parameters are listed in table 3. View this table: [Table 3:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T3) Table 3: Training Parameters As is evident from table 3, we used the same parameters for all the networks. ## 3 Experimental results In this section, we report the results into two sections. The Image classification results section includes the results of the trained networks on the Validation Set images. The Patient identification section reports the results of the automated system for identifying each person as normal or COVID-19. We implemented our algorithms and networks on [Google Colaboratory Notebooks](https://colab.research.google.com/), which allocated a Tesla P100 GPU, 2.00GHz Intel Xeon CPU, and 12GB RAM on Linux to us. We used Keras library [6] on Tensorflow backend [1] for developing and running the deep networks. ### 3.1 Image classification results We trained each network on the training set and with the explained parameters in section 2.4. We also used the accuracy metric while training for monitoring the network validation result after each epoch to find the best converged of the trained network. We evaluated the trained networks using four different metrics for each of the classes and the overall accuracy for all the classes as follows: ![Formula][1] ![Formula][2] ![Formula][3] ![Formula][4] ![Formula][5] In these equations, for each class, *TP* (True Positive) is the number of correctly classified images, *FP* (False Positive) is the number of the wrong classified images, *FN* (False Negative) is the number of images that have been detected as a wrong class, and *TN* (True Negative) is the number of images that do not belong to another class and have not been classified as that class. The results for each fold is reported in table 6. We also showed the average results between five folds in confusion matrices in fig. 10. View this table: [Table 4:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T4) Table 4: Patients identification results View this table: [Table 5:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T5) Table 5: This table shows the speed of the fully automated system based on ResNet50V2 with FPN for CT scans of different patients with various CT scan slices. View this table: [Table 6:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/T6) Table 6: Validation results for each network in each fold ![Figure 10:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F10.medium.gif) [Figure 10:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F10) Figure 10: The average data between five folds are shown on these confusion matrices ### 3.2 Patient identification In this section, we present the main results of our work. If our proposed fully-automated system wants to check the infection of COVID-19 for a patient, it takes all the images of the patient CT scans as input. Then it processes them with the proposed CT scan selection algorithm to select the CT scans that the lung is visible in them. Those chosen images will be fed to the deep neural network to be classified as COVID-19 or normal. Based on the experiments, the infections are usually visible in at least 20 percent of the selected CT scan images(Those images that inside the lung is visible in them) of an infected patient. So as there might be errors in the trained networks, we set a threshold equal to 30, which means if 30 percent of the selected CT scan images of a person be identified as COVID-19, then that person would be considered as an infected one. Otherwise, the system indicates that person as normal. The results of Patient identification for each of the trained networks in each fold are available in table 4. The speed of the fully automated system is reported in table 5. ### 3.3 Feature Visualization In this section, we aim to use the Grad-CAM algorithm [25] to visualized the extracted features of the network to determine the areas of infections and investigate the network’s correct performance. By looking at Fig. 11 and comparing the normal and COVID images; it is visible that the network is classifying the images based on the infected areas. In the COVID-19 images, the highlighted features are around the areas around the infections, and in the normal images, as the network does not see any infections, the highlighted features would be at the center showing the no infections have been found. Therefore the results can be trusted for medical diagnosis. Using the Grad-CAM algorithm can help the medical expert distinguish the CT scan images better and find the infections. ![Figure 11:](http://medrxiv.org/https://www.medrxiv.org/content/medrxiv/early/2020/07/04/2020.06.08.20121541/F11.medium.gif) [Figure 11:](http://medrxiv.org/content/early/2020/07/04/2020.06.08.20121541/F11) Figure 11: Visualized Features by Grad-Cam algorithm to show that the network is operating correctly and indicate the infection regions in the COVID-19 CT Scans ## 4 Discussion Based on the results from table 6 and table 4, we understand that the combination of ResNet50V2 with feature pyramid network made better overall accuracy. In the single image validation phase(table 6), the average results between five-folds show that Resnet50V2 with FPN achieved 98.49% overall accuracy and 94.96% sensitivity for COVID-19 class. Xception evaluation results show 96.55 % overall accuracy and 98.02% COVID-19 sensitivity. Also, Xception performed better in detecting COVID-19 patients, but the ResNet50V2 with FPN showed better results overall. The reason COVID class precision is not very high, like accuracy or sensitivity, is caused by having an unbalanced test dataset, in which we had around 450 COVID-19 images and 7800 normal images for testing the network performance. ResNet50V2 averagely miss-classified 102 images from 7852 normal images as CODIV-19, which is a good value, but because the number COVID-19 images are much lower than normal test images, it made the CoVID-19 precision around 81 percent. So this value of precision does not mean the network is performing poorly. At the fully automated patient classification, the average results between five folds in table 4 show that ResNet50V2 with FPN achieved the best results and approximately correctly classifies 237 persons from 245 persons, which is an acceptable value. Other networks showed good results, too, meaning that applying the proposed methods can make a precise, fully automated system for detecting the infected persons. Fig. 11 also present some of the classified images that are processed by the Grad-Cam algorithm to visualize their features on them. Based on this figure, the system is classifying the images on correct points, and the results are trustworthy. From table 5, it can be understood that the processing speed is good. As one CT scan image sequence of patients have less than 100 images in most cases, this system can process them near 4 to 6 seconds. The reason some of the CT scan slices with a close difference, differ in speed more than what is expected, is that the CT scan selection algorithm may select different proper CT scan images and so the processing speed changes more than expectation. What makes this work superior to other works, is that this research can be implemented for real diagnosis because it has been designed to work with the whole CT scan image sequences of any patient with high accuracy and speed. Previous works may claim to be close to automated system but as most of them have never evaluated this sytem on real circumstances they can not be trusted. What makes this work superior to other works, is that this research can be implemented for real diagnosis because it is designed to work with the whole original CT scan image sequences of patients produced by CT imaging device with high accuracy and speed. Previous works may claim to be close to the automated operation, but most of them have never evaluated their methods in real circumstances for automatic detection such as evaluation for each patient separately(on the whole original CT scans) and, on a large number of images, and not reporting network speed. Because of these matters, they can not be trusted in real COVID-19 diagnosis. We hope that our shared dataset and codes can help other researchers improve these techniques and use them for advanced medical diagnosis. ## 5 Conclusion In this paper, we have proposed a fully automated system for COVID-19 detection from lung HRCT scans. We also introduced a new dataset containing 15589 images of normal persons and 48260 images belonging to patients with COVID-19. At the first stage, we proposed an image processing algorithm to filter the proper images of the patients’ CT scans, which show inside the lung correctly. This algorithm helps increase network accuracy because the deep network would analyze only the appropriate images. Also, as the network only sees some of the CT scan images, it makes the processing faster. In this research, to make the classification and network feature extraction more accurate, we used the original produced files of the CT scan device for training and validation, which are 16-bit grayscale images. At the next stage, we trained three different deep convolution networks for classifying the CT scan images into COVID-19 or normal. One of these networks was the enhanced version of ResNet50V2 with a feature pyramid network that achieved the best overall accuracy. After training, we used the trained networks for running the fully automated COVID-19 identifier system. We tested that system on more than 230 patients and 7796 images. For single image classification, Resnet50V2 with FPN and Xception networks showed 94.96% and 98.02% sensitivity for COVID-19 class and 98.49% and 96.55% overall accuracy, respectively. At the final and main evaluation phased of the proposed automated system, the ResNet50V2 with FPN obtained the best results and correctly identified approximately 237 patients from 245 patients averagely between five folds. We also used the feature-visualizing algorithm to highlight the infection areas of the CT scan images. Based on the obtained results, it can be understood the proposed methods can improve COVID-19 detection accuracy and can run fast enough for implementation in medical centers. We hope that our methods and dataset can help the researchers to improve COVID-19 monitoring and detection. The obtained materials and methods of this paper have been tested in real circumstances and will be implemented in some medical centers in Iran, so we hope these methods be also utilized in other places in the world to improve COVID-19 monitoring. ## Data Availability Data and Codes are available at:[https://github.com/mr7495/COVID-CT-Code](https://github.com/mr7495/COVID-CT-Code) [https://github.com/mr7495/COVID-CTset](https://github.com/mr7495/COVID-CTset) [https://github.com/mr7495/COVID-CT-Code](https://github.com/mr7495/COVID-CT-Code) [https://github.com/mr7495/COVID-CTset](https://github.com/mr7495/COVID-CTset) ## 6 Data availability We have made our data available for public use in this address: ([https://github.com/mr7495/COVID-CTset](https://github.com/mr7495/COVID-CTset)). The dataset is available in two parts: one is the raw data that is presented in three folders for each patient. The next part is the training and validation data in each fold. We hope that this dataset will be utilized for improving COVID-19 monitoring and detection in the coming researches. ## 7 Code availability All the used codes for data analysis, training, and validation and the trained networks are shared in ([https://github.com/mr7495/COVID-CT-Code](https://github.com/mr7495/COVID-CT-Code)). ## Ethics Statement We declare that this paper is original and has been read and approved by all named authors and that there are no other persons who satisfied the criteria for authorship but are not listed. We further confirm that all have approved the order of authors listed in the paper of us. All the patients’ shared data have been approved by Negin Radiology Medical Center located at Sari, Iran, under the supervision of its director(Dr.Sakhaei, radiology specialist) and Dr.Mahdi Hassanzadeh. It must be mentioned that to protect patients’ privacy, all the DICOM files have been converted to TIFF format files to remove the patients’ information. ## Acknowledgment We wish like to thank Negin medical center experts that helped us in proving the dataset. We also like to appreciate Google for providing free and powerful GPU on [Colab servers](https://colab.research.google.com/) and free space on [Google Drive](https://accounts.google.com/signin/v2/identifier?service=wise&passive=1209600&continue=https%3A%2F%2Fdrive.google.com%2F&followup=https%3A%2F%2Fdrive.google.com%2F&emr=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin). * Received June 8, 2020. * Revision received July 3, 2020. * Accepted July 4, 2020. * © 2020, Posted by Cold Spring Harbor Laboratory This pre-print is available under a Creative Commons License (Attribution-NonCommercial-NoDerivs 4.0 International), CC BY-NC-ND 4.0, as described at [http://creativecommons.org/licenses/by-nc-nd/4.0/](http://creativecommons.org/licenses/by-nc-nd/4.0/) ## References 1. [1]. M. Abadi, A. Agarwal, P. Barham, E. Brevdo, Z. Chen, C. Citro, G. S. Corrado, A. Davis, J. Dean, M. Devin, S. Ghemawat, I. Goodfellow, A. Harp, G. Irving, M. Isard, Y. Jia, R. Jozefowicz, L. Kaiser, M. Kudlur, J. Levenberg, D. Mané, R. Monga, S. Moore, D. Murray, C. Olah, M. Schuster, J. Shlens, B. Steiner, I. Sutskever, K. Talwar, P. Tucker, V. Vanhoucke, V. Vasudevan, F. Viégas, O. Vinyals, P. Warden, M. Wattenberg, M. Wicke, Y. Yu, and X. Zheng. TensorFlow: Large-scale machine learning on heterogeneous systems, 2015. Software available from tensorflow.org. 2. [2].ACR. Acr recommendations for the use of chest radiography and computed to-mography (ct) for suspected covid-19 infection | american college of radiology. [https://www.acr.org/Advocacy-and-Economics/ACR-Position-Statements/Recommendations-for-Chest-Radiography-and-CT-for-Suspected-COVID19-Infection](https://www.acr.org/Advocacy-and-Economics/ACR-Position-Statements/Recommendations-for-Chest-Radiography-and-CT-for-Suspected-COVID19-Infection), 05 2020. (Accessed on 05/31/2020). 3. [3]. T. Ai, Z. Yang, H. Hou, C. Zhan, C. Chen, W. Lv, Q. Tao, Z. Sun, and L. Xia. Correlation of chest ct and rt-pcr testing in coronavirus disease 2019 (covid-19) in china: a report of 1014 cases. Radiology, page 200642, 2020. 4. [4]. J.-Z. Cheng, D. Ni, Y.-H. Chou, J. Qin, C.-M. Tiu, Y.-C. Chang, C.-S. Huang, D. Shen, and C.-M. Chen. Computer-aided diagnosis with deep learning architecture: applications to breast lesions in us images and pulmonary nodules in ct scans. Scientific reports, 6(1):1–13, 2016. 5. [5]. F. Chollet. Xception: Deep learning with depthwise separable convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1251–1258, 2017. 6. [6]. F. Chollet and Others. keras, 2015. 7. [7]. J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009. 8. [8].Geneticeducation. Reverse transcription pcr: Principle, procedure, application, advantages and disadvantages. [https://geneticeducation.co.in/reverse-transcription-pcr-principle-procedure-applications-advantages-and-disadvantages/#Disadvantages](https://geneticeducation.co.in/reverse-transcription-pcr-principle-procedure-applications-advantages-and-disadvantages/#Disadvantages), 05 2020. (Accessed on 05/31/2020). 9. [9]. G. P. Green, J. C. Bean, and D. J. Peterson. Deep learning in intermediate microeconomics: Using scaffolding assignments to teach theory and promote transfer. The Journal of Economic Education, 44(2):142–157, 2013. 10. [10]. K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016. 11. [11]. K. He, X. Zhang, S. Ren, and J. Sun. Identity mappings in deep residual networks. Lecture Notes in Computer Science, page 630–645, 2016. 12. [12]. T. Javaheri, M. Homayounfar, Z. Amoozgar, R. Reiazi, F. Homayounieh, E. Abbas, A. Laali, A. R. Radmard, M. H. Gharib, S. A. J. Mousavi, et al. Covidctnet: An open-source deep learning approach to identify covid-19 using ct image. arXiv preprint arxiv:2005.03059, 2020. 13. [13]. L. Li, K. Ota, and M. Dong. Deep learning for smart industry: Efficient manufacture inspection system with fog computing. IEEE Transactions on Industrial Informatics, 14(10):4665–4673, 2018. 14. [14]. L. Li, L. Qin, Z. Xu, Y. Yin, X. Wang, B. Kong, J. Bai, Y. Lu, Z. Fang, Q. Song, et al. Artificial intelligence distinguishes covid-19 from community acquired pneumonia on chest ct. Radiology, page 200905, 2020. 15. [15]. T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, and S. Belongie. Feature pyramid networks for object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2117–2125, 2017. 16. [16]. T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár. Focal loss for dense object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018. 17. [17]. Z. Q. L. Linda Wang and A. Wong. Covid-net: A tailored deep convolutional neural network design for detection of covid-19 cases from chest radiography images, 2020. 18. [18]. G. Litjens, T. Kooi, B. E. Bejnordi, A. A. A. Setio, F. Ciompi, M. Ghafoorian, J. A. Van Der Laak, B. Van Ginneken, and C. I. Sánchez. A survey on deep learning in medical image analysis. Medical image analysis, 42:60–88, 2017. [CrossRef](http://medrxiv.org/lookup/external-ref?access_num=10.1016/j.media.2017.07.005&link_type=DOI) [PubMed](http://medrxiv.org/lookup/external-ref?access_num=28778026&link_type=MED&atom=%2Fmedrxiv%2Fearly%2F2020%2F07%2F04%2F2020.06.08.20121541.atom) 19. [19].Lybrate. Huntington’s disease - understanding the stages of symptoms! - by ms. sadhana ghaisas | lybrate. [https://www.lybrate.com/topic/huntington-s-disease-understanding-the-stages-of-symptoms/](https://www.lybrate.com/topic/huntington-s-disease-understanding-the-stages-of-symptoms/) 51a9194e8afa17a117aa5b8db364f2eb, 05 2020. (Accessed on 05/31/2020). 20. [20]. P. Mlynarski, H. Delingette, H. Alghamdi, P.-Y. Bondiau, and N. Ayache. Anatomically consistent cnn-based segmentation of organs-at-risk in cranial radiotherapy. Journal of Medical Imaging, 7(1):014502, 2020. 21. [21].Narin, C. Kaya, and Z. Pamuk. Automatic detection of coronavirus disease (covid-19) using x-ray images and deep convolutional neural networks. arXiv preprint 2003.10849, 2020. 22. [22]. M. Rahimzadeh and A. Attar. Introduction of a new dataset and method for detecting and counting the pistachios based on deep learning. arXiv preprint 2005.03990, 2020. 23. [23]. M. Rahimzadeh and A. Attar. A modified deep convolutional neural network for detecting covid-19 and pneumonia from chest x-ray images based on the concatenation of xception and resnet50v2. Informatics in Medicine Unlocked, page 100360, 2020. 24. [24]. M. Rahimzadeh, A. Attar, et al. Sperm detection and tracking in phase-contrast microscopy image sequences using deep learning and modified csr-dcf. arXiv preprint 2002.04034, 2020. 25. [25]. R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. International Journal of Computer Vision, 128(2):336–359, Oct 2019. 26. [26].Shen, G. Wu, and H.-I. Suk. Deep learning in medical image analysis. Annual review of biomedical engineering, 19:221–248, 2017. [CrossRef](http://medrxiv.org/lookup/external-ref?access_num=10.1146/annurev-bioeng-071516-044442&link_type=DOI) [PubMed](http://medrxiv.org/lookup/external-ref?access_num=28301734&link_type=MED&atom=%2Fmedrxiv%2Fearly%2F2020%2F07%2F04%2F2020.06.08.20121541.atom) 27. [27].Soares, P. Angelov, S. Biaso, M. H. Froes, and D. K. Abe. Sars-cov-2 ct-scan dataset: A large dataset of real patients ct scans for sars-cov-2 identification. medRxiv, 2020. 28. [28].Song, N. Shi, F. Shan, Z. Zhang, J. Shen, H. Lu, Y. Ling, Y. Jiang, and Y. Shi. Emerging 2019 novel coronavirus (2019-ncov) pneumonia. Radiology, 295(1):210–217, 2020. [CrossRef](http://medrxiv.org/lookup/external-ref?access_num=10.1148/radiol.2020200274&link_type=DOI) [PubMed](http://medrxiv.org/lookup/external-ref?access_num=http://www.n&link_type=MED&atom=%2Fmedrxiv%2Fearly%2F2020%2F07%2F04%2F2020.06.08.20121541.atom) 29. [29].Voulodimos, E. Protopapadakis, I. Katsamenis, A. Doulamis, and N. Doulamis. Deep learning models for covid-19 infected area segmentation in ct images. medRxiv, 2020. 30. [30]. S. Wang, Y. Zha, W. Li, Q. Wu, X. Li, M. Niu, M. Wang, X. Qiu, H. Li, H. Yu, et al. A fully automatic deep learning system for covid-19 diagnostic and prognostic analysis. European Respiratory Journal, 2020. 31. [31].WHO. Q&a on coronaviruses (covid-19). [https://www.who.int/emergencies/diseases/](https://www.who.int/emergencies/diseases/) novel-coronavirus-2019/question-and-answers-hub/q-a-detail/q-a-coronaviruses, 05 2020. (Accessed on 05/31/2020). 32. [32].Wikipedia. Covid-19 testing - wikipedia. [https://en.wikipedia.org/wiki/COVID-19\_testing](https://en.wikipedia.org/wiki/COVID-19_testing), 05 2020. (Accessed on 05/31/2020). 33. [33]. X. Xie, Z. Zhong, W. Zhao, C. Zheng, F. Wang, and J. Liu. Chest ct for typical 2019-ncov pneumonia: relationship to negative rt-pcr testing. Radiology, page 200343, 2020. 34. [34]. W. Yang, Y. Chen, Y. Liu, L. Zhong, G. Qin, Z. Lu, Q. Feng, and W. Chen. Cascade of multi-scale convolutional neural networks for bone suppression of chest radiographs in gradient domain. Medical image analysis, 35:421–433, 2017. [1]: /embed/graphic-13.gif [2]: /embed/graphic-14.gif [3]: /embed/graphic-15.gif [4]: /embed/graphic-16.gif [5]: /embed/graphic-17.gif