You are currently viewing a new version of our website. To view the old version click .
Diagnostics
  • Article
  • Open Access

20 April 2023

COVID-19 Diagnosis in Computerized Tomography (CT) and X-ray Scans Using Capsule Neural Network

and
1
Research Centre, African Institute for Mathematical Sciences (AIMS) South Africa, Cape Town 7945, South Africa
2
Department of Computer Science and Informatics, University of the Free State, Phuthaditjhaba 9866, South Africa
3
Department of Mathematical Sciences, Stellenbosch University, Cape Town 7945, South Africa
*
Author to whom correspondence should be addressed.
This article belongs to the Special Issue AI and Big Data in Healthcare

Abstract

This study proposes a deep-learning-based solution (named CapsNetCovid) for COVID-19 diagnosis using a capsule neural network (CapsNet). CapsNets are robust for image rotations and affine transformations, which is advantageous when processing medical imaging datasets. This study presents a performance analysis of CapsNets on standard images and their augmented variants for binary and multi-class classification. CapsNetCovid was trained and evaluated on two COVID-19 datasets of CT images and X-ray images. It was also evaluated on eight augmented datasets. The results show that the proposed model achieved classification accuracy, precision, sensitivity, and F1-score of 99.929%, 99.887%, 100%, and 99.319%, respectively, for the CT images. It also achieved a classification accuracy, precision, sensitivity, and F1-score of 94.721%, 93.864%, 92.947%, and 93.386%, respectively, for the X-ray images. This study presents a comparative analysis between CapsNetCovid, CNN, DenseNet121, and ResNet50 in terms of their ability to correctly identify randomly transformed and rotated CT and X-ray images without the use of data augmentation techniques. The analysis shows that CapsNetCovid outperforms CNN, DenseNet121, and ResNet50 when trained and evaluated on CT and X-ray images without data augmentation. We hope that this research will aid in improving decision making and diagnostic accuracy of medical professionals when diagnosing COVID-19.

1. Introduction

Coronavirus disease 19 (COVID-19), one of the deadliest pandemics in the history of mankind, has swept through almost all the countries in the world [1]. Coronavirus has infected over 676 million people and killed over 6.88 million as of 17 March 2023, as indicated in the COVID-19 map of Johns Hopkins University. Unfortunately, the virus is still evolving, and new variants continue to emerge worldwide. Multiple nations, including Australia, Bangladesh, Denmark, India, Japan, and the United States, detected a novel immune-evasive COVID-19 strain (XBB) in August 2022, which is causing outbreaks in various nations. This shows that COVID-19 is still a threat, and there is a need for suitable techniques that can be used to tackle this pandemic.
Recently, computer-aided diagnosis technologies have become a fundamental part of routine clinical practice. These tools can be utilized to aid physicians in accurately diagnosing COVID-19 patients. Convolutional neural networks (CNNs) are one of the effective deep learning (DL) algorithms for building improved medical imaging systems. However, they are unable to handle input transformations effectively. In addition, CNNs must be trained on massive or augmented datasets to generate superior results. A capsule neural network (CapsNet) is a recent deep learning (DL) algorithm proposed by Hinton et al. [2]. CapsNets are resistant to image rotations and transformations [2], and they can produce excellent results when trained on small datasets [1,3].
This study proposes a CapsNet model for COVID-19 diagnosis using CT and X-ray images. This study also evaluates the robustness of CapsNets for image rotations and transformations. The main contributions of this study are as follows:
  • This study proposes an improved CapsNet technique for COVID-19 diagnosis (named CapsNetCovid). The proposed model was trained and evaluated on 14,000 CT images and 15,153 X-ray images. The results show that the proposed technique achieved good results for both CT and X-ray datasets. The full results are presented and discussed in Section 4.
  • As noted by the researchers that developed CapsNets [2], one of the key advantages of CapsNets over CNNs is its robustness to image rotations and affine transformations. To the best of the authors’ knowledge, no study has presented a performance analysis of CapsNet on different image rotations and transformations. This study presents a performance analysis of CapsNets on standard CT and X-ray images and their corresponding augmented variants. The analysis is presented for both binary classification and multi-class classification. The objective of the analysis is to evaluate the robustness of CapsNets to affine transformations.
  • To the best of the authors’ knowledge, no study has compared CapsNets and other CNN-based techniques in terms of their ability to recognize randomly transformed and rotated images. This study presents a comparative analysis between CapsNet, CNN, and two state-of-the-art CNN models, namely DenseNet121 and ResNet50. The comparative analysis is presented for both CT and X-ray images. The analysis compares the ability of CapsNet, CNN, DenseNet121, and ResNet50 to correctly identify randomly transformed and rotated CT and X-ray images without using data augmentation techniques.
This paper is organized as follows. A detailed review of related studies is presented in Section 2, and in Section 3, the methodology used in this study is presented. Furthermore, the dataset details and performance metrics used for evaluation are presented in Section 3. The results are presented and discussed in Section 4. The paper is finally concluded in Section 5.

3. Methodology

