Diff of /README.md [000000] .. [bfd162]

Switch to unified view

a b/README.md
1
# WCE Bleeding Region Classification & Detection
2
3
## Problem Statement :
4
5
- GI bleeding is a medical condition characterised by bleeding in the digestive tract, which circumscribes oesophagus, stomach, small intestine, large intestine (colon), rectum, and anus. Since blood flows into the GI tract, a cascade of risks emerge, ranging from immediate dangers to potential long-term consequences. Excessive blood loss from GI bleeding may lead to a drop in blood pressure, reduced oxygen delivery to organs and tissues, and potentially life-threatening organ dysfunction
6
- According to World Health Organisation (WHO), gastrointestinal bleeding is responsible for approximately 300,000 deaths every year globally
7
- WCE Stands for ****************************************************Wireless Capsule Endoscopy**************************************************** , a technique used to analyse GI
8
- During 6-8 hours of WCE procedure, a video of the GI tract trajectory is recorded on a device attached to the patient’s belt which produces about 57,000-1,00,000 frames; analysed posterior by experienced health experts. Presently, an experienced gastroenterologist takes approximately 2−3 hours to inspect the captured video of one-patient through a frame-by-frame analysis which is not only time-consuming but also susceptible to human error.
9
10
## Motivation :
11
12
- To come up with a system to find patterns in the bleeding frames, so that it can be used to detect bleeding frames in future patients. This should make the procedure more accessible and making the process less time consuming and less prone to error.
13
- For Pattern Recognition, Deep Learning is employed for both classification of bleeding and non bleeding frames and detection of bleeding regions in the bleeding frames
14
    - Combination of Convolutional Networks to extract features from the frames and then using fully connected layers to predict and learn if it is bleeding or non bleeding frame
15
    - Using Two Stage object detection algorithms for detecting bleeding regions
16
17
## Data Preparation :
18
19
- The data we have received consists of 2 files :
20
    - Bleeding file : Contains Bleeding frames and bounding box files
21
    - Non Bleeding file : Contains Non Bleeding frames
22
- Code present in the Repository
23
24
### Classification :
25
26
- Our goal is to redistribute the data in a format accepted by ImageFolder method in the PyTorch datasets library, which is :
27
28
```markdown
29
WCEBleedGen/ <- Overall Dataset Folder
30
    train/ <- Containing the training Dataset
31
        Bleeding/ <- Containing the training Bleeding Frames only
32
        Non Bleeding/ <- Containing the training Non Bleeding Frames only
33
    test/ <- Containing the test Dataset
34
        Bleeding/ <- Containing the test Bleeding Frames only
35
        Non Bleeding/ <- Containing the test Non Bleeding Frames only
36
    
37
```
38
39
- Approach (overview)
40
    - For this we first extract all the bleeding and non bleeding images from their respective folders using Path.glob function
41
    - Then separately we apply train_test_split functionality on the 2 types of data
42
    - Then we merge training data of bleeding and non bleeding data into one file (train file) and test data of bleeding and non bleeding data into another (test file)
43
    - within these files we make 2 sub files bleeding and non bleeding
44
45
### Detection :
46
47
- Our goal is to create a file in the following format using the Bleeding images only :
48
49
```markdown
50
WCEBleedGen/ <- Overall Dataset Folder
51
    train/ <- Containing the training Dataset
52
        Images/ <- Containing the training Bleeding Frames only
53
        Bounding Boxes/ <- Containing the Bounding Boxes of images in order
54
    test/ <- Containing the test Dataset
55
        Images/ <- Containing the test Bleeding Frames only
56
        Bounding Boxes/ <- Containing the Bounding Boxes of images in order
57
```
58
59
- Extract bleeding images and bounding boxes using Path.glob() function
60
- The Problem we face here is that the files retrieved are not in order (images being mapped to different bounding boxes). To tackle this, we sort the list of file names based on the image number contained in them. This ensures data consistency
61
62
## Sample Data Images :
63
64
- Bleeding
65
    
66
    ![Screenshot 2023-10-24 at 3.38.49 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_3.38.49_PM.png)
67
    
68
69
- Non Bleeding
70
    
71
    ![Screenshot 2023-10-24 at 3.39.22 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_3.39.22_PM.png)
