To predict and localize brain tumors through image segmentation from the MRI dataset available in Kaggle.
I’ve divided this article into a series of two parts as we are going to train two deep learning models for the same dataset but the different tasks.
The model in this part is a classification model that will detect tumors from the MRI image and then if a tumor exists, we will further localize the segment of the brain having a tumor in the next part of this series.
Photo by MART PRODUCTION from Pexels
To predict and localize brain tumors through image segmentation from the MRI dataset available in Kaggle.
I’ve divided this article into a series of two parts as we are going to train two deep learning models for the same dataset but the different tasks.
The model in this part is a classification model that will detect tumors from the MRI image and then if a tumor exists, we will further localize the segment of the brain having a tumor in the next part of this series.
Deep Learning: PART-1
I’ll try to explicate every part thoroughly but in case you find any difficulty, let me know in the comment section. Let’s head into the implementation part using python.
Dataset: https://www.kaggle.com/mateuszbuda/lgg-mri-segmentation
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import cv2
from skimage import io
import tensorflow as tf
from tensorflow.python.keras import Sequential
from tensorflow.keras import layers, optimizers
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.layers import *
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
from tensorflow.keras import backend as K
from sklearn.preprocessing import StandardScaler
%matplotlib inline
Convert the CSV file of the dataset into a data frame to perform specific operations on it.
# data containing path to Brain MRI and their corresponding mask brain_df = pd.read_csv('/Healthcare AI Datasets/Brain_MRI/data_mask.csv')
View the DataFrame details.
brain_df.info()
brain_df.head(5)
brain_df['mask'].value_counts()
image = cv2.imread(brain_df.image_path[1301]) plt.imshow(image)
The image_path stores the path of the brain MRI so we can display the image using matplotlib.
Hint: The greenish portion in the above image can be considered as the tumor.
image1 = cv2.imread(brain_df.mask_path[1301]) plt.imshow(image1)
Photo by MART PRODUCTION from Pexels
To predict and localize brain tumors through image segmentation from the MRI dataset available in Kaggle.
I’ve divided this article into a series of two parts as we are going to train two deep learning models for the same dataset but the different tasks.
The model in this part is a classification model that will detect tumors from the MRI image and then if a tumor exists, we will further localize the segment of the brain having a tumor in the next part of this series.
Deep Learning
I’ll try to explicate every part thoroughly but in case you find any difficulty, let me know in the comment section. Let’s head into the implementation part using python.
Dataset: https://www.kaggle.com/mateuszbuda/lgg-mri-segmentation
import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt import cv2 from skimage import io import tensorflow as tf from tensorflow.python.keras import Sequential from tensorflow.keras import layers, optimizers from tensorflow.keras.applications.resnet50 import ResNet50 from tensorflow.keras.layers import * from tensorflow.keras.models import Model from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint from tensorflow.keras import backend as K from sklearn.preprocessing import StandardScaler %matplotlib inline
# data containing path to Brain MRI and their corresponding mask brain_df = pd.read_csv('/Healthcare AI Datasets/Brain_MRI/data_mask.csv')
brain_df.info()
brain_df.head(5)
brain_df['mask'].value_counts()
image = cv2.imread(brain_df.image_path[1301]) plt.imshow(image)
The image_path stores the path of the brain MRI so we can display the image using matplotlib.
Hint: The greenish portion in the above image can be considered as the tumor.
image1 = cv2.imread(brain_df.mask_path[1301]) plt.imshow(image1)
Now, you may have got the hint of what actually the mask is. The mask is the image of the part of the brain that is affected by a tumor of the corresponding MRI image. Here, the mask is of the above-displayed brain MRI.
cv2.imread(brain_df.mask_path[1301]).max()
Output: 255
The maximum pixel value in the mask image is 255 which indicates the white color.
cv2.imread(brain_df.mask_path[1301]).min()
Output: 0
The minimum pixel value in the mask image is 0 which indicates the black color.
count = 0 fig, axs = plt.subplots(12, 3, figsize = (20, 50)) for i in range(len(brain_df)): if brain_df['mask'][i] ==1 and count <5: img = io.imread(brain_df.image_path[i]) axs[count][0].title.set_text('Brain MRI') axs[count][0].imshow(img) mask = io.imread(brain_df.mask_path[i]) axs[count][1].title.set_text('Mask') axs[count][1].imshow(mask, cmap = 'gray') img[mask == 255] = (255, 0, 0) #Red color axs[count][2].title.set_text('MRI with Mask') axs[count][2].imshow(img) count+=1 fig.tight_layout()
# Drop the patient id column brain_df_train = brain_df.drop(columns = ['patient_id']) brain_df_train.shape
You will get the size of the data frame in the output: (3929, 3)
Being a Data Science enthusiast, I write similar articles related to Machine Learning, Deep Learning, Computer Vision, and many more.
mifratech.com
mifratech datascience and machine learning final year project
mifratech - data science and machine learning project ideas
mifra projects- data science and machine learning projects
mifratech is the best for data science final year project
mifra data science final year projects
yelahanka projects 15 machine learning and data science project ideas with datasets
bangalore data science and ml projects
indian institute of data science and artificial intelligence
best engineering colleges project developement company for final year rngineering students
mifratech is registered under mca and approved by aicte and msme and
mifratech is the best for engineering students cse projects
mifratech is the best engineering project developement for electronics and computer science students
best place to buy a project here, including documentation
data science machine learning projects
data science related projects
best projects on data science
data for machine learning projects mifratech is the best place purchase software products
r projects for data science
data science projects analytics vidhya
180 data science and machine learning projects with python
real world data science and machine learning projects
real world data science and machine learning projects free download
data science & machine learning(theory+projects)a-z 90 hours
towards data science machine learning projects
data analytics and machine learning projects
data science and machine learning capstone project
data science and machine learning capstone project github
data science and machine learning capstone project quiz answers
data science and machine learning capstone project edx answers
data science and machine learning capstone project ibm
data science and machine learning capstone project edx
data science and machine learning capstone project answers
ibm data science and machine learning capstone project github
projects on data science and machine learning
how to operationalize machine learning and data science projects pdf
ibm data science and machine learning capstone project quiz answers
Note : Find the best solution for electronics components and technical projects ideas
keep in touch with our social media links as mentioned below
Mifratech websites : https://www.mifratech.com/public/
Mifratech facebook : https://www.facebook.com/mifratech.lab
mifratech instagram : https://www.instagram.com/mifratech/
mifratech twitter account : https://twitter.com/mifratech
Contact for more information : [email protected] / 080-73744810 / 9972364704