This study proposes a CapsNet architecture for COVID-19 diagnosis (CapsNetCovid). The architecture is shown in Figure 1. The same model was used for the CT and X-ray images. The model consists of convolutional layer, primary capsule layer, and digit capsule layer. The convolutional layer is used to extract features from images, the primary capsule layer is used to learn different image parts and features of an image (such as orientation, size, pose, texture, etc.) and the spatial relationships between the parts. The digit capsule layer is used to perform the final classification.
Figure 1. The proposed CapsNet architecture (CapsNetCovid).
Specifically, the proposed model consists of three convolutional layers, sixteen primary capsule layers, and one digit capsule layer. Three convolutional layers were added to the network after performing experiments with different number of layers, kernels, and filter sizes. The convolutional layers help to extract effective and informed features for the primary capsule. The first and second convolutional layer consists of 256 kernels of size 3 × 3 with a stride of 1. The third convolutional layer consist of 512 kernels of size 3 × 3 with a stride of 2. The ReLU activation function is used for all the layers. The ReLU activation function is used to introduce non-linearity to the model and handle the vanishing gradient problem.
Initially, images are passed through the three convolutional layers. The images are resized to 224 × 224 after experimenting with different image sizes. The output from the convolutional layer is passed to 16 primary capsule layers, where each capsule contains 8D vectors. The capsule layer applies convolutional operation with 9 × 9 kernel, and then squash the output to obtain a capsule. The output of the capsule layer is passed to a digit layer, containing 16D vectors per class. The layer is used to classify the CT images into two classes (COVID-19 and normal) and the X-ray images into three classes (COVID-19, normal, and pneumonia).
Another CNN model was designed in this study for the purpose of comparison. The CNN model consists of two convolutional layers, one fully connected layer, and one output layer. The proposed architecture was also compared with DenseNet121 and ResNet50. The output of DenseNet121 and ResNet50 was passed through two fully connected layers, and one output layer. The output layer consists of two neurons for the binary classification, and three neurons for the multi-class classification. The pooling and dropout layer was also used to improve the computation speed and prevent overfitting. Note that only the added layers were finetuned. The number of layers and parameters for the CapsNet model, CNN model, and the two pre-trained models were selected after performing the series of experiments. More information about the parameters is presented in Table 2, Table 3 and Table 4.
Table 2. Training Parameters for CapsNetCovid.
Table 3. Parameters used for DenseNet121 and ResNet50.
Table 4. CNN model parameters.
Different experiments were performed to evaluate the efficacy of CapsNetCovid. Firstly, CapsNetCovid was trained on 80% of the dataset and evaluated on the remaining 20%. Twenty percent of the training set was reserved for validation. After training, the trained CapsNetCovid was saved and used in the subsequent experiments. During the other experiments, the saved CapsNet model was evaluated on the eight augmented datasets. Note that the augmented datasets were not used to train CapsNetCovid; they were only used to evaluate the pre-trained CapsNetCovid. We did this to assess CapsNetCovid’s ability to distinguish precisely between standard, flipped, shifted, and rotated images. Additionally, we wanted to evaluate the CapsNet’s ability to recognize augmented images, even if it was not exposed to such images during training. The same procedure was carried out for CNN, DenseNet121, and ResNet50. The models were trained, validated, and tested on the original datasets. After training, their trained weights were saved and evaluated on the eight augmented datasets.

3.1. Dataset

Two types of datasets are used in this study. The first dataset type consists of standard images, while the second dataset type consists of augmented/transformed images. Standard images/datasets in this study refers to images/datasets that are not transformed (rotated or shifted).

3.1.1. Standard Dataset

Two datasets with standard images were used in this study. The first dataset was obtained from different sources, including China National Center for Bio-information [31], National Institutes of Health Intramural Targeted Anti-COVID-19 [32], Negin Radiology Medical Center [33], Union Hospital and Liyuan Hospital of Huazhong University of Science and Technology [34], COVID-19 CT Lung and Infection Segmentation initiative [35], and the Radiopaedia collection [36]. The dataset (called COVID-Net CT-2) was created by Gunraj et al. [37]. Readers are referred to [37] for more information on the dataset. A subset of the COVID-Net CT-2 dataset is used in this study. Samples of the dataset are shown in Figure 2. The dataset consists of 14,000 CT images (9000 COVID-19 images and 5000 non-COVID-19 images). The second dataset was created by some researchers at the university of Qatar [38,39]. The dataset consists of 3616 COVID-19 X-ray images, 10,192 normal X-ray images, and 1345 pneumonia X-ray images. The dataset is publicly available and it can be downloaded from [40].
Figure 2. Samples of standard and augmented CT images used for training.

3.1.2. Augmented Datasets

Eight new augmented datasets were generated from the original CT and X-ray datasets. The Keras ImageDataGenerator class was used to generate the augmented datasets. The first four augmented datasets consist of 14,000 randomly flipped CT images, 14,000 randomly shifted CT images, 14,000 CT images rotated randomly by 45 degrees, and 14,000 CT images rotated randomly by 90 degrees. The last four augmented datasets consist of 15,153 randomly flipped X-ray images, 15,153 randomly shifted X-ray images, 15,153 X-ray images rotated randomly by 45 degrees, and 15,153 X-ray images rotated randomly by 90 degrees. More details on the dataset are provided in Table 5. Additionally, the samples from the CT and X-ray standard and augmented dataset are shown in Figure 2 and Figure 3, respectively.
Table 5. Dataset summary.
Figure 3. Samples of standard and augmented X-ray images used for training.
During the pre-processing stage, the images’ pixel values were converted to the range 0 to 1 by dividing them by 255. This value was used because 255 is the maximum possible pixel value for an image. The images were also resized to 224 × 224 and used as inputs to the CapsNet model. Eighty percent of the dataset was used for training, while the remaining twenty percent was used to test the model. During training, 20 percent of the training images was used to validate the training performance. All the experiments were conducted on a computer cluster. The cluster computer had the following specifications: 2 × Intel Xeon E5-2697A v4 processors with 512 GB of 2.4 GHz DDR4 memory.

3.2. Performance Measures

Five performance measures 3454 used to evaluate the performance of the models, namely accuracy, precision, sensitivity, F1-score, and area under the ROC curve (AUC-ROC). The performance metrics can be calculated using Equations (1)–(4). The five metrics are influenced by the number of true negatives (TNs), true positives (TPs), false negatives (FNs), and false positives (FNs).
Accuracy = ( T N + T P ) ( T N + T P + F N + F P ) × 100
Sensitivity = T P T P + F N × 100
Precision = T P T P + F P × 100
F 1 - Score = 2 P r e c i s i o n S e n s i t i v i t y P r e c i s i o n + S e s i s i t i v i t y
AUC-ROC is a measure showing the efficacy of a model in separating different classes. A high AUC indicates that the model is performing well, while a low AUC indicates otherwise.

4. Results and Discussion

Different experiments were performed to evaluate the performance of the proposed CapsNet model. This section presents the results and discussion. This section also presents a comparative analysis between CapsNetCovid and CNN, ResNet50, DenseNet121, and two existing studies.

4.1. Performance of CapsNetCovid for Binary Classification

