reab5555 commited on
Commit
17bfb39
1 Parent(s): c39dacc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -3
README.md CHANGED
@@ -1,3 +1,124 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ metrics:
4
+ - f1
5
+ - recall
6
+ - precision
7
+ pipeline_tag: image-classification
8
+ tags:
9
+ - medical
10
+ ---
11
+
12
+
13
+ # Multiple Sclerosis Prediction from MRI Scans
14
+
15
+ ## Project Overview
16
+ This repository contains the implementation of a Vision Transformer (ViT) model finetuned and designed to predict Multiple Sclerosis (MS) from Magnetic Resonance Imaging (MRI) scans.
17
+
18
+ What helps the model distinguish between an MRI scan of an MS patient and a healthy subject are clear lesions in different areas of the brain that can be distinguished in the MRI scans.
19
+ By implementing the Vision Transformer (ViT) model for MRI scans and Multiple Sclerosis detection, we showcase the model's effectiveness in medical imaging applications.
20
+
21
+ ## What is Multiple Sclerosis?
22
+ Multiple Sclerosis (MS) is a chronic demyelinating disease characterized by the presence of plaques in the white matter of the central nervous system. These plaques can disrupt the flow of information within the brain, and between the brain and the rest of the body. MS can be diagnosed using MRI, which helps identify the characteristic lesions associated with the disease. Usual onset is around age 20–50.
23
+
24
+ It can cause a wide range of symptoms including fatigue, vision problems, mobility issues, cognitive changes, numbness, pain, speech difficulties, mood changes, heat sensitivity, and muscle spasticity, which vary in severity and occurrence among individuals.
25
+
26
+ ## Dataset
27
+ The dataset and initial modeling attempts are derived from the work by Macin et al. (2022). They proposed a computationally efficient model using Exemplar Multiple Parameters Local Phase Quantization (ExMPLPQ) combined with a k-nearest neighbor (kNN) classifier. Their model achieved high accuracy in detecting MS from MRI images.
28
+
29
+ **Original Article:** [An Accurate Multiple Sclerosis Detection Model Based on Exemplar Multiple Parameters Local Phase Quantization: ExMPLPQ](https://www.mdpi.com/2076-3417/12/10/4920)
30
+
31
+ The dataset consists of axial and sagittal MRI images divided into four classes:
32
+ 1. **Control-Axial:** Axial MRI images from healthy individuals.
33
+ 2. **Control-Sagittal:** Sagittal MRI images from healthy individuals.
34
+ 3. **MS-Axial:** Axial MRI images from individuals diagnosed with MS.
35
+ 4. **MS-Sagittal:** Sagittal MRI images from individuals diagnosed with MS.
36
+
37
+ ### Criterions for diagnostic labeling of MS:
38
+ *Interpretation of MRI images requires experts to manually scrutinize multiple contiguous image sections for the presence of white matter lesions, with care being taken to distinguish MS plaques from lesions associated with diseases that present with similar symptoms, e.g., ischemic gliosis and central nervous system vasculitis. MS plaques are hyperintense in T2 sequence, oval-round shaped, at least 3mm in size, with asymmetric distribution. The typical location of MS plaques is as follows: periventricular: adjacent to the lateral ventricles; juxtracortical and cortical: localized to U fibers; infratentorial: located unilaterally or bilaterally paramedian adjacent to the brain stem, cerebellum, and 4th ventricle; spinal cord: cervical and thoracic localized, shorter than two vertebral segments, axially wedge-shaped, sagittal cigarette shaped, localized in peripherally located posterior and lateral columns.*
39
+
40
+ ### Sample Distribution
41
+ We have to classes, MS or Non-MS.
42
+ After we balanced the classes using downsampling, each class contains 1293 samples (MRI images), ensuring a balanced dataset for training and evaluation.
43
+
44
+ ## Model Architecture
45
+ We utilized and finetuned the Vision Transformer (ViT) model, specifically `google/vit-base-patch16-384` on our MRI dataset images.
46
+
47
+ ### Vision Transformer (ViT)
48
+ - **Patch Embeddings:** The input image is divided into fixed-size patches (e.g., 16x16), each of which is flattened and embedded into a vector.
49
+ - **Positional Encoding:** Added to the patch embeddings to maintain spatial information.
50
+ - **Transformer Encoder:** Processes the encoded patches through multi-head self-attention layers and feed-forward neural networks.
51
+ - **Classification Head:** The output is pooled and passed through a fully connected layer to generate final class probabilities.
52
+
53
+ ### Detailed Architecture
54
+ - **Base Vision Transformer:**
55
+ - Pre-trained on ImageNet-21k.
56
+ - Added Adaptive Average Pooling to minimize overfitting.
57
+ - **Fully Connected Layers:**
58
+ - Connected Layer: 128 neurons, ReLU activation.
59
+ - Linear layer with single output (1 or 0) for binary classification.
60
+
61
+ The following table lists the hyperparameters used in our model:
62
+
63
+ | Hyperparameter | Value |
64
+ |------------------|-----------------|
65
+ | Input Size | 384x384 |
66
+ | Dropout Rate | 0.5 |
67
+ | Weight Decay | 0.01 |
68
+ | Learning Rate | 1e-5 |
69
+ | Optimizer | AdamW |
70
+ | Batch Size | 8 |
71
+
72
+ ### Cross-validation
73
+ To ensure robust evaluation and to prevent overfitting, we employed 6 fold cross-validation. This approach divides the dataset into six subsets, training the model on five subsets while using the sixth for validation (around 431 samples per fold-validation set).
74
+
75
+ ## Results
76
+ Below are the results for the last epochs of each fold:
77
+
78
+ ### Fold-wise Results
79
+ | Fold | Epochs | Train Loss | Val Loss | F1 | Accuracy | Precision | Recall |
80
+ |------|--------|------------|----------|---------|----------|-----------|--------|
81
+ | 1 | 3 | 0.5596 | 0.2153 | 0.92 | 0.92 | 0.92 | 0.92 |
82
+ | 2 | 6 | 0.5402 | 0.1795 | 0.94 | 0.94 | 0.94 | 0.94 |
83
+ | 3 | 4 | 0.5443 | 0.2065 | 0.92 | 0.92 | 0.93 | 0.92 |
84
+ | 4 | 4 | 0.5150 | 0.2093 | 0.94 | 0.94 | 0.94 | 0.94 |
85
+ | 5 | 5 | 0.5281 | 0.1826 | 0.95 | 0.95 | 0.95 | 0.95 |
86
+ | 6 | 5 | 0.5337 | 0.2232 | 0.94 | 0.94 | 0.95 | 0.94 |
87
+
88
+ ### Average Metrics across all Folds
89
+ | Metric | Value |
90
+ |-----------------|---------|
91
+ | Accuracy | 0.9346 |
92
+ | Precision | 0.9378 |
93
+ | Recall | 0.9346 |
94
+ | F1 Score | 0.9345 |
95
+
96
+ ### Class-wise Average Metrics
97
+ | Class | Precision | Recall | F1-Score |
98
+ |-----------------|-----------|--------|----------|
99
+ | NON-MS | 0.9229 | 0.9513 | 0.9356 |
100
+ | MS | 0.9527 | 0.9180 | 0.9335 |
101
+
102
+ ## Conclusion
103
+ In conclusion, our project aimed to build upon the existing research by applying modern computer vision techniques, primarily the Vision Transformer model, to classify MS from MRI images. Through cross-validation and fine-tuning, we achieved robust performance metrics, demonstrating the efficacy of ViT models in medical image classification tasks, with an average prediction Recall of 93%.
104
+
105
+ ## Potential Problems and Future Directions
106
+ ### Small Dataset
107
+ - The current dataset, while balanced and sufficient for initial trials, is relatively small. Small datasets may not capture the full variability required for robust model training and generalization.
108
+
109
+ ### Higher Resolution Images
110
+ - Higher resolution images could provide more detailed information, potentially improving the model's ability to detect subtle features associated with MS.
111
+
112
+ ### Model Complexity and Interpretability
113
+ - Vision Transformers are complex models, which makes interpreting the learned features challenging. Understanding why the model makes specific predictions is crucial in medical applications.
114
+
115
+ ## Acknowledgments
116
+ This project was made possible by the pioneering efforts of [Macin et al., 2022](https://www.mdpi.com/2076-3417/12/10/4920), whose data and initial study laid the groundwork for our research.
117
+
118
+ **References:**
119
+ Macin, G., Tasci, B., Tasci, I., Faust, O., Barua, P.D., Dogan, S., Tuncer, T., Tan, R.-S., Acharya, U.R. An Accurate Multiple Sclerosis Detection Model Based on Exemplar Multiple Parameters Local Phase Quantization: ExMPLPQ. Appl. Sci. 2022, 12, 4920.
120
+
121
+ ---
122
+
123
+ **Disclaimer:**
124
+ This project is intended for research and educational purposes only and should not be used as a diagnostic tool without formal clinical validation.