Automatic Diagnosis of Myocarditis Disease in Cardiac MRI Modality using Deep Transformers and Explainable Artificial Intelligence

Mahboobeh Jafari, Afshin Shoeibi, Navid Ghassemi, Jónathan Heras, Abbas Khosravi, Sai Ho Ling, Roohallah Alizadehsani, Amin Beheshti, Yu-Dong Zhang, Shui-Hua Wang, Juan Manuel Górriz, U. Rajendra Acharya, Hamid Alinejad-Rokny · DOI

Abstract

Myocarditis, an inflammation of the heart muscle often triggered by viral infections, remains a significant diagnostic challenge. While Cardiac MRI (CMRI) is a powerful non-invasive tool, the manual interpretation of numerous image slices is time-consuming and prone to human error. This paper presents a high-precision computer-aided diagnosis system (CADS) that leverages Vision Transformers and advanced data augmentation techniques. By evaluating various architectures, the Turbulence Neural Transformer (TNT) achieved a peak diagnostic accuracy of 99.73%. The integration of Explainable AI (XAI) via Grad-CAM provides clinical transparency, allowing practitioners to visually verify the model's findings.

Introduction

The clinical management of myocarditis is complicated by the subtle nature of inflammatory markers in CMRI scans, which often suffer from low contrast and resolution. Traditional diagnostic workflows require radiologists to manually review dozens of slices per patient, a process susceptible to fatigue-induced errors. While deep learning, particularly Convolutional Neural Networks (CNNs), has shown promise in medical imaging, this study explores the potential of Transformer architectures to capture global spatial relationships more effectively for myocarditis detection.

Methodology

The proposed system follows a multi-stage pipeline designed for robustness and interpretability.

Preprocessing and Data Augmentation

Input images are first denoised using Gaussian filters and resized to a uniform 224x224 resolution. To address the common issue of overfitting in medical datasets, the researchers implemented a novel combination of CutMix (patch replacement) and MixUp (linear blending of images and labels). This strategy enhances the model's ability to generalize across diverse patient data.

Model Architectures

The study conducted a comprehensive comparison between traditional CNNs (e.g., EfficientNet, ResNet, Inception V4) and modern Deep Transformers (e.g., ViT, Swin, TNT). The Turbulence Neural Transformer (TNT) emerged as the most effective, utilizing a hierarchical approach that processes images as both "visual sentences" (large patches) and "visual words" (sub-patches) to capture both structural and fine-grained anomalies.

The proposed CADS pipeline, illustrating the flow from input CMRI through feature extraction to an explainable diagnosis using Grad-CAM.

Explainable AI (XAI)

To move beyond "black box" predictions, the system incorporates Grad-CAM and occlusion-based attribution. These techniques generate heatmaps that highlight the specific myocardial regions driving the AI's classification, providing a "second opinion" that aligns with clinical expectations.

Datasets

The research utilized the Z-Alizadeh Sani Myocarditis Dataset, comprising 10,425 CMRI images (5,040 healthy controls and 5,385 myocarditis cases). The dataset includes various imaging protocols such as CINE-segmented, T2-weighted, and Late Gadolinium Enhancement (LGE) sequences.

A sample Cardiac MRI (CMRI) slice from the dataset used for training and validation.

Results and Discussion

The TNT model achieved a state-of-the-art accuracy of 99.73% under 10-fold cross-validation. In comparison, the best-performing CNN (Inception ResNet v2) reached 99.66%. The results indicate that the global attention mechanism of Transformers is superior at identifying diffuse inflammatory patterns across the heart muscle compared to the local filters of CNNs.

Interestingly, while data augmentation generally improved performance, some models like DeiT and Beit saw a decrease, suggesting that certain data-hungry architectures require even larger datasets to benefit from complex augmentation strategies.

Conclusion

This study demonstrates that combining Vision Transformers with Explainable AI can significantly enhance the accuracy and reliability of myocarditis diagnosis. Future work will focus on validating the system with multi-center datasets, developing multi-class models for severity grading, and optimizing computational efficiency for real-time clinical deployment.

Summary updated

BibTeX
@misc{jafari2022automatic,
  author = {Mahboobeh Jafari and Afshin Shoeibi and Navid Ghassemi and Jónathan Heras and Abbas Khosravi and Sai Ho Ling and Roohallah Alizadehsani and Amin Beheshti and Yu-Dong Zhang and Shui-Hua Wang and Juan Manuel Górriz and U. Rajendra Acharya and Hamid Alinejad-Rokny},
  title = {{Automatic Diagnosis of Myocarditis Disease in Cardiac MRI Modality using Deep Transformers and Explainable Artificial Intelligence}},
  year = {2022},
  eprint = {2210.14611},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.14611},
}
Figure