Table 6, Table 7, Table 8, Table 9 and Table 10 and Figure 4 show the performance of CapsNetCovid on COVID-19 CT scans. As shown, the CapsNet achieved a test accuracy of 99.929%. This shows that CapsNetCovid misclassified less than 0.1% of the CT images in the test dataset. Table 7 and Table 8 show the precision and sensitivity produced by the CapsNet during evaluation. The CapsNet achieved a precision, sensitivity and F1-score of 99.887%, 100%, and 99.316%, respectively. The sensitivity of 100% shows that the proposed model correctly classified all the COVID-19 samples, making them a good fit for medical diagnosis. It is crucial in the medical field to develop a model with a high degree of sensitivity. The precision of 99.887% shows the quality and completeness of the predictions. It confirms that all the COVID-19 samples were correctly predicted. The F1-score of 99.316% shows that the proposed CapsNet model correctly predicted 99.316% of the COVID-19 and normal samples across the evaluated dataset. This is quite admirable, as there is a good balance between the prediction of COVID-19 and normal samples in the dataset.
Table 6. Classification accuracy of CapsNetCovid, CNN, DenseNet121, and ResNet50.
Table 7. Precision of CapsNetCovid, CNN, DenseNet121, and ResNet50.
Table 8. Sensitivity of CapsNetCovid, CNN, DenseNet121, and ResNet50.
Table 9. F1-Score of CapsNetCovid, CNN, DenseNet121, and ResNet50.
Table 10. ROC score for CT Images.
Figure 4. CapsNetCovid training and validation performance.
Table 10 shows the AUC scores produced by the proposed model. Furthermore, Figure 5 shows the AUC curves and their macro average with AUC scores. As shown, the proposed model performed well with an AUC of 100% for the two classes. This shows that the proposed model correctly distinguished all the COVID-19 and normal CT images in the original dataset. The proposed model is useful to medical practitioners because it correctly classifies all the COVID-19 and normal classes. A false positive result can lead to unnecessary procedures and treatments, while a false negative result can prevent a patient from receiving the necessary treatment, which can lead to the death of a patient.
Figure 5. CapsNet ROC curves for CT images.

4.2. Performance of CapsNetCovid on Augnemted Dataset for Binary Classification

Table 6, Table 7, Table 8, Table 9 and Table 10 also show the performance of CapsNetCovid on the augmented dataset. As shown, CapsNetCovid produced a classification accuracy of 71.075%, 84.935%, 87.114%, and 80.5844% for the RandomShift, RandomFlip, Rotated_45, and Rotated_90 datasets, respectively. The results show that the CapsNet is able to correctly identify a significant proportion of the augmented variants of the images it was trained on. The results also demonstrate the CapsNet’s resistance to image transformations and its ability to generate accurate results without additional data. Table 10 also shows that CapsNetCovid produced an AUC score of 0.61, 0.81, 0.81, and 0.72 for the RandomShift, RandomFlip, Rotated_45, and Rotated_90 datasets, respectively. This indicates that CapsNetCovid’s ability to reliably distinguish between COVID-19 and normal CT images decreased. The generalization performance of the CapsNet can be improved if it is exposed to augmented images during training. In addition, as demonstrated by the results, CapsNetCovid’s performance varies for various image transformations. The results also shows that the CapsNet is more robust at capturing randomly rotated and randomly flipped images than randomly shifted images. This shows that the robustness of the CapsNet depends on the type and degree of image transformation. More work is required to improve the generalization performance of CapsNet when applied to augmented medical images. This presents an opportunity for future research.

4.3. Comparative Analysis of CapsNetCovid with CNN-Based Techniques on Binary Classification

One of the key advantages of the CapsNet over CNN is its ability to capture affine rotations and transformations better than CNN. In view of this, we trained CNN, DenseNet121, and ResNet50 on the same COVID-19 dataset and compared their performance to that of CapsNetCovid. The results are shown in Table 6, Table 7, Table 8, Table 9 and Table 10 and Figure 6, Figure 7 and Figure 8. As shown in the table, CapsNetCovid outperformed CNN on the standard and rotated datasets. CapsNetCovid produced better classification accuracy, precision, sensitivity, and F1-score than CNN in most cases. This indicates that the CapsNet is more robust than CNN in identifying randomly rotated and transformed images without data augmentation. This is because the CNN model must be trained on all orientations of the images to achieve very good results. However, the CapsNet can detect and learn all orientations from a single image using a single capsule. In addition, it should be noted that the CapsNet is a recent DL algorithm. CNN existed before the CapsNet and has undergone numerous improvements over the years. Therefore, it is quite enthralling to see the CapsNet outperform CNN in most cases.
Figure 6. CNN training and validation performance.
Figure 7. DenseNet121 training and validation performance.
Figure 8. ResNet50 training and validation performance.
CapsNetCovid was compared with two state-of-the-art CNN pre-trained models, namely DenseNet121 and ResNet50. The two models were finetuned on the COVID-19 datasets used in this study. After training, the finetuned models were saved and evaluated on the four augmented datasets. The results of the experiments are reported in Table 6, Table 7, Table 8, Table 9 and Table 10. As shown in the tables, CapsNetCovid produced better classification accuracy, sensitivity, precision, and F1-score than DenseNet121 and ResNet50 in the original dataset. CapsNetCovid also outperformed DenseNet121 and ResNet50 in the augmented datasets in most cases. In addition, the outcomes demonstrate that CapsNetCovid produced a higher AUC score than DenseNet121 and ResNet50 for the RandomFlip and Rotated_45 datasets. Additionally, it produced a higher AUC score than ResNet50 for the Rotated_90 dataset. This demonstrates that the CapsNet is superior to CNN at detecting transformations in images. Note that DenseNet121 and ResNet50 have already been trained on a large-scale dataset (ImageNet) containing over 1.2 million images. Nonetheless, the CapsNet still performed better than the two models. This demonstrates the capability of the CapsNet to handle small and augmented medical image datasets without data augmentation techniques.
Figure 9, Figure 10 and Figure 11 show the ROC curves for CNN, DenseNet121, and ResNet50. As shown, CapsNetCovid outperforms the AUC score of CNN, DenseNet121, and ResNet50 by 0.01%, 0.16%, and 0.23% for both normal and COVID-19 CT images. This shows that CapsNetCovid is more effective at distinguishing between positive and negative classes than the three compared CNN-based models.
Figure 9. CNN ROC curves for CT images.
Figure 10. DesNet121 ROC curves for CT images.
Figure 11. ResNet50 ROC curves for CT images.

