Segmentation On Brain MRI
Segmentation On Brain MRI
Abids, Hyderabad.
Mini Project
SEGMENTATION ON
BRAIN MRI
Segmentation on brain MRI(Magnetic Resonance Imaging) using MATLAB.
160619735112~Kola Aarthy
160619735312~Doodala Ushasree
160619735322~Thatipally Sharanya
Guide~Mrs.C.V. Keerthilatha
(Assi.Prof)ECE dept.
CONTENTS
• Abstract
• Introduction
• Literature review
• Methodology
• => Theory
• => Figures
• => Graphs
• => MATLAB code and flowchart
• Discussion
• Advantages and disadvantages
• Results
• Conclusion
• Future scope
• References
ABSTRACT
Image segmentation is one of the most important tasks in medical image
analysis and is often the first and the most critical step in many clinical
applications. In brain MRI analysis, image segmentation is commonly used
for measuring and visualizing the brain's anatomical structures, for
analysing brain changes, for delineating pathological regions, and for
surgical planning and image-guided interventions. In the last few decades,
various segmentation techniques of different accuracy and degree of
complexity have been developed and reported in the literature. Benefits
of MRI is non-invasive, does not use radiation and does not involve
radiation. MRI contrasting agent is less likely to produce an allergic
reaction that may occur when iodine-based substances are used for x-rays
and CT scans. This project describes how to detect and extraction of brain
tumour from patient's MRI scan images of the brain. Here by using
MATLAB software, segmentation on MRI scan images of the brain is done.
Keywords: Brain tumour, MRI image, MATLAB.
INTRODUCTION
In this project, we develop the process of segmentation on
brain using magnetic resonance imaging (MRI) through the
MATLAB. It is used to access the brain injury and it's condition
and also provides large amount of data with high level of
quality.We review the most popular methods commonly used
for brain MRI segmentation. We discuss their capabilities,
advantages, and limitations.We first introduce the basic
concepts of image segmentation. This includes defining 2D
and 3D images, describing an image segmentation problem
and image features, and introducing MRI intensity
distributions of the brain tissue. Then, we explain different
MRI preprocessing steps including image registration, bias
field correction, and removal of nonbrain tissue. We observes
the output using MATLAB code.
LITERATURE REVIEW
We collected this mini project information from
Physionet. We searched on the topic of segmentation
on brain MRI using MATLAB in the available network
i.e, Physionet. We got images and theory on the basis
of segmentation on brain using MRI. And also we use
GitHub, google and youtube to get information on
this project.
METHODOLOGY
2D and 3D images
An image can be
defined as a
function I(i,j) in 2D
space or I(I,j,k) in
3D space. Intensity
values are typically
represented by a
gray value
{0,.......,255} in MRI
of the brain; see
Figure 1.
Figure 1
Every image consists of
a finite set of image
elements called pixels
in 2D space or voxels in
3D space. It's
coordinates, where i
is the image row
number, j is the image
column number, and k
is the slice number in a
volumetric stack; see
Figure 2.
Figure 2
Image segmentation
The goal of image
segmentation is to divide an
image into a set of
semantically meaningful,
homogeneous, and non-
overlapping regions of similar
attributes such as intensity,
depth, color, or texture.The
segmentation result is either
an image of labels identifying
each homogeneous region or a
set of contours which describe
the region
boundaries .Classification
means to assign to each
element in the image a tissue
class, where the classes are
defined in advance.
Create a
randomPatchExtractionDatastore
that contains the training image and
pixel label data.
Follow the same steps to create a
randomPatchExtractionDatastore that contains
the validation image and pixel label data.
False:
Model data
time Train
the model using the
trainNetwork (Deep
Learning Toolbox)
function.
True:
Patch size
Perform Segmentation of
Test Data
False: To Perform
True:
preprocess Segmentation
imageDir
Data Loc of Test Data
Quantify Segmentation
Accuracy(Measure the
segmentation accuracy using the
dice function.)
Create Box
False plot variable True
code
Boxplot not
created
Boxplot created
Stop
MATLAB code for
segmentation on Brain MRI
imageDir = fullfile(tempdir,'BraTS'); lblLoc = fullfile(preprocessDataLoc,'labelsTr');
if ~exist(imageDir,'dir') classNames = ["background","tumor"];
pixelLabelID = [0 1];
mkdir(imageDir); pxds =
pixelLabelDatastore(lblLoc,classNames,pixelLabelID,
end
...
sourceDataLoc = [imageDir filesep 'FileExtensions','.mat','ReadFcn',volReader);
'Task01_BrainTumour']; volume = preview(volds);
label = preview(pxds);
preprocessDataLoc = viewPnl = uipanel(figure,'Title','Labeled Training
fullfile(tempdir,'BraTS','preprocessedDataset Volume');
'); hPred =
preprocessBraTSdataset(preprocessDataLoc, labelvolshow(label,volume(:,:,:,1),'Parent',viewPnl, ..
.
sourceDataLoc);
'LabelColor',[0 0 0;1 0 0]);
volReader = @(x) matRead(x); hPred.LabelVisibility(1) = 0;
patchSize = [132 132 132];
volLoc = patchPerImage = 16;
fullfile(preprocessDataLoc,'imagesTr'); miniBatchSize = 8;
volds = imageDatastore(volLoc, ... patchds =
randomPatchExtractionDatastore(volds,pxds,patchSi
ze, ...
'FileExtensions','.mat','ReadFcn',volReader); 'PatchesPerImage',patchPerImage);
patchds.MiniBatchSize = miniBatchSize;
volLocVal = dataSource = 'Training';
fullfile(preprocessDataLoc,'imagesVal');
dsTrain =
voldsVal = imageDatastore(volLocVal, ... transform(patchds,@(patchIn)augmentAn
dCrop3dPatch(patchIn,outPatchSize,dataS
'FileExtensions','.mat','ReadFcn',volReader ource));
);
dataSource = 'Validation';
lblLocVal =
fullfile(preprocessDataLoc,'labelsVal'); dsVal =
transform(dsVal,@(patchIn)augmentAndC
pxdsVal = rop3dPatch(patchIn,outPatchSize,dataSou
pixelLabelDatastore(lblLocVal,classNames,
rce));
pixelLabelID, ...
outputLayer =
'FileExtensions','.mat','ReadFcn',volReader dicePixelClassificationLayer('Name','Outp
); ut');
dsVal = lgraph =
randomPatchExtractionDatastore(voldsVal, replaceLayer(lgraph,'Segmentation-
pxdsVal,patchSize, ... Layer',outputLayer);
'PatchesPerImage',patchPerImage); inputLayer =
dsVal.MiniBatchSize = miniBatchSize; image3dInputLayer(inputPatchSize,'Norm
numChannels = 4; alization','none','Name','ImageInputLayer'
);
inputPatchSize = [patchSize numChannels];
numClasses = 2; lgraph =
replaceLayer(lgraph,'ImageInputLayer',in
[lgraph,outPatchSize] = putLayer);
unet3dLayers(inputPatchSize,numClasses,'
ConvolutionPadding','valid'); analyzeNetwork(lgraph)
options = trainingOptions('adam', ... doTraining = false;
'MaxEpochs',50, ... if doTraining
tempSeg(i:i+outPatchSize(1)-1, ...
tempGroundTruth = read(pxdsTest); j:j+outPatchSize(2)-1, ...
groundTruthLabels{id} = tempGroundTruth{1}; k:k+outPatchSize(3)-1) = patchSeg;
vol{id} = read(voldsTest); end
end
% Use reflection padding for the test image. end
% Avoid padding of different modalities.
zID = size(vol3d,3)/2;
tempSeg = categorical(zeros([height,width,depth],'uint8'),
[0;1],classNames); zSliceGT = labeloverlay(vol3d(:,:,zID),groundTruthLabels{volId}(:,:,zID));
zSlicePred = diceResult = zeros(length(voldsTest.Files),2);
labeloverlay(vol3d(:,:,zID),predictedLabels{vo for j = 1:length(vol)
lId}(:,:,zID));
diceResult(j,:) =
figure dice(groundTruthLabels{j},predictedLabels{j});
montage({zSliceGT,zSlicePred},'Size',[1 end
2],'BorderSize',5)
meanDiceBackground = mean(diceResult(:,1));
title('Labeled Ground Truth (Left) vs. Network
Prediction (Right)') disp(['Average Dice score of background across
',num2str(j), ...
viewPnlTruth = uipanel(figure,'Title','Ground-
' test volumes =
Truth Labeled Volume'); ',num2str(meanDiceBackground)])
hTruth = meanDiceTumor = mean(diceResult(:,2));
labelvolshow(groundTruthLabels{volId},vol3d
,'Parent',viewPnlTruth, ... disp(['Average Dice score of tumor across
',num2str(j), ...
'LabelColor',[0 0 0;1 0
0],'VolumeThreshold',0.68); ' test volumes = ',num2str(meanDiceTumor)])
viewPnlPred = if createBoxplot
uipanel(figure,'Title','Predicted Labeled figure
Volume');
boxplot(diceResult)
hPred =
labelvolshow(predictedLabels{volId},vol3d,'P title('Test Set Dice Accuracy')
arent',viewPnlPred, ... xticklabels(classNames)
'LabelColor',[0 0 0;1 0 ylabel('Dice Coefficient')
0],'VolumeThreshold',0.68);
end
hPred.LabelVisibility(1) = 0;
DISCUSSION
we have defined the basic concepts necessary for
understanding MRI segmentation methods, such as
2D and 3D image definition, image features, and
brain MRI intensity distributions.Following this,
preprocessing steps necessary to prepare images for
MRI segmentation using MATLAB have been
described.The most important steps include bias field
correction, image registration, and removal of
nonbrain tissues or brain extraction. The correction of
intensity inhomogeneity is an important step for the
efficient segmentation and registration of brain MRI.
ADVANTAGES
• Identifies the presenceof tumour in humanbrain.
• Increase the chances of the patient's recovery after
treatment.
• Substantial development in the medical imaging
technologies.
• MRI is non-invasive
• MRI does not use radiation and does not involve
radiation.
DISADVANTAGES
• A major challenge for brain tumor detection arises
from the variations in tumor location, shape, and
size.
Comparison of X-ray, CT
scan and MRI:
Example
RESULTS
• MRI can detect a variety of
conditions of the brain such as
cysts, tumors, bleeding,
swelling, developmental and
structural abnormalities,
infections, inflammatory
conditions, or problems with
the blood vessels. It can
determine if a shunt is working
and detect damage to the
brain caused by an injury or a
stroke.
• By using MATLAB code we
observed these outputs in a
system.
CONCLUSION
Image segmentation is an important step in many
medical applications involving 3D visualization,
computer-aided diagnosis, measurements, and
registration. This paper has provided a brief
introduction to the fundamental concepts of MRI
segmentation of the human brain and methods that
are commonly used. MATLAB is the easiest software
to understand the conditionof brain using MRI
preprocessing.
FUTURE SCOPE
• In future, this technique can be developed to
classify the tumours based on feature extraction.
• This technique can be applied for ovarian, breast,
lung, skin tumours.
• Instead of rectangular boxes, can work with general
boundaries: level set based framework.
REFERENCES
• Teacher notes and lab manual
• MATLAB software
• Physionet and GitHub
• Google and YouTube