72
    
73
74
## Classification :
75
76
### Model Architecture :
77
78
![Pannu, H.S., Ahuja, S., Dang, N. *et al.* Deep learning based image classification for intestinal hemorrhage. *Multimed Tools Appl* **79**, 21941–21966 (2020). https://doi.org/10.1007/s11042-020-08905-7](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_3.44.41_PM.png)
79
80
Pannu, H.S., Ahuja, S., Dang, N. *et al.* Deep learning based image classification for intestinal hemorrhage. *Multimed Tools Appl* **79**, 21941–21966 (2020). https://doi.org/10.1007/s11042-020-08905-7
81
82
### Results :
83
84
- Loss and Accuracy Plots :
85
    
86
    ![Screenshot 2023-10-24 at 3.47.24 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_3.47.24_PM.png)
87
    
88
- Precision, Recall and F1 Score (Test Dataset)
89
    
90
    ![Screenshot 2023-10-24 at 3.48.13 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_3.48.13_PM.png)
91
    
92
93
## Detection :
94
95
### Additional Data Preparation :
96
97
- The data that we have for Bleeding region detection is not in the standard form which the PyTorch Dataset Class and DataLoader Class accepts hence we have created a Custom dataset class. It returns the following data
98
    - Bleeding Image
99
    - Corresponding Bounding Box and label in a dictionary
100
- For the proper functioning of the DataLoader, we need to create a Collate Function which would take the batched data and convert it into a list of images and labels
101
102
### Pre trained Model :
103
104
- We have decided to use **Two Stage object detection** algorithm for our use case because:
105
    - Unlike one stage object detection algorithm which prioritise speed, two stage object detection algorithms prioritise accuracy. Accuracy is paramount when dealing with medical applications of Machine Learning
106
    - Two-stage detectors are usually slower than one-stage detectors, but they usually reach better accuracy. They are often used in the medical domain where classification accuracy is more important than speed
107
- The Pre trained model we have used is the variant of ************************Faster R-CNN************************ trained on the Resnet dataset with a upper limit of 10 box detections per image
108
- We have frozen all the layers except for the **Region Proposal Network**, and we have changed the classification layer from detecting 91 classes to 2 classes
109
110
### Sample Predictions :
111
112
- Test Dataset
113
- Red → Model Prediction, Green → Actual Bleeding Region
114
115
![Screenshot 2023-10-24 at 4.18.49 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_4.18.49_PM.png)
116
117
![Screenshot 2023-10-24 at 4.25.14 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_4.25.14_PM.png)
118
119
![Screenshot 2023-10-24 at 4.25.41 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_4.25.41_PM.png)
120
121
![Screenshot 2023-10-24 at 4.26.16 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_4.26.16_PM.png)
122
123
- Validation set Predictions :
124
- White Boundary → Actual Bleeding Region , Red → Model Predictions
125
126
![Screenshot 2023-10-24 at 5.19.23 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_5.19.23_PM.png)
127
128
![Screenshot 2023-10-24 at 5.21.16 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_5.21.16_PM.png)
129
130
![Screenshot 2023-10-24 at 5.22.21 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_5.22.21_PM.png)
131
132
![Screenshot 2023-10-24 at 5.24.44 PM.png](WCE%20Bleeding%20Region%20Classification%20&%20Detection/Screenshot_2023-10-24_at_5.24.44_PM.png)
133
134
## References :
135
136
- Classification Model Architecture :
137
    - Pannu, H.S., Ahuja, S., Dang, N. *et al.* Deep learning based image classification for intestinal hemorrhage. *Multimed Tools Appl* **79**, 21941–21966 (2020). https://doi.org/10.1007/s11042-020-08905-7
138
- Detection (Faster R-CNN) :
139
    - **[Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks](https://arxiv.org/abs/1506.01497)**
140
- Dataset :
141
    - [Palak, Harshita Mangotra, Jyoti Dhatarwaland Nidhi Gooel, ‘WCEbleedGen: A wireless capsule endoscopy dataset containing bleeding and non-bleeding frames’. Zenodo, Jan. 18, 2023. doi: 10.5281/zenodo.7548320.](https://zenodo.org/records/7548320)