4.4. Performance of CapsNetCovid on Multi-Class Classification

The proposed technique was applied to a dataset with three classes: COVID-19, normal, and pneumonia. Figure 12 and Table 11, Table 12, Table 13, Table 14 and Table 15 show the performance of CapsNetCovid on the multi-class dataset. As shown, CapsNetCovid achieved a classification accuracy, precision, sensitivity, and F1-score of 94.721, 93.864%, 92.947%, and 93.386%, respectively. The accuracy shows that the proposed model correctly predicted over 94% of the images in the dataset. Figure 13 shows that CapsNetCovid also produced an AUC score of 95.21%. This shows that the model has a strong ability in distinguishing between COVID-19, normal, and pneumonia X-ray images. CapsNetCovid correctly predicted 95% of normal X-ray scans, 96% of pneumonia scans, and 95% of COVID-19 X-ray scans.
Figure 12. CapsNet training and validation performance for X-ray images.
Table 11. Classification accuracy for CapsNetCovid, CNN, DenseNet121, and ResNet50 for multi-class classification.
Table 12. Precision for CapsNetCovid, CNN, DenseNet121, and ResNet50 for multi-class classification.
Table 13. Sensitivity for CapsNetCovid, CNN, DenseNet121, and ResNet50 for multi-class classification.
Table 14. F1-Score for CapsNetCovid, CNN, DenseNet121, and ResNet50 for multi-class classification.
Table 15. AUC-ROC of CapsNetCovid, CNN, DenseNet121, and ResNet50 for multi-class classification.
Figure 13. CapsNet ROC curves for X-ray images.
Table 12, Table 13 and Table 14 shows the precision, sensitivity, and F1-score of CapsNetCovid. As shown, CapsNetCovid produced a precision, sensitivity, and F1-score of 93.864%, 92.947%, and 93.386%, respectively. The high F1-score shows that the model has good generalization performance, and it performs well for normal, COVID-19 and pneumonia classes. The high sensitivity shows that the model correctly identified most of the COVID-19 and pneumonia classes. This is quite remarkable because it can be catastrophic to incorrectly diagnose a patient with COVID-19 or pneumonia. Medical practitioners prefer models with high sensitivity than models with high accuracy. The high precision shows that the CapsNetCovid model is 93.864% correct when it predicts an image to be COVID-19 or pneumonia.
It was observed that the performance of CapsNetCovid reduced from 99.929% to 94.721% when applied to multi-class classification. This decrease could be because of the quality of images in the dataset or the change in image modality. This may indicate that the CapsNet performs better on CT images compared to X-ray images. This reduction may also be because of the multi-class dataset. This may indicate that CapsNet performs better on binary classification compared to multi-class classification. More experiments are required to confirm the reason(s) for the decrease in performance. Overall, the proposed model performed well on the original X-ray images.

4.5. Comparative Analysis of CapsNetCovid with CNN-Based Techniques on Multi-Class Classification

Figure 14, Figure 15 and Figure 16 and Table 11, Table 12, Table 13, Table 14 and Table 15 shows the performance of CNN, DenseNet121, and ResNet50 on the multi-class dataset. As shown, CapsNetCovid outperforms the three models in terms of classification accuracy and AUC score. It outperforms CNN, DenseNet121, and ResNet50 by 5.18%, 4.52%, and 26.36%, respectively. This shows that CapsNetCovid performs better than CNN in correctly distinguishing between COVID-19, pneumonia, and normal X-ray images without using data augmentation. It also shows that the proposed technique outperformed the compared CNN-based techniques in terms of correctly identifying COVID-19 and pneumonia cases. The proposed model will be a good fit for medical practitioners as its predictions for COVID-19, pneumonia, and normal X-ray images are satisfactory.
Figure 14. CNN training and validation performance for X-ray images.
Figure 15. DenseNet121 training and validation performance for X-ray images.
Figure 16. ResNet50 training and validation performance for X-ray images.
Note that DenseNet121 and ResNet50 are pre-trained on the ImageNet dataset containing over 1.2 million images. This shows that CapsNet does not need to be trained on large-scale datasets to outperform CNN-based models. The results also show that CapsNetCovid produced higher F1-score, precision, sensitivity, and AUC score than the compared CNN-based techniques in most cases. This indicates that the proposed technique has a better ability to correctly predict COVID-19 and pneumonia X-ray scans compared to CNN, DensNet121, and ResNet50. This shows that the CapsNet will be more acceptable to medical practitioners compared to CNN, especially when working with small datasets, which is mostly the case for medical image datasets.
Figure 17, Figure 18 and Figure 19 show the ROC curves produced by CNN, DenseNet121, and ResNet50 for multi-class classification. As shown, CapsNetCovid outperformed CNN by 0.09%, 0.05%, and 0.11% for normal, pneumonia, and COVID-19 images, respectively. CapsNetCovid outperformed DenseNet121 by 0.07%, 0.02%, and 0.08% for normal, pneumonia, and COVID-19 images, respectively. CapsNetCovid outperformed ResNet50 by 0.45%, 0.46%, and 0.45% for normal, pneumonia, and COVID-19 images, respectively. This shows that CapsNetCovid is more effective at correctly predicting COVID-19, pneumonia, and normal X-ray images than CNN, DenseNet121, and ResNet50.
Figure 17. CNN ROC curves for X-ray images.
Figure 18. DesNet121 ROC curves for X-ray images.
Figure 19. ResNet50 ROC curves for X-ray images.

4.6. Performance of CapsNetCovid on Augmented Dataset for Multi-Class Classification

