Past months have been sadly tied up with the novel coronavirus (COVID-19) outbreak resulting in long term damages to the society and people's lives. As such, a global action plan has been established to prevent the spread of this highly contagious disease including attempts to find vaccines and early diagnosis of the disease. The latter is highly important for the immediate isolation and treatment of the COVID-19 positive cases. The gold standard diagnostic test for this disease is the Reverse Transcription Polymerase Chain Reaction (RT-PCR), which is associated with a high false negative rate [1] . RT-PCR is also a time-consuming test, which may deprive health authorities from the opportunity of early isolation resulting in further spread of the virus. Recent studies have demonstrated the strong capability of Chest Radiographs (CR) and Computed Tomography (CT) scans in providing distinctive patterns associated with the COVID-19 infection such as bilateral prevalence of Ground Glass Opacities (GGO) with peripheral and subpleural distribution and lower lung zone predominance. Halo and reverse halo signs, focal areas of consolidations and interstitial thickening have also been described [2, 3] . COVID-19 lung manifestations, however, are highly overlapped with the Community Acquired Pneumonia (CAP) findings making their identification challenging and complicated even for experienced radiologists and healthcare professionals.
Recently, several research studies have developed deep learningbased approaches to identify COVID-19 disease from chest radiographs, some of which acquired promising performances [4] [5] [6] [7] . Both chest radiograph and CT scan provide a view of the structures inside the body by sending an electromagnetic radiation to the body and capturing the radiation passed through the body on a detector. However, chest radiographs are single 2D images that provide limited details of the lung infections. CT scans, on the other hand, consist of multiple cross-sectional images of the body (slices), which are seen together to create a 3D representation of the body. Unlike chest radiographs, CT scans can provide a comprehensive illustration of the specific structure of the lung abnormalities. Consequently, CT has a higher sensitivity compared to CR especially in the case of COVID-19 detection, where there is a high overlap with other lung infections such as CAP and therefore a fast and accurate diagnosis is imperative. Due to the radiation exposure caused by CT scans and the chance of virus spread during the scanning, CT scan is mainly recommended as diagnostic tools in emergency settings and to assist radiologists evaluating patients with suspected or confirmed COVID-19 infection [8] . However, chest CT is widely used as a primary diagnostic imaging modality in many countries, especially in those where RT-PCR test resources are low. Therefore, several studies have investigated possible deep solutions to identify COVID-19 from 2D and 3D CT images. Analyzing a series of CT scan slices, however, is more challenging compared to a single chest radiograph as we have to review several images and investigate the evidence of infection over multiple slices.
Contributions: In this paper, we propose a fully automated framework based on Capsule Networks [9] , referred to as the "CT-CAPS", to represent each slice of a CT scan by a small feature map to distinguish COVID-19 cases from non-COVID (CAP and normal) cases. The capsule network is selected to address the failure of the commonly used CNN architectures [10] in recognizing spatial relations between objects in an image and thus eliminate the need for large labeled datasets to reach a satisfying result. Large datasets are difficult to obtain in the case of a novel and barely recognized disease such as COVID-19. Furthermore, CNN architectures consist of millions of parameters making their training process slow and complex. Medical images, in particular COVID-19 related ones, contain distinctive spatial relations between image instances. For example, there is a distinctive distribution of imaging findings in COVID-19 infection on CT scans, which makes finding spatial relations in the image highly important. Moreover, the superiority of Capsule Networks over their counterparts is demonstrated in some of our previous research studies based on various imaging modalities such as magnetic resonance imaging (MRI) and chest radiographs (CR) [4, [11] [12] [13] .
In this study, a Capsule Network-based feature extractor is presented to detect specific characteristics of CT slices, followed by a Max Pooling Layer to convert slice-level feature maps into patientlevel ones. Finally, a stack of fully connected layers are added to make the final decision. The CT-CAPS is trained on a dataset of CT slices labeled by three experienced radiologists [14] to determine slices demonstrating infection and slices without an evidence of infection. The main focus of our labeling process was to detect distinctive and obvious abnormalities in a CT scan not struggling to identify minor findings of questionable infection. Therefore, CT-CAPS framework benefits from a fast and timely labeling process, which is highly valuable when we are facing an early emergence of a new type of data. The experimental results on our in-house dataset of 307 patients [14] demonstrate the capability of CT-CAPS model to be trained on such a coarsely labeled dataset achieving the accuracy of 90.8%, sensitivity of 94.5%, specificity of 86.0%, and Area Under the ROC Curve (AUC) of 0.93 using the cut-off probability of 0.6. To improve on the explanability of the proposed CT-CAPS, we incorporated the Grad-CAM localization mapping approach [15] to determine the lung regions contributing the most to the final decision. The %95 Confidence Interval (CI) values are also calculated for all performance matrics using the methods explained in [16, 17] . The trained CT-CAPS model and the testing code are available publicly for open access at https://github.com/ShahinSHH/CT-CAPS.
Existing identification methods based on chest CT scans are generally divided into slice-level and patient-level methods. These works can further be classified into segmentation-based or feature extraction-based approaches. Segmentation-based methods [18] [19] [20] aim to train a model on a large dataset of annotated lung lesions to detect regions of infection and determine the disease severity and type. Although the lung segmentation task has been wellstudied [21] , infection segmentation requires an extensive collaboration with radiologists to perform the sophisticated infection and abnormality annotation task making the training process too complicated and time-consuming. Moreover, in some cases [19] , the overall performance is low for scenarios with mild lung infections. As an example of segmentation-based methods, Nguyen et al. [18] used a semi-supervised method based on pre-trained existing segmentation models to detect lung infected regions to be incorporated into a CNN-based classifier via an attention mechanism to increase the classification accuracy. The underlying approach reached the overall accuracy of 88% in the binary slice-level classification (COVID-19 and normal cases). In another study, Shi et al. [19] proposed a model, which extracts handcrafted radiomics features from the segmented lung and infected regions followed by a feature selection mechanism to feed multi-stage random forest classifiers to classify patients into four groups based on their infection size obtained from the first step. Then a random forest model is trained for each group as the final classifier achieving the accuracy of 87.0%, sensitivity of 90.7%, and specificity of 83.3%. As another example, Zhang et al. [20] proposed a two-stage method consisting of a sophisticated lung infection segmentation model, trained on a manually annotated chest CT scan dataset, followed by a 3D ResNet18 classification model [22] to classify patients into COVID-19, CAP, and normal cases. Their proposed method achieves the overall accuracy of 92.49%.
With regard to the feature extraction-based approaches, different frameworks have been recently introduced, commonly utilizing a CNN-based model. Such methods either use a 3D CNN to analyze the whole CT volume in a single stage, or apply 2D CNNs on CT slices and aggregate slice-level results via an aggregation mechanism. As an example, Wang et al. [23] fed a 3D CNN-based classifier with lung regions, segmented by a pre-trained U-Net [24] , achieving accuracy of 90.1%, sensitivity of 84.0%, and specificity of 98.2% on a dataset containing only COVID-19 and normal cases. Hu et al. [25] extended patient-level labels into slice-level and used the same label for all slices in a CT scan to train a deep model, utilizing the intermediate CNN layers to obtain classification features. These features are then combined to make the final decision. Their proposed method achieved the overall accuracy of 87.4% in the three-way classification. It is worth mentioning that using patient-level labels for all slices in a CT scan is not reasonable and will add errors into the system as each volume of CT scan contains many slices without any visible infection area. In another study, Li et al. [26] proposed a fully automated framework using a ResNet50 as the backbone to extract slice-level features followed by max pooling and fully connected dense layers for the ultimate goal of patientlevel classification achieving the sensitivities of 90%, 87%, and 94% for COVID-19, CAP, and normal cases, respectively. The aforementioned methods either require a carefully annotated data to segment regions of infection, or extend patient-level labels to all slices resulting in an unexplainable and potentially lower results. Moreover, some of the aforementioned works have only proposed slice-level classifiers, which makes such methods partially automated.
In this section, the CT-CAPS framework is introduced in detail. First, the in-house dataset of chest CT scans and the associated labeling and preprocessing steps used in this study are briefly described. Next, the detailed description of the model structure and processing pipeline is presented.
We used our recently released dataset of volumetric chest CT scans referred to as the "COVID-CT-MD" [14] , which includes 171 patients positive for COVID-19 infection, 60 patients with CAP, and 76 normal patients. A subset of 55 COVID-19, and 25 CAP cases in the COVID-CT-MD are analyzed by three experienced radiologist to detect slices with a distinctive evidence of infection. As mentioned earlier, there exist many slices without evidence of infection in a chest CT scan and commonly only a proportion of the lung is involved in the infection. The labeling process aims to specify slices with distinctive disease manifestations in a timely manner rather than those with minimal findings. The labeled subset of the data contains 4, 993 slices demonstrating infection and 18, 416 slices without evidence of infection. This labeled data is then randomly divided into three groups, including 60%, 10%, and 30% independent parts of the data, to train, validate, and test the feature extraction stage of the CT-CAPS framework. The remaining data is split with the same proportion and used along with the labeled data to train and evaluate the subsequent fully connected layer as the patient-level classifier. This research work is performed based on the policy certification number 30013394 of Ethical acceptability for secondary use of medical data approved by Concordia University. The COVID-CT-MD dataset is available online through Figshare 1 . For more information about the imaging settings and detailed description of the dataset, please refer to Reference [14] .
In order to remove the unimportant components and artifacts existing in a CT scan, we utilized a pre-trained U-Net-based lung region segmentation model [21] referred to as the "U-net (R231CovidWeb)", which has been fine-tuned specifically on the COVID-19 images. A sample of lung region extracted by this model is illustrated in Fig. 1 . It is worth mentioning that unlike segmenting infected regions, lung region segmentation is a well-studied topic and highly efficient models have been introduced so far. The input of the R231CovidWeb model is a CT scan with the original slice size of 512 × 512. The model returns the extracted lung tissues, which will further go through some normalization and resizing steps. More specifically, the output images will be normalized between 0 and 1 to help the generalizability and effective convergence of the model. Following the literature [20, 25] , we down-sampled the output images from the original 512 × 512 size to 256 × 256 to reduce the complexity and memory requirements with negligible loss of information. Finally, slices without visible lung tissues are excluded and the remaining ones are saved to be used in the CT-CAPS framework.
The CT-CAPS' pipeline is illustrated in Fig. 2 . The first stage of the CT-CAPS architecture consists of a 2D Capsule Network, which aims to classify 2D CT slices into COVID-19 and non-COVID images. This network is initialized by a stack of four convolutional lay-1 https://figshare.com/s/c20215f3d42c98f09ad0 ers along with a batch-normalization and one max pooling layer as shown in Fig. 3 . The last convolutional layer is then used to feed the subsequent Capsule Layers to extract deeper and smaller feature maps by the routing by agreement process defined in [9] . Two more capsule layers are subsequently added to the model, where the amplitude of the last one represents the probability of the input image belonging to each target class. In the next step, we aggregate slice-level features extracted by intermediate layers of the described network to move on to the patient-level domain. In this regard, the capsule layer before the last one is used as the representative feature map of the slices. Experimental results (presented later in Section 4) demonstrate the ability of this feature map to efficiently distinguish between COVID-19 and non-COVID images.
A max pooling layer is then applied on the feature maps associated with slices of a patient and the result is fed to a stack of four fully connected layers with the size of 256, 128, 32, and 2 respectively. Using this feature selection and max pooling, each 3D volume CT scan is represented by a small 32 × 16 matrix. In addition, we modified the loss function to compensate the relatively imbalanced training dataset. We used a weighted version of the loss function, such that a higher penalty rate is given to the less frequent class, which is COVID-19 in this case. For the fully connected layers, however, the class weights are equal. The loss function of the Capsule Network model is modified as follows
where N + represents the number of COVID-19 samples, N − is the number of non-COVID samples, loss + signifies the loss value associated with COVID-19 samples, and loss − is the loss value associated with non-COVID samples.
The feature extraction part of the CT-CAPS is trained on a dataset of 55 COVID-19, 25 CAP, and all 78 normal cases. The Adam optimizer with the initial learning rate of 1e−4, batch size of 16, and 100 epochs is used in the corresponding training step. For the fully connected patient-level classifier, the initial learning rate of 1e − 3, and 500 epochs are used. In each stage, the model with the lowest loss value on the validation set is considered as the final model for evaluation. The evaluation results on the COVID-CT-MD dataset [14] are presented in Table 4 . We compared the CT-CAPS with its duplicate but using the whole CT images without extracting the lung tissues. We also replaced the Capsule Layers in another experiment with two fully connected layers with the size of 128, while the rest of the architecture and parameters are kept the same. We then took the fully connected dense layer before the last layer as the new feature map to make a CNN-based alternative model for the comparison. In a similar experiment, Resnet50, which is the backbone of many similar works such as Reference [26] is used in the feature extraction stage. In this case, the fully connected layer with 2, 048 neurons before the last layer is taken as the feature map. The comparison results are presented in Table 4 . The CT-CAPS achieves the accuracy of 89.8%, high sensitivity of 94.5%, specificity of 83.7%, and Area Under the ROC Curve (AUC) of 0.93 using the default probability threshold of 0.5. It is worth mentioning that various cutoff probabilities can be used based on the radiologist's preference. A higher cut-off probability indicates the higher importance of the specificity, while the lower value indicates the higher importance of the sensitivity. In other words, radiologists can adjust this threshold to change the range of required confidence to consider a patient as a COVID-19 positive case or a non-COVID case. Experimental results show that increasing the probability threshold from 0.5 to 0.6 improves the accuracy to 90.8%, and the specificity to 86.0% while the sensitivity remains the same. Table 4 presents performance of the proposed CT-CAPS using different cut-off probabilities.
In addition to the aforementioned numerical results, we incorporated the GRAD-CAM localization mapping method to visualize the distinctive patterns in a chest CT scan recognized by the last convolutional layer of the CT-CAPS. Fig. 4 illustrates the recognized abnormal regions for two lung samples containing small evidences of COVID-19 infection. In these two examples, we can observe that the model correctly identified the regions of infection, which had the highest contribution to final decision. 
In this paper, we proposed a fully automated Capsule network-based framework, referred to as the "CT-CAPS", which extracts distinctive features of chest CT scans via Capsule Networks to identify COVID-19 cases in a coarsely-labeled dataset of COVID-19, CAP, and normal cases. The experimental results indicate the capability of the CT-CAPS to automatically analyze volumetric chest CT scans and distinguish different cases with the accuracy of 90.8%, high sensitivity of 94.5%, and specificity of 86.0%, using far less number of parameters and less sophisticated labeling process compared to its existing counterparts. We also showed that Capsules in the layer before the last one can be a proper compact feature representative of CT scans. Moreover, the benefits of extracting lung tissues in the CT-CAPS framework, and the flexibility of the model to be adjusted based on radiologists' preferences to achieve desired results have been demonstrated by the experimental results. As a final note, we will continue to further improve and validate our proposed method upon receiving new datasets from our collaborators in medical centers to modify our model based on a multi-center dataset.