Brain Tumor Detection
Introduction :
Abnormalities in the brain are now being identified with the help of BRAIN MRI SCAN, Magnetic resonance imaging (MRI) of the brain is a safe and painless test that uses a magnetic field and radio waves to produce detailed images of the brain and the brain stem. Identification of abnormalities in the brain needs a Specialist Doctor Consultant.
Also, identification of such abnormalities is very important, else this could lead us to major diseases like cancer.
From a business point of view, The machine learning model which identifies abnormalities in the brain given their MRI scan can counter a large number of patients, also it is cost-effective
Problem Statement :
Using the concept of Machine learning and Deep Learning we have to perform a computer vision task, where we have to do segmentation on a given Brain MRI SCAN in order to identify Abnormalities on the brain Accordingly.
Constraints
- No strict latency concerns.
- Interpretability is important.
- Errors can be very costly.
Data Overview
This dataset contains brain MR images together with manual FLAIR abnormality segmentation masks.
The images were obtained from The Cancer Imaging Archive (TCIA).
They correspond to 110 patients included in The Cancer Genome Atlas (TCGA) lower-grade glioma collection with at least fluid-attenuated inversion recovery (FLAIR) sequence and genomic cluster data available.
Tumor genomic clusters and patient data is provided in data.csv file.
All images are provided in .tif format with 3 channels per image. For 101 cases, 3 sequences are available, i.e. pre-contrast, FLAIR, post-contrast (in this order of channels).
Masks are binary, 1-channel images. They segment FLAIR abnormality present in the FLAIR sequence (available for all cases).
The dataset is organized into 110 folders named after case ID that contains information about the source institution. Each folder contains MR images with the following naming convention:
TCGA_< institution-code >< patient-id >< slice-number >.tif
Corresponding masks have a _mask suffix.
There are total Three thousand nine hundred twenty-nine {3,929} MRI scan of brain and their respective mask image
The below-given images are examples of the images which are used in the dataset, and the corresponding figure which has green highlights in the brain is the detected abnormality in the brain. If there are no abnormalities in the brain, there would be no green spot in the corresponding image.
Mapping the real-world problem to an ML problem
Using the concept of Deep Learning we have to perform a computer vision task, where we have to do segmentation on a given Brain MRI SCAN in order to identify Abnormalities on the brain Accordingly.
Type of Machine Learning Problem
This is a binary class problem statement, where either the image pixel is classified as Normal or Abnormality
DATA ANALYSIS:
While performing EDA, I tried to plot the scan image with the corresponding mask, overlapped mask, the abnormal region, dominating color of the abnormal region, and the location of the abnormal region.
Pie chart of closest dominating color in an abnormal scan.
Observation:-
If there exist any abnormilties in scan then the probability that the abnormility are
→ Black in color is 39.33%
→ Green in color is 37.58%
→ Gray in color is 19.81%
→ Bordeaux in color is 2.91%
→Light gray in color is 0.36%
Pie chart of Locations of the abnormal regions in scan images
Observation:-
If there exist any abnormilties in scan then the probability that the abnormilities are present in
→ Top Left is 34.30%
→Top Right is 27.68%
→Down Right is 22.07%
→Down Left is 15.95%
NOTE:-
The shape of all the scan and mask images are the same i.e ( 256 x 256 )
Violin Plot of Percentage of the abnormal classified pixel, only on abnormal images
Observation:-
→In Almost half of the abnormal mask images, percentage of pixel classified as abnormal is less then 2.3331, and maximum 12% of pixel that are classified as abnormal.
→In most of the mask images which has some abnormality, the abormality was found in very small area, like most of them are spread in only 1% of total image area
Histogram of Normal and Abnormal image.
Normal 2556
Abnormality 1373
Observation:-
→Most of the scan does not contain any abnormilty.
Creation of Organised Dataset
I was given 110 patient data files in separate folders in this case study, which include their brain mri scan and their respective mask image for finding abnormalities in the mri scan. To clean up my data, I create two folders, one for scan images and the other for mask images.
Observation:
→ For every scan image we have its mask image , i.e no image is missing
Then I created a data frame containing scan image path, mask image path, and a label that tells us whether the scan image is abnormal or not. The purpose of introducing this column is that, because my dataset is imbalanced between abnormal and normal images, my train and test distributions may change if I randomly split the data. To counteract this, I introduced a label column so that I can stratify split my dataset.
Splitting of Data
I randomly stratified split data into train and test datasets in the ratio 7:3
Performance Metric
- Intersection-Over-Union (Jaccard Index) SCORE
- IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth For binary (two classes) or multi-class segmentation, the mean IoU of the image is calculated by taking the IoU of each class and averaging them.
Model
I load a pre-trained ResNet architecture from U-Net Model with input shape 256,256,3 and freeze its encoder weights
U-net was created for biological image segmentation and was the first to use it. Its architecture is roughly divided into two parts: an encoder network and a decoder network. Unlike classification, where the deep network’s final result is the only thing that matters, semantic segmentation necessitates not just pixel-level discrimination but also a technique to project the discriminative features learned at various stages of the encoder onto the pixel space.
We have experimented with numerous backbones for Unet such as ResNet50, ResNeXt, SE-ResNeXt, and SE-ResNet, as well as multiple pretrained models on different datasets in the same/similar domain. After analysing the results of various architectures, we found that ResNet50 produced the greatest results, so we chose ResNet50 as the backbone of our UNet Architecture.
ResNet is an abbreviation for Residual Network. ResNet comes in a variety of flavours, each with a different number of layers but the same basic premise. The term Resnet50 refers to a variation that can work with up to 50 neural network layers.
ResNet was built specifically to address this issue. Residual blocks are used in deep residual nets to increase model accuracy. The strength of this form of neural network is the concept of “skip connections,” which is at the heart of the residual blocks.
Why U-net?
The U-Net is a simple architecture that addresses the majority of problems. This approach is based on the concept of fully convolutional networks. The purpose of the U-Net is to record both context and localization characteristics. The type of architecture used to execute this operation is successful. The implementation’s fundamental idea is to use successive contracting layers, which are then followed by upsampling operators to provide better resolution outputs on the input images.
UNet works with a small number of training samples and performs better in segmentation tasks. It learns from the samples and produces a variety of image sizes. The network can use a high number of feature channels in the up-sampling section because there are so many.
Contextual information should be propagated to higher resolution layers. Image segmentation and biomedical segmentation
With the evolution of Deep CNNs, analysis has gotten more accurate and dependable. The whole storey is here.
Connected CNNs reduce human effort in pre-processing and learn from their mistakes automatically.
Then I import my dataset from the image generator (flow from DataFrame), do prior image scaling, and augment the training image.
Then, for 50 epochs, I train our ResNet architecture, resulting in a train IOU score of 0.42 and a test IOU score of 0.4.
EPOCH VS IOU SCORE CURVE
Observation:-
→As from the very start, only train IOU score dominates over validation IOU score and as it reaches 15th epoch the gap between the curve also decreases.
EPOCH VS LOSS CURVE
Observation:-
→As from the very start, only train loss is than validation loss and as it reaches 10th epoch the gap between the curve also decreases.
PIPELINE
RESULT
Observation:-
→ Most of the images is with good precision i.e greater than 0.8
Conclusion
After examining the model’s predictions, I discovered that the best forecasts were made for scans in which the abnormality is separated in the region by a considerable bold hue and can also be easily classified by our nacked eye. Despite the fact that our model performs admirably in almost all of the scans, with extremely high precision.
Sources/Useful Links
The Dataset has been abstracted from Kaggle BRAIN TUMOR DETECTION
Research Papers :
- Metrics to Evaluate your Semantic Segmentation Model
- Understanding U-Net Architecture For Image Segmentation
- Deep Learning for Brain MRI Segmentation: State of the Art and Future Directions
- Brain Tumor Segmentation with UNET
- Brain tumor segmentation based on deep learning and an attention mechanism using MRI multi-modalities brain images
References
- https://www.appliedaicourse.com/course/11/Applied-Machine-learning-course
- Kaggle Dataset: Brain MRI segmentation
- The solution to code related issue
Future Work
We can experiment with some more Deep learning architecture from academic research, also we can try different combinations of models to find the final prediction and then by stacking their prediction according to the importance of the individual model which will be determined by their individual score.