As aforementioned, the proposed technique was evaluated on four augmented X-ray datasets containing 15,153 randomly flipped, randomly rotated, and randomly shifted X-ray images. The results are reported in Table 11, Table 12, Table 13, Table 14 and Table 15. As shown, the performance of CapsNetCovid decreased when evaluated on the augmented images. This is obviously because the model was not exposed to any of the augmented images during training. CapsNetCovid was anticipated to successfully recognize a larger percentage of the augmented version of the images it was trained on. However, as shown in the results, that was not the case. This shows that the robustness of CapsNet to affine transformations requires improvement, especially for multi-class classification. This is an opportunity for future research.
As shown in Table 11, Table 12, Table 13, Table 14 and Table 15, the performance of CapsNetCovid on randomly flipped, randomly rotated, and randomly shifted images varies. It achieved a higher classification accuracy for randomly flipped and randomly rotated images. This shows that the CapsNet is more resistant to randomly flipped and rotated images compared to randomly shifted images. CapsNetCovid also produced higher AUC score for randomly flipped and rotated images. This shows that it correctly predicted more randomly flipped COVID-19 and pneumonia images compared to normal images. The results also show that CapsNetCovid performed better on images that are randomly rotated by 45 degrees compared to images that are rotated by 90 degrees. This shows that the robustness of the CapsNet for image rotation is limited by the degree of image rotation.

4.7. Comparative Analysis of CapsNetCovid with CNN-Based Techniques on Multi-Class Classification

Table 11, Table 12, Table 13, Table 14 and Table 15 also show the performance of CNN, DenseNet121, and ResNet50 on augmented X-ray images. As shown in the results, the performance of the three models also decreased. CapsNetCovid produced better accuracy than CNN for randomly flipped and randomly rotated images. Furthermore, although DenseNet121 and ResNet50 produced higher classification accuracy than CapsNetCovid, the proposed model produced better precision, sensitivity, and F1-score than DenseNet121 and ResNet50. This shows that CapsNet is more robust than CNN-based techniques in correctly identifying COVID-19 and pneumonia images. The high classification accuracy of DenseNet121 and ResNet50 is most likely because the two models were pre-trained on over 1.2 million normal and augmented images. This suggests that data augmentation can be used to improve the robustness and generalization performance of CapsNet for image transformations. This can be confirmed from the performance of the CNN model. The CNN model was not previously trained on the augmented images, and it performed poorer than CapsNet, DenseNet121, and ResNet50.
Furthermore, as shown in the results, CapsNetCovid outperform CNN, DenseNet121, and ResNet50 in terms of precision, sensitivity, and F1-score. This shows that CapsNet is more robust for image rotations and affine transformation than the compared CNN-based techniques. Figure 13 shows the ROC curves of CapsNetCovid for the three classes and their macro average. As shown, the proposed model produced a better AUC score for standard images compared to augmented images. This shows that the performance of the CapsNet can be improved if it is exposed to augmented images during training. The ROC curves for CNN, DenseNet121, and ResNet50 are shown in Figure 17, Figure 18 and Figure 19. As shown, CapsNetCovid produced a better AUC score than CNN and ResNet50. This shows that it outperforms the two models in correctly predicting COVID-19 and pneumonia images.

4.8. Comparison of CapsNetCovid with Related Studies

The proposed technique is compared with existing state-of-the-art COVID-19 diagnosis techniques. The technique is compared with 10 binary classification techniques and 11 multi-class classification techniques. The results are reported in Table 16 and Table 17. As shown in the tables, the proposed technique outperformed all the compared techniques for binary classification and most of the techniques for multi-class classification. It is noteworthy to highlight that some of the compared techniques combined CNN pre-trained models with CapsNet. Notwithstanding, the proposed CapsNetCovid model still outperformed most of them. As an example, Tiwari and Anurag [41] proposed a CapsNet architecture for COVID-19 diagnosis from CT scans. They hybridized different CNN pre-trained models with a CapsNet. As shown in the results, CapsNetCovid performed slightly better than DenseCapsNet. It should be noted that DenseCapsNet is an aggregation of CapsNet and DensNet121, implying that it is already pre-trained on the ImageNet dataset with millions of images. Despite this, CapsNetCovid still produced comparable results to DenseCapsNet. Some studies combined CNN and SVM, CNN and CapsNet, optimization techniques and InceptionV3; nevertheless, the proposed model still outperformed them.
Table 16. CapsNetCovid versus existing COVID-19 diagnosis techniques for binary classification.
Table 17. CapsNetCovid versus existing COVID-19 diagnosis technique for multi-class classification.

4.9. Summarized Results and Deductions

Different experiments were performed in this study, and their results are presented in Section 4.1, Section 4.2, Section 4.3, Section 4.4, Section 4.5, Section 4.6, Section 4.7 and Section 4.8. As shown in the results, CapsNetCovid performed differently for both CT and X-ray images. The summary of the all the results is presented in this section. Deductions from the results are also presented in this section.
  • The results show that CapsNetCovid performs well on standard X-ray and CT images. It produced better accuracy when trained and evaluated on CT images and binary classification. Its performance slightly decreased when trained and evaluated on X-ray images and multi-class classification. Overall, the proposed technique produced very good accuracy, sensitivity, F1-score, and AUC score when trained on standard images without data augmentation. The proposed technique also performs well on small medical image datasets. This is because the CNN model must be trained on all orientations of the images to achieve very good results. However, CapsNet can detect and learn all orientations from a single image using a single capsule.
  • The results show that CapsNet is able to correctly identify a large proportion of the augmented variants of the images it was previously trained on, especially for binary classification. This demonstrates the CapsNet’s resistance to image transformations and its ability to achieve good results without data augmentation techniques.
  • The performance of the CapsNet decreased when evaluated on the augmented variants of images it was previously trained on. This decrease was higher for X-ray images and multi-class classification. This is an indication that the CapsNet is more resistant to image rotations and transformations for binary classification than multi-class classification.
  • The results show that CapsNetCovid outperforms CNN, DenseNet121, and ResNet50 when trained and evaluated on CT and X-ray images without data augmentation. This indicates that CapsNet is an excellent choice when working with small dataset and binary and multi-class classification.
  • CapsNet outperforms CNN, DenseNet121, and ResNet50 when evaluated on an augmented CT image dataset with two classes (binary classification). It outperforms the CNN-based techniques in terms of classification accuracy, sensitivity, F1-score, and AUC score. Furthermore, although DenseNet121 and ResNet50 outperform the CapsNet in terms of classification accuracy, the CapsNet produced better precision, sensitivity, and F1-score than CNN, DenseNet121 and ResNet50 when evaluated on an augmented X-ray dataset with three classes (multi-class classification). This shows that medical practitioners will favor the CapsNet over CNN due to the significance of high sensitivity and F1-score in the medical domain. The higher classification accuracy of DenseNet121 and ResNet50 is most likely because the two models are pre-trained on a dataset with over 1.2 million normal and augmented images. This suggests that data augmentation can be used to improve the performance of the CapsNet for multi-class classification.
  • The results show that the CapsNet produces a better AUC score than CNN, DenseNet121, and ResNet50 for both binary and multi-class classification problems. This shows that the CapsNet has a better ability to distinguish between positive and negative classes, which is remarkable.
