Brain Tumor MRI Detection Using Matlab
Brain Tumor MRI Detection Using Matlab
by ashleynu
Once the tumor is detected, the instructions will 3. The focus of this program and the various methods
further describe how to incorporate this program into that guide this project are outlined in this research
a graphical user interface (GUI). Throughout these paper: https://www.mathworks.com/downloads/
instructions, the appropriate code and files will be
attached to help explain how this MRI scan analysis
The first step would be to create and initiate the the most important feature that must be altered when
graphical user interface, GUI. This could be done by creating these functions is the Tag name. It is
typing guide into the command window, pressing important to change the Tag name of each function
enter, and creating a new GUI. Once this step is that is implemented because it will allow us to create
completed you can begin to create functions such as a distinguishable callback function. Once you are
axes, static text, edit text, and push buttons that will satisfied with the layout of your GUI you can move on
be displayed once the program is run and the user to loading the DICOM files that will be displayed
can interact with. These functions can be edited and within the GUI.
manipulated through the property inspector, however
In order to load the DICOM files you would have to The built in MATLAB function ‘dicominfo’ is also
correctly initialize the call back function that would be extremely useful in addressing all the information of
executed when pressing the button “Load MRI each MRI dicom file. We utilized this function to
Image.” Once this is completed, you must create a extract all the descriptive information of the patients,
global variable that would display the image on the such as their sex, age, weight, and height. This
handles axes where you want the Original MRI Image function also provides you with the stack order which
to be displayed. The MRI scan images downloaded is useful for implementation of the program within the
from the database are all DICOM formatted files that graphical user interface. We created variables for
need to be loaded into your MATLAB directory. each of the descriptive information of the patients
Locate the file using imgetfile in order to load them which will be used for the GUI when the detect button
into the program. The images are read using the built is pressed.
in MATLAB function ‘dicomread’, and the first raw
image for each file is imbedded into the left GUI axes
using imshow.
Once the DICOM file of the raw image has been preserves the edges in a 5 x 5 square around each
loaded and read, the image needs to be converted pixel. Next, we apply a sliding window using ‘strel’, to
from grayscale into a binarized form consisting of only create a disk shaped flat structuring element with a
black and white pixels We used the function neighborhood radius of 2 to identify each central,
‘imbinarize’ to create a binary image from the raw origin pixel, in each disk neighborhood. We utilized a
image by controlling aspects of adaptive thresholding disk structuring element because we are analyzing
at sensitivity value of 0.59. The default threshold each circular spot and the pixels within each spot, so
sensitivity factor, 0.5 was low and unable to detect a disk shape element is more useful.
the brighter blobs and spots from the image, so we
increased it to 0.59. Once the image has been filtered, it can be cleaned
using the ‘imclose’ function to remove the black spots
in between the filtered white pixels in the image, and
The binarized image is then processed through a closes all the gaps around it. The completely
median filter using the function ‘medfilt2’ because the processed image can then be plotted in the second
binarized image is two-dimensional. We set each subplot of the pre-allocated figure, allowing a
output pixel to contain the median value in the 5 x 5 comparison between the raw and filtered image.
neighborhood around the corresponding pixel in the
input binarized image. This reduces the noise and
The bright spots of the tumor can then be isolated coordinates based on the coordinates contained in
from the main filtered image through a pre-generated vectors from 1 to the length of the x-axis, and from 1
elliptical mask. To create this mask, you should know to the length of the y-axis of the image. Col is a matrix
the size of the original, raw MRI scan image, and where each row is a copy of the x-axis, and Row is a
using it’s row and column length, as x and y- matrix where each column is a copy of the y-axis. The
coordinates respectively, allocate the center cartesian grid represented by the coordinates Col and
coordinates for the elliptical. We set the y-axis as a Row has length(1:Y_Size) rows and length(1:X_Size)
major axis with a radius of 50 units from the center, columns. Use the indices of Col and Row generated
and the minor axis with a radius of 40 units from the by the cartesian grid to determine the equation of
center. ellipse depending on the predetermined radius and
center coordinates. The elliptical outline can now be
filled with the white pixels found from tumor spots.
We used the MATLAB function ‘meshgrid’ to
generate a cartesian plane with two dimensional grid Utilizing the pre-generated elliptical mask we can
crop out the specific tumor you wish to analyze from greater neighborhood radius of 6, to close the gaps
the filtered image. The elliptical mask detects which between each central white pixel within the detected
spots logically fit within the outline of the ellipse and tumor. The detected tumor spot is further cleaned up
accepts this as a spot on the filtered image to be using ‘imclose’ to further eliminate the black pixels
acceptable as a tumor. The function ‘bwareafilt’ then and fill in all the holes with ‘imfill’. This processed
filters out all other objects outside this detected tumor tumor can then be displayed in the third subplot in the
from the image. We used a specific window of 500 by preallocated plot to provide a comparison between
4000 empirically based on the dimensions of all the the isolated tumor and the original and filtered images
images. We then applied another sliding window with of the MRI scan.
‘strel’ as a flat disk shaped structuring element of a
Now that the tumor is isolated with the mask, it can original, raw image, using a ‘for’ loop that plots the
be be outlined and displayed on the original image, to outline around the tumor using the indices of the line
show its exact location. To do this, we used the with a line width of 1.5 pixels. This outline is then
function ‘bwboundaries’ to trace the previously plotted onto the raw image, showing the exact size
detected tumor with an outline. We specified the and location of the tumor, relative to the original MRI
outline to not include the holes within the tumor object scan.
as it is being outlined. This can be plotted onto the
The isolated and outlined spot can provide us with world units of millimeters. The empirical information
useful information about the size, area, and location the program provides us with is unique for each MRI
of the tumor. We used the ‘regionprops’ function to scan and is extremely useful in determining the size,
detect the properties of the tumor that pertain to area, location, and type of tumor, that the users can
perimeter, centroids, and the pixel index value. This analyze and incorporate into the graphical user
pixel index value gives us the real world units for interface.
each pixel of each image, unique to each scan.
These properties can then be converted into real