Overall, as shown in all the reported results, the proposed CapsNet model produced very good results for a small medical image dataset and it outperformed CNN, DenseNet121, and ResNet50 at classifying both standard and augmented CT and X-ray images. Moreover, Figure 4 and Figure 12 show the training and validation loss of CapsNetCovid. As shown, the training and validation loss and accuracy curves are nearly overlapping, indicating that there is no significant variance between the training and validation loss and accuracy. This shows that the CapsNet model did not overfit.

5. Conclusions

The COVID-19 pandemic remains a threat, with multiple waves causing significant damage to the health of millions of people around the world. This study developed a CapsNet model (named CapsNetCovid) for COVID-19 diagnosis using CT and X-ray images. The model achieved a classification accuracy, precision, sensitivity and F1-score of 99.929%, 99.887%, 100%, and 99.319%, respectively, for CT images. Moreover, it achieved a classification accuracy, precision, sensitivity, and F1-score of 94.721%, 93.864%, 92.947%, and 93.386%, respectively, for the X-ray dataset. CapsNetCovid was compared with a CNN model designed for the purpose of comparison, and it outperformed the model on both standard and augmented CT and X-ray images. CapsNetCovid was also compared with two state-of-the-art pre-trained models, namely DenseNet121 and ResNet50. CapsNetCovid outperformed the two models for the standard CT and X-ray image dataset.
Moreover, the results show that CapsNetCovid is more resistant to image rotations and affine transformations than CNN, DenseNet121 and ResNet50 for CT and X-Ray images. Furthermore, the results show that the CapsNet is more resistant to image rotations and transformations for binary classification than multi-class classification. Furthermore, the results show that the CapsNet performs better when applied to randomly rotated and flipped images compared to shifted images. The results also suggest that data augmentation can be used to improve the performance of the CapsNet for multi-class classification. Data augmentation can also be used to improve the overall generalization performance of the CapsNet. Future research can focus on improving the generalization performance of the CapsNet and the robustness of the CapsNet for image rotations and transformations, especially for multi-class classification problems.

Author Contributions

Conceptualization, A.A.A. and B.B.; methodology, A.A.A.; software, A.A.A.; investigation, A.A.A.; data curation, A.A.A.; implementation, A.A.A.; writing—original draft preparation, A.A.A.; writing—review and editing, A.A.A. and B.B.; supervision, B.B.; Funding acquisition, B.B. All authors have read and agreed to the published version of the manuscript.

Funding

Authors were supported by a grant (no. 01DG16005) of the BMBF (through the Alexander von Humboldt Foundation), funding for the German Research Chair of Mathematics with Specialization in Data Science at AIMS South Africa.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

Publicly available datasets were analyzed in this study. This data can be found here: [37,38,39].

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Akinyelu, A.A.; Blignaut, P. COVID-19 diagnosis using deep learning neural networks applied to CT images. Front. Artif. Intell. 2022, 5, 919672. [Google Scholar] [CrossRef] [PubMed]
  2. Sabour, S.; Frosst, N.; Hinton, G.E. Dynamic routing between capsules. arXiv 2017, arXiv:1710.09829. [Google Scholar]
  3. LaLonde, R.; Bagci, U. Capsules for object segmentation. arXiv 2018, arXiv:1804.04241. [Google Scholar]
  4. AbouEl-Magd, L.M.; Darwish, A.; Snasel, V.; Hassanien, A.E. A pre-trained convolutional neural network with optimized capsule networks for chest X-rays COVID-19 diagnosis. Cluster Comput. 2022, 26, 1389–1403. [Google Scholar] [CrossRef] [PubMed]
  5. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic minority over-sampling technique. J. Artif. Intell. Res. 2002, 16, 321–357. [Google Scholar] [CrossRef]
  6. Saif, A.F.M.; Imtiaz, T.; Rifat, S.; Shahnaz, C.; Zhu, W.-P.; Ahmad, M.O. CapsCovNet: A modified capsule network to diagnose Covid-19 from multimodal medical imaging. IEEE Trans. Artif. Intell. 2021, 2, 608–617. [Google Scholar] [CrossRef]
  7. Toraman, S.; Alakus, T.B.; Turkoglu, I. Convolutional capsnet: A novel artificial neural network approach to detect COVID-19 disease from X-ray images using capsule networks. Chaos Solitons Fractals 2020, 140, 110122. [Google Scholar] [CrossRef]
  8. Cohen, J. COVID-19 Image Data Collection. 2020. Available online: https://github.com/ieee8023/COVID-chestxray-dataset (accessed on 20 October 2022).
  9. Wang, X.; Peng, Y.; Lu, L.; Lu, Z.; Bagheri, M.; Summers, R.M. Chestx-ray8: Hospital-scale chest x-ray database and benchmarks on weakly-supervised classification and localization of common thorax diseases. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017; pp. 2097–2106. [Google Scholar]
  10. Tiwari, S.; Jain, A. Convolutional capsule network for COVID-19 detection using radiography images. Int. J. Imaging Syst. Technol. 2021, 31, 525–539. [Google Scholar] [CrossRef]
  11. Dadario, A.M.V. COVID-19 X-rays. 2019. Available online: https://www.kaggle.com/datasets/andrewmvd/convid19-x-rays (accessed on 20 October 2022).
  12. Afshar, P.; Heidarian, S.; Naderkhani, F.; Oikonomou, A.; Plataniotis, K.N.; Mohammadi, A. Covid-caps: A capsule network-based framework for identification of covid-19 cases from X-ray images. Pattern Recognit. Lett. 2020, 138, 638–643. [Google Scholar] [CrossRef]
  13. Heidarian, S.; Afshar, P.; Enshaei, N.; Naderkhani, F.; Rafiee, M.J.; Babaki Fard, F.; Samimi, K.; Atashzar, S.F.; Oikonomou, A.; Plataniotis, K.N. COVID-fact: A fully-automated capsule network-based framework for identification of COVID-19 cases from chest ct scans. Front. Artif. Intell. 2021, 4, 598932. [Google Scholar] [CrossRef]
  14. Quan, H.; Xu, X.; Zheng, T.; Li, Z.; Zhao, M.; Cui, X. DenseCapsNet: Detection of COVID-19 from X-ray images using a capsule neural network. Comput. Biol. Med. 2021, 133, 104399. [Google Scholar] [CrossRef] [PubMed]
  15. Iglovikov, V.; Shvets, A. Ternausnet: U-net with vgg11 encoder pre-trained on imagenet for image segmentation. arXiv 2018, arXiv:1801.05746. [Google Scholar]
  16. Jaeger, S.; Candemir, S.; Antani, S.; Wáng, Y.-X.J.; Lu, P.-X.; Thoma, G. Two public chest X-ray datasets for computer-aided screening of pulmonary diseases. Quant. Imaging Med. Surg. 2014, 4, 475. [Google Scholar] [PubMed]
  17. Qi, Q.; Qi, S.; Wu, Y.; Li, C.; Tian, B.; Xia, S.; Ren, J.; Yang, L.; Wang, H.; Yu, H. Fully automatic pipeline of convolutional neural networks and capsule networks to distinguish COVID-19 from community-acquired pneumonia via CT images. Comput. Biol. Med. 2022, 141, 105182. [Google Scholar] [CrossRef] [PubMed]
  18. Chaurasia, A.; Culurciello, E. Linknet: Exploiting encoder representations for efficient semantic segmentation. In Proceedings of the 2017 IEEE Visual Communications and Image Processing (VCIP), St. Petersburg, FL, USA, 10–13 December 2017; pp. 1–4. [Google Scholar]
  19. Attallah, O. RADIC: A tool for diagnosing COVID-19 from chest CT and X-ray scans using deep learning and quad-radiomics. Chemom. Intell. Lab. Syst. 2023, 233, 104750. [Google Scholar] [CrossRef]
  20. Mercaldo, F.; Belfiore, M.P.; Reginelli, A.; Brunese, L.; Santone, A. Coronavirus COVID-19 detection by means of explainable deep learning. Sci. Rep. 2023, 13, 462. [Google Scholar] [CrossRef]
  21. Shah, V.; Keniya, R.; Shridharani, A.; Punjabi, M.; Shah, J.; Mehendale, N. Diagnosis of COVID-19 using CT scan images and deep learning techniques. Emerg. Radiol. 2021, 28, 497–505. [Google Scholar] [CrossRef]
  22. Attallah, O.; Samir, A. A wavelet-based deep learning pipeline for efficient COVID-19 diagnosis via CT slices. Appl. Soft Comput. 2022, 128, 109401. [Google Scholar] [CrossRef]
  23. Attallah, O. A computer-aided diagnostic framework for coronavirus diagnosis using texture-based radiomics images. Digit. Health 2022, 8, 20552076221092544. [Google Scholar] [CrossRef]
  24. Zhao, W.; Jiang, W.; Qiu, X. Deep learning for COVID-19 detection based on CT images. Sci. Rep. 2021, 11, 1–12. [Google Scholar] [CrossRef]
  25. Shankar, K.; Perumal, E. A novel hand-crafted with deep learning features based fusion model for COVID-19 diagnosis and classification using chest X-ray images. Complex Intell. Syst. 2021, 7, 1277–1293. [Google Scholar] [CrossRef] [PubMed]
  26. Constantinou, M.; Exarchos, T.; Vrahatis, A.G.; Vlamos, P. COVID-19 classification on chest X-ray images using deep learning methods. Int. J. Environ. Res. Public Health 2023, 20, 2035. [Google Scholar] [CrossRef]
  27. Attallah, O. Deep learning-based CAD system for COVID-19 diagnosis via spectral-temporal images. In Proceedings of the 12th International Conference on Information Communication and Management, London, UK, 13–15 July 2022; pp. 25–33. [Google Scholar]
  28. Shinde, G.R.; Kalamkar, A.B.; Mahalle, P.N.; Dey, N.; Chaki, J.; Hassanien, A.E. Forecasting models for coronavirus disease (COVID-19): A survey of the state-of-the-art. SN Comput. Sci. 2020, 1, 197. [Google Scholar] [CrossRef] [PubMed]
  29. Şenol, A.; Canbay, Y.; Mahmut, K. Trends in Outbreak Detection in Early Stage by Using Machine Learning Approaches. Bilişim Teknol. Derg. 2021, 14, 355–366. [Google Scholar]
  30. Born, J.; Brändle, G.; Cossio, M.; Disdier, M.; Goulet, J.; Roulin, J.; Wiedemann, N. POCOVID-Net: Automatic detection of COVID-19 from a new lung ultrasound imaging dataset (POCUS). arXiv 2020, arXiv:2004.12084. [Google Scholar]
  31. Zhang, K.; Liu, X.; Shen, J.; Li, Z.; Sang, Y.; Wu, X.; Zha, Y.; Liang, W.; Wang, C.; Wang, K.; et al. Clinically applicable AI system for accurate diagnosis, quantitative measurements, and prognosis of COVID-19 pneumonia using computed tomography. Cell 2020, 181, 1423–1433. [Google Scholar] [CrossRef] [PubMed]
  32. An, P.; Xu, S.; Harmon, S.A.; Turkbey, E.B.; Sanford, T.H.; Amalou, A.; Kassin, M.; Varble, N.; Blain, M.; Anderson, V.; et al. CT Images in COVID-19 [Data Set]. 2020. Available online: https://wiki.cancerimagingarchive.net/display/Public/CT+Images+in+COVID-19 (accessed on 5 January 2022).
  33. Rahimzadeh, M.; Attar, A.; Sakhaei, S.M. A fully automated deep learning-based network for detecting COVID-19 from a new and large lung ct scan dataset. Biomed. Signal Process. Control 2021, 68, 102588. [Google Scholar] [CrossRef]
  34. Ning, W.; Lei, S.; Yang, J.; Cao, Y.; Jiang, P.; Yang, Q.; Zhang, J.; Wang, X.; Chen, F.; Geng, Z.; et al. Open resource of clinical data from patients with pneumonia for the prediction of COVID-19 outcomes via deep learning. Nat. Biomed. Eng. 2020, 4, 1197–1207. [Google Scholar] [CrossRef]
  35. Ma, J.; Wang, Y.; An, X.; Ge, C.; Yu, Z.; Chen, J.; Zhu, Q.; Dong, G.; He, J.; He, Z.; et al. Towards efficient COVID-19 ct annotation: A benchmark for lung and infection segmentation. arXiv 2020, arXiv:2004.12537. [Google Scholar]
  36. Radiopaedia. COVID-19. 2021. Available online: https://radiopaedia.org/articles/covid-19-4 (accessed on 1 November 2021).
  37. Gunraj, H.; Sabri, A.; Koff, D.; Wong, A. COVID-Net CT-2: Enhanced Deep Neural Networks for Detection of COVID-19 from Chest CT Images Through Bigger, More Diverse Learning. Front. Med. 2022, 8, 3126. [Google Scholar] [CrossRef]
  38. Chowdhury, M.E.H.; Rahman, T.; Khandakar, A.; Mazhar, R.; Kadir, M.A.; Mahbub, Z.B.; Islam, K.R.; Khan, M.S.; Iqbal, A.; Al Emadi, N. Can AI help in screening viral and COVID-19 pneumonia? IEEE Access 2020, 8, 132665–132676. [Google Scholar] [CrossRef]
  39. Rahman, T.; Khandakar, A.; Qiblawey, Y.; Tahir, A.; Kiranyaz, S.; Kashem, S.B.A.; Islam, M.T.; Al Maadeed, S.; Zughaier, S.M.; Khan, M.S. Exploring the effect of image enhancement techniques on COVID-19 detection using chest X-ray images. Comput. Biol. Med. 2021, 132, 104319. [Google Scholar] [CrossRef] [PubMed]
  40. Rahman, T.; Khandakar, A.; Chowdhury, M.E.H. COVID-19 Radiography Database. Available online: https://www.kaggle.com/datasets/tawsifurrahman/covid19-radiography-database (accessed on 14 March 2023).
  41. Tiwari, S.; Jain, A. A lightweight capsule network architecture for detection of COVID-19 from lung CT scans. Int. J. Imaging Syst. Technol. 2022, 32, 419–434. [Google Scholar] [CrossRef] [PubMed]
  42. Saha, P.; Sadi, M.S.; Islam, M.M. EMCNet: Automated COVID-19 diagnosis from X-ray images using convolutional neural network and ensemble of machine learning classifiers. Inform. Med. Unlocked 2021, 22, 100505. [Google Scholar] [CrossRef] [PubMed]
  43. Apostolopoulos, I.D.; Mpesiana, T.A. COVID-19: Automatic detection from x-ray images utilizing transfer learning with convolutional neural networks. Phys. Eng. Sci. Med. 2020, 43, 635–640. [Google Scholar] [CrossRef]
  44. Narin, A.; Kaya, C.; Pamuk, Z. Automatic detection of coronavirus disease (COVID-19) using X-ray images and deep convolutional neural networks. Pattern Anal. Appl. 2021, 24, 1207–1220. [Google Scholar] [CrossRef]
  45. Sethy, P.K.; Behera, S.K.; Ratha, P.K.; Biswas, P. Detection of Coronavirus Disease (COVID-19) Based on Deep Features and Support Vector Machine. Preprints.org 2020, 2020030300. Available online: https://www.preprints.org/ (accessed on 27 February 2023).
  46. Alqudah, A.M.; Qazan, S.; Alqudah, A. Automated systems for detection of COVID-19 using chest X-ray images and lightweight convolutional neural networks. Res. Sq. 2020, in press.
  47. Dimeglio, N.; Romano, S.; Vesseron, A.; Pelegrin, V.; Ouchani, S. COVID-DETECT: A deep learning based approach to accelerate COVID-19 detection. In Proceedings of the Advances in Model and Data Engineering in the Digitalization Era: MEDI 2021 International Workshops: DETECT, SIAS, CSMML, BIOC, HEDA, Tallinn, Estonia, 21–23 June 2021; Proceedings 10. pp. 166–178. [Google Scholar]
  48. Chakraborty, S.; Paul, S.; Hasan, K.M.A. A transfer learning-based approach with deep cnn for COVID-19-and pneumonia-affected chest X-ray image classification. SN Comput. Sci. 2022, 3, 17. [Google Scholar] [CrossRef]
  49. Sharma, P.; Arya, R.; Verma, R.; Verma, B. Conv-CapsNet: Capsule based network for COVID-19 detection through X-ray scans. Multimed. Tools Appl. 2023, 1–25. [Google Scholar] [CrossRef]
  50. Heidarian, S.; Afshar, P.; Mohammadi, A.; Rafiee, M.J.; Oikonomou, A.; Plataniotis, K.N.; Naderkhani, F. Ct-caps: Feature extraction-based automated framework for COVID-19 disease identification from chest ct scans using capsule networks. In Proceedings of the ICASSP 2021–2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), Toronto, ON, Canada, 6–11 June 2021; pp. 1040–1044. [Google Scholar]
  51. Mohammad, R.; Abolfazl, A. A new modified deep convolutional neural network for detecting COVID-19 from X-ray images. arXiv 2020, arXiv:2004.08052. [Google Scholar]
  52. Rahimzadeh, M.; Attar, A. 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. Inform. Med. Unlocked 2020, 19, 100360. [Google Scholar] [CrossRef] [PubMed]
  53. Kim, H.W.; Capaccione, K.M.; Li, G.; Luk, L.; Widemon, R.S.; Rahman, O.; Beylergil, V.; Mitchell, R.; D’Souza, B.M.; Leb, J.S. The role of initial chest X-ray in triaging patients with suspected COVID-19 during the pandemic. Emerg. Radiol. 2020, 27, 617–621. [Google Scholar] [CrossRef] [PubMed]
  54. Wang, L.; Lin, Z.Q.; Wong, A. Covid-net: A tailored deep convolutional neural network design for detection of COVID-19 cases from chest X-ray images. Sci. Rep. 2020, 10, 1–12. [Google Scholar] [CrossRef] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.