Download as pdf or txt
Download as pdf or txt
You are on page 1of 57

Brain Tumor Detection

CHAPTER 1
INTRODUCTION
Before dealing with the brain tumors and MR Images, the basic structure of human brain must be
understood well. Following are the main parts of human brain.
The human brain is the central organ of the human nervous system, and with the spinal cord makes up
the central nervous system. The brain consists of the cerebrum, the brainstem and the cerebellum as
shown in Figure 1.1. It controls most of the activities of the body, processing, integrating, and
coordinating the information it receives from the sense organs, and making decisions as to the
instructions sent to the rest of the body.

Fig 1.1: Brain Anatomy


The cerebrum is the largest part of the brain. The cerebrum is the largest and best-developed of the
five major divisions of the brain. The cerebrum is made up of the two cerebral hemispheres separated
from each other by a deep fissure called the longitudinal fissure.

Frontal Lobe - It is the front part of the brain and is involved in planning, organizing, problem solving,
selective attention, personality and a variety of "higher cognitive functions" including behavior and
emotions.

Occipital Lobe - It is the region in the back of the brain which processes visual information. It also
contains association areas that help in the visual recognition of shapes and colors.

1
Brain Tumor Detection

Parietal Lobe - One of the two parietal lobes of the brain located behind the frontal lobe at the top of
the brain.

Temporal Lobe - There are two temporal lobes, one on each side of the brain located at about the level
of the ears. These lobes allow a person to tell one smell from another and one sound from another.
They also help in sorting new information and are believed to be responsible for short-term memory.

1.1 BRAIN TUMOR


There are many diseases affecting human body. Diseases of brain are very common in human body. It
takes place in different forms. Some of the major classes of brain diseases are tumors, infections,
stroke, trauma and seizures. An infamous disease has affected and devastated many lives which is brain
tumour. Brain tumors affect the humans badly, because of the abnormal growth of cells within the
brain. It can disrupt proper brain function and be life-threatening. Two types of brain tumors have been
identified as benign tumors and malignant tumors. Benign tumors are less harmful than malignant
tumors as malignant are fast developing and harmful while benign are slow growing and less harmful.

1.2 TUMORS TYPES


1.2.1 Primary Brain Tumors:
A tumor which begins in brain is called primary brain tumor it can be either malignant which is
cancerous or benign which is non-cancerous.
1.2.2 Secondary Brain Tumors:
A cancerous tumor which starts from other part of body and end up in brain is known as secondary or
metastatic brain tumor. Depending upon the abnormality of cell appearance and aggressive growth
tumors is classified into grades. They are
Grade I: The tissue is said to be benign, grows slowly and resembles like the healthy cell.
Grade II: The tissue is said to be malignant, tissues doesn’t resemble like the regular cell.
Grade III: These malignant tissues are the cells which are more irregular to look at and rapidly
growing.
Grade IV: These malignant tissues are the most abnormal and tend to grow at faster rate.

2
Brain Tumor Detection

1.4 SYMPTOMS
Most common symptoms of brain tumors are headaches, nausea and vomiting, change in speech,
vision, or hearing, mood, personality problems, memory, balancing or walking, ability to concentrate,
muscle jerking or twitching and numbness or tingling in the arms and legs.

1.5 INTRODUCTION TO IMAGE PROCESSING


1.5.1 Image
An image may be defined as a two-dimensional function, f(x, y), where x and y are spatial (plane)
coordinates, and the amplitude of f at any pair of coordinates (x, y) is called the intensity or gray level
of the image at that point. When x,y and the amplitude values of f are all finite, discrete quantities, we
call the image a digital image.

1.5.2 Digital Image Processing


The field of digital image processing refers to processing digital images by means of a digital
computer. Digital image is composed of a finite number of elements, each of which has a particular
location and value. Those elements are referred to as picture elements, image elements, pels and pixels.
Pixel is the term most widely used to denote the elements of a digital image.
1.6 FUNDAMENTAL STEPS IN IMAGE PROCESSING

Figure 1.2 Block Diagram of Digital Image Processing

3
Brain Tumor Detection

Image acquisition:

Image acquisition is the first process in Image Processing. The image acquisition stage involves
preprocessing steps such as scaling and sampling.

Image Enhancement:

Image enhancement is the simplest and most appealing areas of digital image processing. The idea
behind enhancement techniques is to simply highlight certain features of interest in an image. An
example of enhancement is increasing the contrast of an image because “it looks better.” Image
Enhancement is a very subjective area of image processing. Image Enhancement is based on human
subjective preferences regarding what constitutes a good enhancement result. Enhancement of an
image can be implemented by using different operations of brightness increment, sharpening, blurring
or noise removal as shown in Figure 1.2.

Image Restoration:

Image restoration is an area that also deals with improving the appearance of an image. However,
unlike enhancement, which is subjective, image restoration is objective in the sense that restoration
techniques tend to be based on mathematical or probabilistic models of image degradation.

Morphological processing:

Morphological processing deals with tools for extracting image components that are useful in the
representation and description of shape.

Image Segmentation:

Image segmentation procedures partition an image into its constituent parts or objects. In general,
autonomous segmentation is one of the most difficult tasks in digital image processing.

Image Representation and Description:

Representation and description always follow the output of a segmentation stage, which usually is raw
pixel data, constituting either the boundary of a region (i.e., the set of pixels separating one image
region from another) or all the points in the region itself. The first decision that must be made is whether
the data should be represented as a boundary or as a complete region. Boundary representation mainly
focuses on external shape characteristics such as corners and inflections.

4
Brain Tumor Detection

Regional representation is appropriate when the focus is on internal properties such as texture or
skeletal shape.

Image Compression:

Compression deals with techniques reducing the storage required to save an image or the bandwidth
required to transmit the image.

Color image processing is divided into two major areas:

i) Full color image processing

ii) Pseudo color image processing

Color Image Processing:

Color image processing is an area that has been gaining its importance because of the significant
increase in the use of digital images over the Internet.

1.7 HISTOGRAM

The histogram plots the number of pixels in the image (vertical axis) with a particular brightness value
(horizontal axis). Algorithms in the digital editor allow the user to visually adjust the brightness value
of each pixel and to dynamically display the results. Improvements in picture brightness and contrast
can thus be obtained.

1.7.1 Histogram Processing

The histogram of a digital image with gray levels in the range [0,L-1] is a discrete function ℎ(𝑟𝑘) =
𝑛𝑘where rk is the 𝑘𝑡ℎ gray level and 𝑛𝑘 is the number of pixels in the image having gray level𝑟𝑘. It is
used to normalize a histogram by dividing each of its values by the total number of pixels in the image,
denoted by n.Thus, a normalized histogram is given by 𝑝(𝑟𝑘) = 𝑛𝑘/𝑛 , for k=0,1,p,L- 1.Loosely
speaking,𝑝(𝑟𝑘)gives an estimate of the probability of occurrence of gray level𝑟𝑘. The sum of all
components of a normalized histogram is equal to 1.

Histograms are the basis for numerous spatial domain processing techniques. Histogram manipulation
can be used effectively for image enhancement, as shown in the Figure 1.3.In addition to providing
useful image statistics, we shall see that the information inherent in histograms also is quite useful in
other image processing applications, such as image compression and segmentation.

5
Brain Tumor Detection

Histograms are simple to calculate in software and also lend themselves to economic hardware
implementations, thus making them a popular tool for real-time image processing.

Fig 1.3 Histogram of Sampled Image

1.7.2 Histogram Equalization

Contrast enhancement techniques in the second subgroup modify the image through some pixel
mapping such that the histogram of the processed image is more spread than that of the original image.
If a single mapping derived from the image is used then it is a global method, if the neighborhood of
each pixel is used to obtain a local mapping function then it is a local method. Using a single global
mapping cannot enhance the local contrast. One of the most popular global contrast enhancement
techniques is Histogram Equalization (HE).

The histogram in the context of image processing is the operation by which the occurrence of each
intensity value. Normally, the histogram is a graph showing the number of pixels in an image at each
different intensity value found in that image. Histogram Equalization is the technique by which the
dynamic range of the histogram of an image is increased. HE assigns the intensity values of pixels in
the input image such that the output image contains a uniform distribution of intensities. It improves
contrast and the goal of HE is to obtain a uniform histogram. This technique can be used on a whole
image or just on a part of an image. This method usually increases the global contrast of many images,
especially when the usable data of the image is represented by close contrast values. Through this
adjustment, the intensities can be better distributed on the histogram. This allows for
6
Brain Tumor Detection

areas of lower local contrast to gain a higher contrast without affecting the global contrast. Histogram
equalization accomplishes this by effectively spreading out the most frequent intensity values. The
method is useful in images with backgrounds and foregrounds that are both bright or both dark. In
particular, the method can lead to better views of bone structure in x-ray images, and to better detail
in photographs that are over or under-exposed.

Consider for a moment continuous functions, and let the variable r represent the gray levels of the
image to be enhanced. In the initial part of our discussion we assume that r has been normalized to the
interval [0, 1], with r=0 representing black and r=1 representing white. We consider a discrete
formulation and allow pixel values to be in the interval [0, L-1].

S = T(r) where 0 ≤ r ≤ 1

Histogram equalization is a specific case of the more general class of histogram remapping methods.
These methods seek to adjust the image to make it easier to analyze or improve visual quality. The
above example describes histogram equalization on a grey-scale image. However it can also be used
on color images by applying the same method separately to the Red, Green and Blue components of
the RGB color values of the image. Still, it should be noted that applying the same method on the Red,
Green, and Blue components of an RGB image may yield dramatic changes in the image's color
balance since the relative distributions of the color channels change as a result of applying the
algorithm.

Advantages:

The advantage of the method is that it is a fairly straightforward technique and an invertible operator.
So in theory, if the histogram equalization function is known, then the original histogram can be
recovered.

Disadvantages:

A disadvantage of the method is that it is indiscriminate. It may increase the contrast of background
noise, while decreasing the usable signal.

1.8 SEGMENTATION
Image segmentation is the division of an image into regions or categories, which correspond to
different objects or parts of objects. Segmentation is often the critical step in image analysis: the point
at which we move from considering each pixel as a unit of observation to working with objects (or
parts of objects) in the image, composed of many pixels. If segmentation is done well then all
7
Brain Tumor Detection

other stages in image analysis are made simpler, but as we shall see, success is often only partial when
automatic segmentation algorithms are used. However, manual intervention can usually overcome
these problems, and by this stage the computer should already have done most of the work. There are
three general approaches to segmentation termed Thresholding, edge-based methods and region-based
methods.
1.8.1 DIFFERENT APPROACHES FOR SEGMENTATION

Digital image segmentation can be divided as below:

i) Local segmentation - Segments into specific part or region of image.


ii) Global segmentation - Segments the whole image, consisting of a large number of pixels.

Based on the properties of an image, the segmentation process can be categorized into these two types.
Digital Image Segmentation can be classified as follows:

• Region Based Segmentation.


• Edge Based Segmentation.
• Thresholding
• Clustering (Based on features)

1.8.1 (a) Region Based Segmentation


Region based segmentation can further be divided into the following:
Region growing methods: In region growing based segmentation methods, based on the growing of
seeds (initial pixels) the whole region of the image is segmented into various regions. These initial
pixels or seeds can be selected manually (based on prior knowledge) or automatically (based on
particular application). Also, the growing of seeds is controlled by connectivity between pixels, and
with the help of the prior knowledge of problem, it can be further stopped. The basic connectivity
algorithms are used for region growing methods are
Region splitting and merging methods: An image is divided into uniform regions by splitting and
merging. It uses two basic techniques i.e. splitting and merging for segmenting an image into various
regions. Splitting iteratively divides an image into regions having similar characteristics and merging
contributes to combining the adjacent similar regions. Split and merge algorithms are used for such a
type of segmentation.
1.8.1(b) Edge Detection
Edge detection is a common method to segment an image. The sudden changes of discontinuities in
an image are called as edges or significant transitions in an image are called as edges as shown in

8
Brain Tumor Detection

figure 1.5. It detects and outlines of an object and boundaries among various objects and the
background in the image. It detects significant discontinuities in intensity values of an image. Essential
information regarding the shapes of objects in the scene is retained even though the edge representation
of an image significantly reduces the quantity of data to be processed. Edge detection facilitates higher
level image analysis therefore is an active area of research. Basically, three different types of
discontinuities occur in the grey level like point, line and edges and spatial masks can be used to detect
these discontinuities in an image.

Fig 1.4 Original Image

Fig 1.5 Edge detected Image

1.8.1(c) Thresholding
In Thresholding, pixels are allocated to categories according to the range of values in which a pixel
lies. It shows boundaries which were obtained by Thresholding the muscle fibers image. Pixels with
values less than threshold value have been placed in one category, and the rest have been placed in the
other category. The boundaries between adjacent pixels in diff erent categories have been
superimposed in white on the original image as shown in Figure 1.6.

9
Brain Tumor Detection

Thresholding is the simplest and most commonly used method of segmentation. Given a single
threshold, t, the pixel located at lattice position (i,j), with grayscale value fij, is allocated to zero (Black)
if fij ≤ t. Otherwise, the pixel is allocated to one (White). In many cases, by trying a range of values of
t and seeing which one works best at identifying the objects of interest.

Fig 1.6 Thresholding


1.9 CLUSTERING (BASED ON FEATURES)
An image is segmented into clusters having pixels with similar characteristics using clustering.
Clustering divides the data elements into different clusters such that elements in same cluster are more
similar to each other than elements in other clusters. Clustering can further be classified into:
i) Hierarchical method: A Hierarchical method uses the concept of trees, where the root of the tree
represents whole database and the internal nodes represent the clusters.
ii) Partition based method: Partition based methods use optimization methods iteratively that
minimizes an objective function.

1.9.1 Types of Clustering


i) Hard Clustering: Hard clustering divides an image into set of clusters such that one pixel can only
belong to only one cluster. Membership functions having values either 1 or 0 are used by these methods
which define whether a pixel can belong to particular cluster or not.
E.g. K-means clustering.
ii) Soft clustering: In soft clustering techniques division is not strict so they are most useful for image
segmentation.
E.g. fuzzy c-means clustering, in which pixels are partitioned into clusters based on partial
membership. In this technique one pixel can belong to more than one clusters and this degree of
belonging is described by membership values.

10
Brain Tumor Detection

CHAPTER 2

BRAIN IMAGING TECHNIQUES


Brain imaging techniques allow doctors and researchers to view activity or problems within the human
brain, without invasive neurosurgery. There are a number of accepted, safe imaging techniques in use
today in research facilities and hospitals throughout the world.

2.1 fMRI (FUNCTIONAL MAGNETIC RESONANCE IMAGING)

functional Magnetic Resonance Imaging, or fMRI, is a technique for measuring brain activity. It works
by detecting the changes in blood oxygenation and flow that occur in response to neural activity –
when a brain area is more active it consumes more oxygen and to meet this increased demand blood
flow increases to the active area. fMRI can be used to produce activation maps showing which parts
of the brain are involved in a particular mental process as shown in Figure 2.1.

The fMRI is a series of MRIs that measures both the structure and the functional activity of the brain
through computer adaptation of multiple images. Specifically, the fMRI measures signal changes in
the brain that are due to changing neural activity. In an fMRI, a patient can perform mental tasks and
the area of action can be detected through blood flow from one part of the brain to another by taking
pictures less than a second apart and showing where the brain “lights up.” For example, when a person
processes visual information, blood rushes to the back of the brain, which is where the occipital lobe
is located. fMRIs make it possible to show when things happen, how brain areas change with
experience, and which brain areas work together. They have been used to study a wide range of
psychological phenomena, including the neural activity of telling a lie, the differences between novices
and experts when playing a musical instrument, and what happens inside our heads when we dream.

Fig 2.1 fMRI scan Image

11
Brain Tumor Detection

2.2 CT SCAN(COMPUTED TOMOGRAPHY SCANNING)

Computed Tomography (CT) scanning builds up a picture of the brain based on the differential
absorption of X-rays. During a CT scan the subject lies on a table that slides in and out of a hollow,
cylindrical apparatus. An x-ray source rides on a ring around the inside of the tube, with its beam aimed
at the subjects head. After passing through the head, the beam is sampled by one of the many detectors
that line the machine’s circumference. Images made using x-rays depend on the absorption of the beam
by the tissue it passes through. Bone and hard tissue absorb x-rays well, air and water absorb very little
and soft tissue is somewhere in between. Thus, CT scans reveal the gross features of the brain but do
not resolve its structure well.There is always a slight chance of cancer from excessive exposure to
radiation as shown in Figure 2.2.

Fig 2.2 CT Scan brain image

2.3 PET (POSITRON EMISSION TOMOGRAPHY)

Positron Emission Tomography (PET) uses trace amounts of short-lived radioactive material to map
functional processes in the brain. When the material undergoes radioactive decay a positron is emitted,
which can be picked up by the detector. Areas of high radioactivity are associated with brain activity.
Positron emission tomography (PET) scans measure levels of the sugar glucose in the brain in order to
illustrate where neural firing is taking place as shown in Figure 2.3. This works because active neurons
use glucose as fuel. As part of the scan, a tracer substance attached to radioactive isotopes is injected
into the blood. When parts of the brain become active, blood (which contains the tracer) is sent to
deliver oxygen. This creates visible spots, which are then picked up by detectors and used to create a
video image of the brain while performing a particular task. However, with PET scans, we can only
locate generalized areas of brain activity and not specific locations. In addition, PET scans are costly
and invasive, making their use limited. However, they can be used in some forms of medical diagnosis,
including for Alzheimer’s.
12
Brain Tumor Detection

Fig 2.3 PET Scanned Brain

2.4 EEG (ELECTROENCEPHALOGRAPHY)

Electroencephalography (EEG) is the measurement of the electrical activity of the brain by recording
from electrodes placed on the scalp. The resulting traces are known as an electroencephalogram (EEG)
and represent an electrical signal from a large number of neurons as shown in Figure 2.4.

EEGs are frequently used in experimentation because the process is non-invasive to the research
subject. The EEG is capable of detecting changes in electrical activity in the brain on a millisecond-
level. It is one of the few techniques available that has such high temporal resolution.Electro
Encephalography (EEG) is used to show brain activity in certain psychological reactions such as
alertness or drowsiness. It is useful in the diagnosis of seizures and other medical problems that involve
an overabundance or lack of activity in certain parts of the brain.

To prepare for an EEG, electrodes are placed on the face and scalp. After placing each electrode in the
right position, the electrical potential of each electrode can be measured. According to a person’s state
(waking, sleeping, etc.), both the frequency and the form of the EEG signal differ. Patients who suffer
from epilepsy show an increase of the amplitude of firing visible on the EEG record. The disadvantage
of EEG is that the electric conductivity and therefore the measured electrical potentials—may vary
widely from person to person and also over time, due to the natural conductivities of other tissues such
as brain matter, blood, and bones. Because of this, it is sometimes unclear exactly which region of the
brain is emitting a signal.

13
Brain Tumor Detection

Fig 2.4 EEG Recording Setup

2.5 NIRS (NEAR INFRARED SPECTROSCOPY)

Near infrared spectroscopy is an optical technique for measuring blood oxygenation in the brain. It
works by shining light in the near infrared part of the spectrum (700-900nm) through the skull and
detecting how much the remerging light is attenuated as shown in Figure 2.5. How much the light is
attenuated depends on blood oxygenation and thus NIRS can provide an indirect measure of brain
activity.

Fig 2.5 NIRS Brain Image

2.6 MEG (MAGNETO ENCEPHALOGRAPHY)

Magneto Encephalography (MEG) is an imaging technique used to measure the magnetic fields
produced by electrical activity in the brain via extremely sensitive devices known as SQUIDs. These
measurements are commonly used in both research and clinical settings. There are many uses for the
MEG, including assisting surgeons in localizing pathology, assisting researchers in determining the
function of various parts of the brain, neuro feedback, and others. This can be applied in a clinical
setting to find locations of abnormalities as well as in an experimental setting to simply measure brain
activity as shown in Figure 2.6.
14
Brain Tumor Detection

Fig 2.6 MEG Brain image

2.7 MRI (MAGNETIC RESONANCEIMAGING)


Medical imaging technique is used to create visual representation of interior of the human body for
medical purposes and noninvasive possibilities can be diagnosed by this technology. The various types
of medical imaging technologies based on noninvasive approach like; MRI, CT scan, Ultrasound,
SPECT, PET and X-ray. When compared to other medical imaging techniques, Magnetic Resonance
Imaging (MRI) is majorly used to examine soft tissues such as cartilage, muscles and other conditions
like tumour, inflammatory diseases. It provides greater contrast images of the brain and cancerous
tissues. Therefore, brain tumor identification can be done accurately through MRI images.

2.7.1 MRI Working


MRI is an imaging technique that produces images of internal Physical, Chemical and Functional
characteristics of an object. MRI is also used to examine internal body structures and diagnose a variety
of disorders such as strokes, tumours, aneurysms, spinal cord injuries, eye and inner ear problems. It
is also widely used in research to measure brain structure and function among other things. The human
body is mostly water. Water molecules (H2O) contain hydrogen nuclei (protons), which become
aligned in a magnetic field. An MRI scanner applies a very strong magnetic field which aligns the
proton "spins". The scanner also produces a radio frequency current that creates a varying magnetic
field as shown in Figure 2.9. The protons absorb the energy from the magnetic field and flip their spins.
When the field is turned off, the protons gradually return to their normal spin, a process called
precession. The return process produces a radio signal that can be measured by receivers in the scanner
and made into an image. Protons in different body tissues return to their normal spins at different rates,
so the scanner can distinguish among various types of tissue. The scanner settings can be adjusted to
produce contrasts between different body tissues. Additional magnetic fields are used to produce 3-
dimensional images that may be viewed from different angles.

15
Brain Tumor Detection

Fig 2.7 MRI Machine

Fig 2.8 MRI Scanner

16
Brain Tumor Detection

Fig 2.9 MRI Working

2.7.2 Advantages of MRI


• High spatial resolution
• Exceptional description of soft tissues.
• Functional brain measurement
• No hazard for human body

2.7.3 MRI Applications


• Examining the abnormalities of the brain and spinal cord.
• Examining the tumors, cysts, and other abnormalities in various parts of the body.
• Examining the injuries or abnormalities of the joints.
• Examining the diseases of the liver and other abdominal organs.
• Knowing causes of pelvic pain in women.
• Finding the unhealthy tissue in the body.
• Planning the surgery.
• Providing a global view of collateral veins.
• Providing a global view of intra and extra cranial.

17
Brain Tumor Detection

CHAPTER 3
LITERATURE SURVEY

18
Brain Tumor Detection

19
Brain Tumor Detection

CHAPTER 4
METHODOLOGY

4.1 Draw backs of Gradient Based Methods


Traditional calculus based methods work by starting at a random point and by moving in the
direction of the gradient, till we reach the top of the hill. This technique is efficient and works very
well for single-peaked objective functions like the cost function in linear regression. But, in most
real-world situations, we have a very complex problem called as landscapes, which are made of
many peaks and many valleys, which causes such methods to fail, as they suffer from an inherent
tendency of getting stuck at the local optima as shown in the following figure 4.1.

Figure 4.1 Optima of Multi-peak objective function

4.2 Introduction to Optimization

Optimization is the process of making something better. In any process, we have a set of inputs
and a set of outputs as shown in the following figure 4.2.

20
Brain Tumor Detection

Figure 4.2 Block diagram of Optimization

Optimization refers to finding the values of inputs in such a way that we get the “best” output
values. The definition of “best” varies from problem to problem, but in mathematical terms, it
refers to maximizing or minimizing one or more objective functions, by varying the input
parameters.

The set of all possible solutions or values which the inputs can take make up the search space. In
this search space, lies a point or a set of points which gives the optimal solution. The aim of
optimization is to find that point or set of points in the search space.

4.3 Genetic Algorithm

4.3.1 Introduction
Genetic Algorithm (GA) is a search-based optimization technique based on the principles of
Genetics and Natural Selection. It is frequently used to find optimal or near-optimal solutions to
difficult problems which otherwise would take a lifetime to solve. It is frequently used to solve
optimization problems, in research, and in machine learning.

Nature has always been a great source of inspiration to all mankind. Genetic Algorithms (GAs)
are search based algorithms based on the concepts of natural selection and genetics. GAs are a
subset of a much larger branch of computation known as Evolutionary Computation.

GAs were developed by John Holland and his students and colleagues at the University of
Michigan, most notably David E. Goldberg and has since been tried on various optimization
problems with a high degree of success.

21
Brain Tumor Detection

In GAs, we have a pool or a population of possible solutions to the given problem. These solutions
then undergo recombination and mutation (like in natural genetics), producing new children, and
the process is repeated over various generations. Each individual (or candidate solution) is
assigned a fitness value (based on its objective function value) and the fitter individuals are given
a higher chance to mate and yield more “fitter” individuals. This is in line with the Darwinian
Theory of “Survival of the Fittest”.

In this way we keep “evolving” better individuals or solutions over generations, till we reach a
stopping criterion.

Genetic Algorithms are sufficiently randomized in nature, but they perform much better than
random local search (in which we just try various random solutions, keeping track of the best so
far), as they exploit historical information as well.

4.3.2 Basic Terminology in GA


Before beginning a discussion on Genetic Algorithms, it is essential to be familiar with some basic
terminology which will be used throughout this tutorial.

Population − It is a subset of all the possible (encoded) solutions to the given problem. The
population for a GA is analogous to the population for human beings except that instead of human
beings, we have Candidate Solutions representing human beings.

Figure 4.3 Representation of Chromosome, Gene and Allele

22
Brain Tumor Detection

Chromosomes − A chromosome is one such solution to the given problem.

Gene − A gene is one element position of a chromosome.

Allele − It is the value a gene takes for a particular chromosome.

Genotype − Genotype is the population in the computation space. In the computation space, the
solutions are represented in a way which can be easily understood and manipulated using a
computing system.

Phenotype − Phenotype is the population in the actual real world solution space in which solutions
are represented in a way they are represented in real world situations.

Decoding and Encoding − For simple problems, the phenotype and genotype spaces are the
same. However, in most of the cases, the phenotype and genotype spaces are different. Decoding
is a process of transforming a solution from the genotype to the phenotype space, while encoding
is a process of transforming from the phenotype to genotype space. Decoding should be fast as it
is carried out repeatedly in a GA during the fitness value calculation.

For example, consider the 0/1 Knapsack Problem. The Phenotype space consists of solutions
which just contain the item numbers of the items to be picked.

However, in the genotype space it can be represented as a binary string of length n (where n is the
number of items). A 0 at position x represents that xth item is picked while a 1 represents the
reverse. This is a case where genotype and phenotype spaces are different.

Figure 4.4 Flow of Phenotype and Genotype Space

23
Brain Tumor Detection

Fitness Function − A fitness function simply defined is a function which takes the solution as
input and produces the suitability of the solution as the output. In some cases, the fitness function
and the objective function may be the same, while in others it might be different based on the
problem.

Genetic Operators −These alter the genetic composition of the offspring. These include
crossover, mutation, selection, etc.

4.3.3 Basic Structure


The basic structure of a GA is as follows

We start with an initial population (which may be generated at random or seeded by other
heuristics), select parents from this population for mating. Apply crossover and mutation operators
on the parents to generate new off-springs. And finally these offspring’s replace the existing
individuals in the population and the process repeats. In this way genetic algorithms actually try
to mimic the human evolution to some extent. Each of the following steps are covered as a separate
chapter later in this tutorial.

Figure 4.5 Flowchart of GA algorithm

24
Brain Tumor Detection

A generalized pseudo-code for a GA is explained in the following program

initialize population

find fitness of population

while (termination criteria is reached) do

parent selection

crossover with probability pc

mutation with probability pm

decode and fitness calculation

survivor selection

find best

return best

4.3.4 Population Initialization and Population Models in GA


Population is a subset of solutions in the current generation. It can also be defined as a set of
chromosomes. There are several things to be kept in mind when dealing with GA population −

The diversity of the population should be maintained otherwise it might lead to premature
convergence.

The population size should not be kept very large as it can cause a GA to slow down, while
a smaller population might not be enough for a good mating pool. Therefore, an optimal
population size needs to be decided by trial and error.

The population is usually defined as a two dimensional array of – size population, size x,
chromosome size.

Population Initialization
There are two primary methods to initialize a population in a GA. They are

Random Initialization − Populate the initial population with completely random solutions.

25
Brain Tumor Detection

Heuristic initialization − Populate the initial population using a known heuristic for the
problem.

It has been observed that the entire population should not be initialized using a heuristic, as it can
result in the population having similar solutions and very little diversity. It has been
experimentally observed that the random solutions are the ones to drive the population to
optimality. Therefore, with heuristic initialization, we just seed the population with a couple of
good solutions, filling up the rest with random solutions rather than filling the entire population
with heuristic based solutions.

It has also been observed that heuristic initialization in some cases, only effects the initial fitness
of the population, but in the end, it is the diversity of the solutions which lead to optimality.

Population Models
There are two population models widely in use

Steady State
In steady state GA, we generate one or two off-springs in each iteration and they replace one or
two individuals from the population. A steady state GA is also known as Incremental GA.

Generational
In a generational model, we generate ‘n’ off-springs, where n is the population size, and the entire
population is replaced by the new one at the end of the iteration.

4.3.5 Fitness Function Properties


The fitness function simply defined is a function which takes a candidate solution to the problem
as input and produces as output how “fit” our how “good” the solution is with respect to the
problem in consideration.

Calculation of fitness value is done repeatedly in a GA and therefore it should be sufficiently fast.
A slow computation of the fitness value can adversely affect a GA and make it exceptionally slow.

In most cases the fitness function and the objective function are the same as the objective is to
either maximize or minimize the given objective function. However, for more complex problems

26
Brain Tumor Detection

with multiple objectives and constraints, an Algorithm Designer might choose to have a different
fitness function.

A fitness function should possess the following characteristics. The fitness


• function should be sufficiently fast to compute.
• It must quantitatively measure how fit a given solution is or how fit individuals can be
produced from the given solution.

In some cases, calculating the fitness function directly might not be possible due to the inherent
complexities of the problem at hand. In such cases, we do fitness approximation to suit our needs.

The following image shows the fitness calculation for a solution of the 0/1 Knapsack. It is a simple
fitness function which just sums the profit values of the items being picked (which have a 1),
scanning the elements from left to right till the knapsack is full.

4.3.6 Types of Parent Selection


Parent Selection is the process of selecting parents which mate and recombine to create off-springs
for the next generation. Parent selection is very crucial to the convergence rate of the GA as good
parents drive individuals to a better and fitter solutions.

However, care should be taken to prevent one extremely fit solution from taking over the entire
population in a few generations, as this leads to the solutions being close to one another in the
solution space thereby leading to a loss of diversity. Maintaining good diversity in the population
is extremely crucial for the success of a GA. This taking up of the entire population by one
extremely fit solution is known as premature convergence and is an undesirable condition in a
GA.

Fitness Proportionate Selection


Fitness Proportionate Selection is one of the most popular ways of parent selection. In this every
individual can become a parent with a probability which is proportional to its fitness. Therefore,
fitter individuals have a higher chance of mating and propagating their features to the next
generation. Therefore, such a selection strategy applies a selection pressure to the more fit
individuals in the population, evolving better individuals over time.

27
Brain Tumor Detection

Consider a circular wheel. The wheel is divided into n pies, where n is the number of individuals
in the population. Each individual gets a portion of the circle which is proportional to its fitness
value.

Two implementations of fitness proportionate selection are possible

Roulette Wheel Selection


In a roulette wheel selection, the circular wheel is divided as described before. A fixed point is
chosen on the wheel circumference as shown and the wheel is rotated. The region of the wheel
which comes in front of the fixed point is chosen as the parent. For the second parent, the same
process is repeated.

Figure 4.6 Roulette Wheel

It is clear that a fitter individual has a greater pie on the wheel and therefore a greater chance of
landing in front of the fixed point when the wheel is rotated. Therefore, the probability of choosing
an individual depends directly on its fitness.

Implementation wise, we use the following steps


• Calculate S = the sum of a finesses.
• Generate a random number between 0 and S.
• Starting from the top of the population, keep adding the finesses to the partial sum P, till
P<S.

28
Brain Tumor Detection

• The individual for which P exceeds S is the chosen individual.

Stochastic Universal Sampling (SUS)


Stochastic Universal Sampling is quite similar to Roulette wheel selection, however instead of
having just one fixed point, we have multiple fixed points as shown in the following image.
Therefore, all the parents are chosen in just one spin of the wheel. Also, such a setup encourages
the highly fit individuals to be chosen at least once.

Figure 4.7 Modified Roulette Wheel

It is to be noted that fitness proportionate selection methods don’t work for cases where the fitness
can take a negative value.

Tournament Selection
In K-Way tournament selection, we select K individuals from the population at random and select
the best out of these to become a parent. The same process is repeated for selecting the next parent.
Tournament Selection is also extremely popular in literature as it can even work with negative
fitness values.

29
Brain Tumor Detection

Figure 4.8 Tournament selection

Rank Selection
Rank Selection also works with negative fitness values and is mostly used when the individuals
in the population have very close fitness values (this happens usually at the end of the run). This
leads to each individual having an almost equal share of the pie (like in case of fitness
proportionate selection) as shown in the following image and hence each individual no matter how
fit relative to each other has an approximately same probability of getting selected as a parent.
This in turn leads to a loss in the selection pressure towards fitter individuals, making the GA to
make poor parent selections in such situations.

Figure 4.9 Rank based selection using Roulette Wheel

30
Brain Tumor Detection

In this, we remove the concept of a fitness value while selecting a parent. However, every
individual in the population is ranked according to their fitness. The selection of the parents
depends on the rank of each individual and not the fitness. The higher ranked individuals are
preferred more than the lower ranked ones.

Fitness
Chromosome Rank
Value
A 8.1 1

B 8.0 4

C 8.05 2

D 7.95 6

E 8.02 3

F 7.99 5

Table 4.1 Fitness value of chromosome

Random Selection
In this strategy we randomly select parents from the existing population. There is no selection
pressure towards fitter individuals and therefore this strategy is usually avoided.

4.3.7 Crossover
In this chapter, we will discuss about what a Crossover Operator is along with its other modules,
their uses and benefits.

Introduction to Crossover
The crossover operator is analogous to reproduction and biological crossover. In this more than
one parent is selected and one or more off-springs are produced using the genetic material of the
parents. Crossover is usually applied in a GA with a high probability – pc .

31
Brain Tumor Detection

Crossover Operators
In this section we will discuss some of the most popularly used crossover operators. It is to be
noted that these crossover operators are very generic and the GA Designer might choose to
implement a problem-specific crossover operator as well.

One Point Crossover:


In this one-point crossover, a random crossover point is selected and the tails of its two parents
are swapped to get new off-springs.

Figure 4.10 One-point crossover

Multi Point Crossover:


Multi point crossover is a generalization of the one-point crossover wherein alternating segments
are swapped to get new off-springs.

Figure 4.11 Multi point crossover

Uniform Crossover:
In a uniform crossover, we don’t divide the chromosome into segments, rather we treat each gene
separately. In this, we essentially flip a coin for each chromosome to decide whether or not it’ll
be included in the off-spring. We can also bias the coin to one parent, to have more genetic material
in the child from that parent.

32
Brain Tumor Detection

Figure 4.12 Uniform crossover

Whole Arithmetic Recombination:


This is commonly used for integer representations and works by taking the weighted average of
the two parents by using the following formulae

• Child1 = α.x + (1-α).y Eq 4.1


• Child2 = α.x + (1-α).y Eq 4.2
Obviously, if α = 0.5, then both the children will be identical as shown in the following image.

Figure 4.12 Whole Arithmetic crossover

Davis’ Order Crossover (OX1):


OX1 is used for permutation based crossovers with the intention of transmitting information about
relative ordering to the off-springs. It works as follows −

• Create two random crossover points in the parent and copy the segment between them from
the first parent to the first offspring.
• Now, starting from the second crossover point in the second parent, copy the remaining
unused numbers from the second parent to the first child, wrapping around the list.
• Repeat for the second child with the parent’s role reversed
There exist a lot of other crossovers like Partially Mapped Crossover (PMX), Order based
crossover (OX2), Shuffle Crossover, Ring Crossover, etc.

33
Brain Tumor Detection

Figure 4.13 Davis’ Order crossover

4.3.8 Mutation
Introduction to Mutation
In simple terms, mutation may be defined as a small random tweak in the chromosome, to get a
new solution. It is used to maintain and introduce diversity in the genetic population and is usually
applied with a low probability (Pm). If the probability is very high, the GA gets reduced to a
random search.

Mutation is the part of the GA which is related to the “exploration” of the search space. It has been
observed that mutation is essential to the convergence of the GA while crossover is not.

Mutation Operators
In this section, we describe some of the most commonly used mutation operators. Like the
crossover operators, this is not an exhaustive list and the GA designer might find a combination
of these approaches or a problem-specific mutation operator more useful.

Bit Flip Mutation:


In this bit flip mutation, we select one or more random bits and flip them. This is used for binary
encoded GAs.

Figure 4.14 Bit Flip Mutation

Random Resetting:
Random Resetting is an extension of the bit flip for the integer representation. In this, a random
value from the set of permissible values is assigned to a randomly chosen gene.

34
Brain Tumor Detection

Swap Mutation:
In swap mutation, we select two positions on the chromosome at random, and interchange the
values. This is common in permutation-based encodings.

Figure 4.15 Swap Mutation

Scramble Mutation:
Scramble mutation is also popular with permutation representations. In this, from the entire
chromosome, a subset of genes is chosen, and their values are scrambled or shuffled randomly.

Figure 4.16 Scramble Mutation

Inversion Mutation:
In inversion mutation, we select a subset of genes like in scramble mutation, but instead of
shuffling the subset, we merely invert the entire string in the subset.

Figure 4.17 Inversion Mutation

4.3.9 Survivor Selection


The Survivor Selection Policy determines which individuals are to be kicked out and which are to
be kept in the next generation. It is crucial as it should ensure that the fitter individuals are not
kicked out of the population, while at the same time diversity should be maintained in the
population.

Some GAs employ Elitism. In simple terms, it means the current fittest member of the population
is always propagated to the next generation. Therefore, under no circumstance can the fittest
member of the current population be replaced.

The easiest policy is to kick random members out of the population, but such an approach
frequently has convergence issues, therefore the following strategies are widely used.

35
Brain Tumor Detection

Age Based Selection


In Age-Based Selection, we don’t have a notion of a fitness. It is based on the premise that each
individual is allowed in the population for a finite generation where it is allowed to reproduce,
after that, it is kicked out of the population no matter how good its fitness is.

For instance, in the following example, the age is the number of generations for which the
individual has been in the population. The oldest members of the population i.e. P4 and P7 are
kicked out of the population and the ages of the rest of the members are incremented by one.

Figure 4.18 New population generation by age-based selection

Fitness Based Selection


In this fitness based selection, the children tend to replace the least fit individuals in the population.
The selection of the least fit individuals may be done using a variation of any of the selection
policies described before – tournament selection, fitness proportionate selection, etc.

For example, in the following image, the children replace the least fit individuals P1 and P10 of
the population. It is to be noted that since P1 and P9 have the same fitness value, the decision to
remove which individual from the population is arbitrary.

36
Brain Tumor Detection

Figure 4.19 New population generation by fitness-based selection

4.3.10 Termination Condition


The termination condition of a Genetic Algorithm is important in determining when a GA run will
end. It has been observed that initially, the GA progresses very fast with better solutions coming
in every few iterations, but this tends to saturate in the later stages where the improvements are
very small. We usually want a termination condition such that our solution is close to the optimal,
at the end of the run.

Usually, we keep one of the following termination conditions −

When there has been no improvement in the population for X iterations.


When we reach an absolute number of generations.
When the objective function value has reached a certain pre-defined value.

For example, in a genetic algorithm we keep a counter which keeps track of the generations for
which there has been no improvement in the population. Initially, we set this counter to zero. Each
time we don’t generate off-springs which are better than the individuals in the population, we
increment the counter.

However, if the fitness any of the off-springs is better, then we reset the counter to zero. The
algorithm terminates when the counter reaches a predetermined value.

37
Brain Tumor Detection

Like other parameters of a GA, the termination condition is also highly problem specific and the
GA designer should try out various options to see what suits his particular problem the best.

4.3.11 Merits and Demerits of GA Algorithm

Advantages of GAs
GAs have various advantages which have made them immensely popular. These include
• Does not require any derivative information (which may not be available for many real-
world problems).
• Is faster and more efficient as compared to the traditional methods.
• Has very good parallel capabilities.
• Optimizes both continuous and discrete functions and also multi-objective problems.
• Provides a list of “good” solutions and not just a single solution.
• Always gets an answer to the problem, which gets better over the time.
• Useful when the search space is very large and there are a large number of parameters
involved.

Limitations of GAs
Like any technique, GAs also suffer from a few limitations. These include −

• GAs are not suited for all problems, especially problems which are simple and for which
derivative information is available.
• Fitness value is calculated repeatedly which might be computationally expensive for some
problems.
• Being stochastic, there are no guarantees on the optimality or the quality of the solution.
• If not implemented properly, the GA may not converge to the optimal solution.

4.3.12 Application Areas


Genetic Algorithms are primarily used in optimization problems of various kinds, but they are
frequently used in other application areas as well.

38
Brain Tumor Detection

In this section, we list some of the areas in which Genetic Algorithms are frequently used. These
are

• Optimization − Genetic Algorithms are most commonly used in optimization problems


wherein we have to maximize or minimize a given objective function value under a given
set of constraints. The approach to solve Optimization problems has been highlighted
throughout the tutorial.
• Economics − GAs are also used to characterize various economic models like the cobweb
model, game theory equilibrium resolution, asset pricing, etc.
• Neural Networks − GAs are also used to train neural networks, particularly recurrent
neural networks.
• Parallelization − GAs also have very good parallel capabilities, and prove to be very
effective means in solving certain problems, and also provide a good area for research.
• Image Processing − GAs are used for various digital image processing (DIP) tasks as well
like dense pixel matching.
• Vehicle routing problems − With multiple soft time windows, multiple depots and a
heterogeneous fleet.
• Scheduling applications − GAs are used to solve various scheduling problems as well,
particularly the time tabling problem.
• Machine Learning − as already discussed, genetics based machine learning (GBML) is a
niche area in machine learning.
• Robot Trajectory Generation − GAs have been used to plan the path which a robot arm
takes by moving from one point to another.
• Parametric Design of Aircraft − GAs have been used to design aircrafts by varying the
parameters and evolving better solutions.
• DNA Analysis − GAs have been used to determine the structure of DNA using
spectrometric data about the sample.
• Multimodal Optimization − GAs are obviously very good approaches for multimodal
optimization in which we have to find multiple optimum solutions.
• Traveling salesman problem and its applications − GAs have been used to solve the
TSP, which is a well-known combinatorial problem using novel crossover and packing .

39
Brain Tumor Detection

4.4 Introduction to swarm intelligence


Inspired by studies in neurosciences, cognitive psychology, social ethology and behavioral
sciences, the concept of swarm intelligence (SI) was introduced in the domain of computing and
artificial intelligence in 1989 as an innovative collective and distributed intelligent paradigm for
solving problems, mostly in the domain of optimization, without centralized control or the
provision of a global model. In this context, the starting point was the realization that many of the
limitations and drawbacks observed in the framework of artificial intelligence may be ascribed to
the assumption that intelligence be based in individual minds, neglecting the fundamental
contribution of sociality. As a consequence, the concept of swarm – inspired by the collective
behavior of social animals, such as bird, fishes, ants, bees, and termites – was introduced to
investigate multi-agent distributed systems of intelligence. A swarm is a population of
homogenous, simple agents performing rather elementary tasks and interacting locally among
themselves, and their environment, with no central control: collective behavior emerges as a
consequence of self-organization and local (and partially stochastic) interactions. Indeed, although
these agents (swarm individuals) are relatively unsophisticated with limited capabilities on their
own, the ability of achieving the final goal of problem solving is provided by their behavioral and
interaction patterns through information sharing. Accordingly, swarm-based algorithms have
recently emerged as a family of nature-inspired, population-based algorithms that are capable of
producing low cost, fast, and robust solutions to several complex problems. The concept of nature
inspired population-based algorithms is not new to chemometricians, as it covers methods, which
have been widely used for many years by the community, such as genetic algorithms or simulated
annealing. In this context, taking inspiration from various natural systems, different algorithms
have been proposed in the literature, the most widely used of which are ant colony optimization
(ACO) and particle swarm optimization (PSO), which are also representative of the two main ways
interactions among agents may be defined, indirectly and directly, respectively. Other algorithms
belonging to this group are, for instance, the bee algorithm, cuckoo search, harmony search, the
flower algorithm, the bat algorithm, and the firefly algorithm.

4.5 PSO algorithm

4.5.1PSO algorithm

As stated before, PSO simulates the behaviors of bird flocking. Suppose the following scenario:
40
Brain Tumor Detection

a group of birds are randomly searching food in an area. There is only one piece of food in the
area being searched. All the birds do not know where the food is. But they know how far the
food is in each iteration. So what's the best strategy to find the food? The effective one is to
follow the bird which is nearest to the food.

PSO learned from the scenario and used it to solve the optimization problems. In PSO, each
single solution is a "bird" in the search space. We call it "particle". All of particles have fitness
values which are evaluated by the fitness function to be optimized, and have velocities which
direct the flying of the particles. The particles fly through the problem space by following the
current optimum particles.

PSO is initialized with a group of random particles (solutions) and then searches for optima by
updating generations. In every iteration, each particle is updated by following two "best" values.
The first one is the best solution (fitness) it has achieved so far. (The fitness value is also stored.)
This value is called pbest. Another "best" value that is tracked by the particle swarm optimizer is
the best value, obtained so far by any particle in the population. This best value is a global best
and called gbest. When a particle takes part of the population as its topological neighbors, the
best value is a local best and is called lbest.

After finding the two best values, the particle updates its velocity and positions with following
equation (4.3) and (4.4).

Equations of PSO algorithm

vi (t+1) = vi(t)+ c1r1[xpi(t)−xi(t)]+ c2r2[g(t)−xi(t)] Eq(4.3)

xi(t+1) = xi(t)+vi(t+1) Eq(4.4)

vi(t) is the ith particle velocity at tth iteration

xi(t) is the ith particle position at tth iteration

c1 ,c2 are acceleration factors

r1,r2 are random numbers between 0 and 1

41
Brain Tumor Detection

g(t) is the gbest position at tth iteration

xpi(t) is the ith particle pbest position at tth iteration

4.5.2 Basic structure

Figure 4.20 Flow chart of PSO algorithm

The pseudo code PSO algorithm is as follows


For each particle
Initialize particle
END
Do
For each particle
42
Brain Tumor Detection

Calculate fitness value


If the fitness value is better than the best fitness value (pBest) in history
set current value as the new pBest
End

Choose the particle with the best fitness value of all the particles as the gBest
For each particle
Calculate particle velocity according equation (a)
Update particle position according equation (b)
End
While maximum iterations or minimum error criteria is not attained

Particles' velocities on each dimension are clamped to a maximum velocity Vmax. If the sum of
accelerations would cause the velocity on that dimension to exceed Vmax, which is a parameter
specified by the user. Then the velocity on that dimension is limited to Vmax.

4.5.3 Comparisons between Genetic Algorithm and PSO


Most of evolutionary techniques have the following procedure:
i) Random generation of an initial population
ii) Reckoning of a fitness value for each subject. It will directly depend on the distance to the
optimum.
iii) Reproduction of the population based on fitness values.
iv) If requirements are met, then stop. Otherwise go back to (ii).

From the procedure, we can learn that PSO shares many common points with GA. Both
algorithms start with a group of a randomly generated population, both have fitness values to
evaluate the population. Both update the population and search for the optimium with random
techniques. Both systems do not guarantee success.
However, PSO does not have genetic operators like crossover and mutation. Particles update
themselves with the internal velocity. They also have memory, which is important to the
algorithm.

43
Brain Tumor Detection

Compared with genetic algorithms (GAs), the information sharing mechanism in PSO is
significantly different. In GAs, chromosomes share information with each other. So the whole
population moves like a one group towards an optimal area. In PSO, only gBest (or lBest) gives
out the information to others. It is a one -way information sharing mechanism. The evolution
only looks for the best solution. Compared with GA, all the particles tend to converge to the best
solution quickly even in the local version in most cases.

4.5.4 PSO parameter control


From the above case, we can learn that there are two key steps when applying PSO to
optimization problems: the representation of the solution and the fitness function. One of the
advantages of PSO is that PSO take real numbers as particles. It is not like GA, which needs to
change to binary encoding, or special genetic operators have to be used. For example, we try to
find the solution for f(x) = x12 + x22+x32, the particle can be set as (x1, x2, x3), and fitness function
is f(x). Then we can use the standard procedure to find the optimum. The searching is a repeat
process, and the stop criteria are that the maximum iteration number is reached or the minimum
error condition is satisfied.

There are not many parameter need to be tuned in PSO. Here is a list of the parameters and their
typical values.

The number of particles: the typical range is 20 - 40. Actually for most of the problems 10
particles is large enough to get good results. For some difficult or special problems, one can try
100 or 200 particles as well.

Dimension of particles: It is determined by the problem to be optimized,

Range of particles: It is also determined by the problem to be optimized, you can specify
different ranges for different dimension of particles.

Vmax: it determines the maximum change one particle can take during one iteration. Usually we

44
Brain Tumor Detection

set the range of the particle as the Vmax for example, the particle (x1, x2, x3)
X1 belongs [-10, 10], then Vmax = 20

Learning factors: c1 and c2 usually equal to 2. However, other settings were also used in different
papers. But usually c1 equals to c2 and ranges from [0, 4]

The stop condition: the maximum number of iterations the PSO execute and the minimum error
requirement. for example, for ANN training in previous section, we can set the minimum error
requirement is one mis-classified pattern. the maximum number of iterations is set to 2000. this
stop condition depends on the problem to be optimized.

Global version vs. local version:


we introduced two versions of PSO. global and local version. global version is faster but might
converge to local optimum for some problems. local version is a little bit slower but not easy to
be trapped into local optimum. One can use global version to get quick result and use local
version to refine the search.
Another factor is inertia weight, which is introduced by Shi and Eberhart in 1998.

4.5.5 Merits and Demerits of PSO


Advantages

• Can be simple to implement


• Have few parameters to adjust
• Able to run parallel computation
• Can be robust
• Have higher probability and efficiency in finding the global optima
• Can converge fast
• Do not overlap and mutate
• Have short computational time
• Can be efficient for solving problems presenting difficulty to find accurate mathematical
models
45
Brain Tumor Detection

Disadvantages

• Can be difficult to define initial design parameters


• Cannot work out the problems of scattering
• Can converge prematurely and be trapped into a local minimum especially with complex
problems

4.6 Concept of symbiosis


Symbiosis is derived from the Greek word for ‘‘living together’’.De Bary first used the term in
1878 to describe the cohabitation behavior of unlike organisms. Today, symbiosis is used to
describe a relationship between any two distinct species. Symbiotic relationships may be either
obligate, meaning the two organ-isms depend on each other for survival, or facultative, meaning
the two organisms choose to cohabitate in a mutually beneficial but nonessential relationship.
The most common symbiotic relationships found in nature are mutualism, commensalism, and
parasitism. Mutualism denotes a symbiotic relationship between two different species in which
both benefits. Commensalism is a symbiotic relationship between two different species in which
one benefits and the other is unaffected or neutral. Parasitism is a symbiotic relationship between
two different species in which one benefits and the other is actively harmed.

Fig.4.21 illustrates a group of symbiotic organisms living together in an ecosystem. Generally


speaking, organisms develop symbiotic relationships as a strategy to adapt to changes in their
environment. Symbiotic relationships may also help organisms increase fitness and survival
advantage over the long-term. Therefore, it is reasonable to conclude that symbiosis has built and
continues to shape and sustain all modern ecosystems.

46
Brain Tumor Detection

Figure 4.21 Symbosis relationships in Nature

4.7 Symbiotic Organisms Search (SOS)

4.7.1 Introduction
SOS is an evolutionary searching method developed by Cheng and Prayogo in 2014. SOS is an
optimization technique which has been inspired from symbiotic organisms that use to survive in the
ecosystem. The proposed SOS algorithm simulates symbiotic interactive behavior among the paired
organism relationship in the ecosystem and tries to seek for fitness organism. In SOS, the individuals in
the population are named as organism and each organism represent a point in the search space, hence
seeking the possible optimal global solution to the problem is promised. A fitness for each organism shows
the degree of adaption to the requested goal. SOS is designed for continuous search space. There is a
main advantage of the SOS algorithm over other nature inspired algorithms; SOS requires no specific
algorithm parameters to be set at the beginning. Similar to other algorithms SOS has operators that
update the position of organisms in each iteration. These operators which resemble the biological
interaction model are introduced as Mutualism/Commensalism/Parasitism. They have been originated
from the most common symbiotic relationships found in nature. Mutualism which benefits both
organisms mimics the relationship between like bees and flowers. Commensalism models the relationship
between remora fish and sharks. The remora is receiving benefits and shark is unaffected (it means neither
benefits nor suffers) from the relationship. And the parasitism is seen in the anopheles mosquito relation
with humans that mosquito benefits and human is harmed and may die. In each phase, the position of
the organisms is updated if the relationship causes a better fitness value for organisms i or j.

47
Brain Tumor Detection

4.7.2 Basic Structure


Pseudo code of SOS algorithm
The basic steps of the SOS algorithm can be expressed in the following
Define objective function f(x); x=(x1, x2, x3,…,xd ) %d is dimension of the problem
Initialize an ecosystem of n organisms with random solutions
While (t<Max Generation)
for i=1: n % n is the number of organism
Find the best organism Xbest in the ecosystem
%Mutualism phase
Randomly select one organism Xj
, where Xj ≠ Xi
Determine mutual relationship vector (Mutual _ Vector) and benefit vector (BF)
Modify organisms Xi and Xj using (eq1) and (eq2)
If modified organisms give better fitness evaluation than previous, then update them
in Ecosystem
%Commensalism phase
Randomly select one organism Xj
, where Xj ≠Xi
Modify organism Xi with the help of Xj using (eq 4)
If the modified organism gives better fitness evaluation, then update it in ecosystem
%Parasitism phase
Randomly select one organism Xj, where Xj ≠Xi
Generate parasite _ Vector form organism Xi
If parasite_ vector gives better fitness value than Xj
, then replace it with
Parasite _ vector
end for
The global best solution is saved as optimal solution

48
Brain Tumor Detection

end while

Figure 4.22 Flowchart of Sos algorithm

49
Brain Tumor Detection

4.7.3 Mutualism phase


An example of mutualism, which benefits both organism participants, is the relationship between
bees and flowers. Bees fly amongst flowers, gathering nectar to turn into honey – an activity that
benefits bees. This activity also benefits flowers because bees distribute pollen in the process,
which facilitates pollination. This SOS phase mimics such mutualistic relationships. In SOS,Xi is
an organism matched to the ith member of the eco-system. Another organism Xj is then selected
randomly from the ecosystem to interact with Xi. Both organisms engage in a mutualistic
relationship with the goal of increasing mutual survival advantage in the ecosystem. New
candidate solutions for Xi and Xj are calculated based on the mutualistic symbiosis between
organism Xi and Xj, which is modeled in Equations (4.6) and (4.7).

Xinew=Xi+rand(0,1)*(Xbest – Mutual_Vector*BF1) Eq(4.5)

Xjnew=Xj+rand(0,1)*(Xbest – Mutual_Vector*BF2) Eq(4.6)

Mutual_Vector=(Xi+Xj)/2 Eq(4.7)

rand(0,1) in Eqs(1) and (2)is a vector of random numbers. The role of BF1and BF2is explained as
follows. In nature, some mutualism relationships might give a greater beneficial advantage for just
one organism than another organism. In other words, organism A might receive a huge benefit
when interacting with organism B. Meanwhile, organism B might only get adequate or not so
significant benefit when interacting with organism A. Here, benefit factors (BF1and BF2) are
determined randomly as either 1or 2. These factors represent level of benefit to each organisms,i.e
whether an organism partially or fully benefits from the interaction.

Eq.(3) shows a vector called ‘‘Mutual_Vector’’ that represents the relationship characteristic
between organism Xi and Xj. The part of equation, (Xbest – Mutual_Vector*BF1), is reflecting the
mutualistic effort to achieve their goal in increasing their survival advantage. According to the
Darwin’s evolution theory, ‘‘only the fittest organisms will prevail’’, all creatures are forced to
increase their degree of adaptation to their ecosystem. Some of them use symbiotic relationship
with others to increase their survival adaptation. The Xbest is needed here because Xbest is
representing the highest degree of adaptation. Therefore, we use Xbest/global solution to model the

50
Brain Tumor Detection

highest degree of adaptation as the target point for the fitness increment of both organisms. Finally,
organisms are updated only if their new fitness is better than their preinteraction fitness.

4.7.4 Commensalism phase


An example of commensalism is the relationship between remora fish and sharks. The remora
attaches itself to the shark and eats food leftovers, thus receiving a benefit. The shark is unaffected
by remora fish activities and receives minimal, if any, benefit from the relationship Similar to the
mutualism phase, an organism, Xj, is selected randomly from the ecosystem to interact with Xi. In
this circumstance, organism Xi attempts to benefit from the interaction. However, organism Xj
itself neither benefits nor suffers from the relationship. The new candidate solution of X i is
calculated according to the commensal symbiosis between organism Xi and Xj, which is modeled
in Eq (4.8). Following the rules, organism Xi is updated only if its new fitness is better than its pre-
interaction fitness.

Xinew=Xi+rand(-1,1)*(Xbest – Xj) Eq(4.8)

The part of equation, (Xbest – Xj), is reflecting as the beneficial advantage provided by Xj to help
Xi increasing its survival advantage in ecosystem to the highest degree in current organism
(represented by Xbest).

4.7.5 Parasitism phase


An example of parasitism is the plasmodium parasite, which uses its relationship with the
anopheles mosquito to pass between human hosts. While the parasite thrives and reproduces inside
the human body, its human host suffers malaria and may die as a result. In SOS, organism X i is
given a role similar to the anopheles mosquito through the creation of an artificial parasite
called‘‘Parasite_Vector’’. Parasite_Vector is created in the search space by duplicating organism
Xi, then modifying the randomly selected dimensions using a random number. Organism Xj is
selected randomly from the ecosystem and serves as a host to the parasite vector. Parasite_Vector
tries to replace Xj in the ecosystem. Both organisms are then evaluated to measure their fitness. If
Parasite_Vector has a better fitness value, it will kill organism Xj and assume its position in the
ecosystem. If the fitness value of Xj is better, Xj will have immunity from the parasite and the
Parasite_Vector will no longer be able to live in that ecosystem.

51
Brain Tumor Detection

4.7.6 Merits and Demerits of SOS Algorithm


• SOS and other population based algorithms like GA, DE, PSO, MBA, CS etc., are similar in
many characteristics, with their iterative performance on a collection of candidate solutions
to achieve the global solution.
• SOS algorithm does not procreate unlike in GA, DE, but adapts through individual
interactions.
• SOS differs with other algorithms by using three different strategies of mutualism,
commensalism and parasitism.
• The strategy of SOS which modifies candidate solution, after taking the difference between
best and average solution is called mutualism. The advantage of exploring new search space
is utilized, when the organisms are separated by a wide space. The values of the interacting
individuals are updated simultaneously.
• Commensalism in SOS utilizes the best solution as the point of reference and exploits points
nearer to it. The speed of convergence is thus enhanced.
• Parasitism is a mutation operator, unique to SOS, the trial mutation vector, competes
randomly with other excepting its parent, having the following advantages:
a) Complete solution is modified.

b) The modified dimensions represent the characteristics of local search.

c) Because of randomization, the solutions are widely spread in the solution space.

4.8 A hybrid algorithm based on genetic algorithm, particle swarm optimization

and symbiotic organisms search


The idea of combining three evolutionary algorithms GA, PSO and SOS (denoted as HPG-SOS) has been
taken from old theory, which was based on natural selection. The natural selection theory has been
argued by Charles Darwin for the first time. According to this theory, organisms which compete with each
other and unique, they have variations that help them to enhance their survival, so they have more
chances to propagate and breed more offspring. These offspring will inherit the features (experiences)
which made the parents ending well. These successful features will spread through all the population and

52
Brain Tumor Detection

population change, which it is called evolution. There is a fact underlying in this theory. If an organism has
a better genetic structure that leads to have better features, it will have better survival chances in the
ecosystem. This could lead to better interaction with other organisms gratefully in increasing survival
opportunity and transfer these experiences and features to their children. Considering this fact in HPG-
SOS, GA creates the offspring which has inherited better genetic structure from parents (best fitness and
experience’s). This helps PSO to get a better experience for each organisms and these experience helps
the SOS to catch a better survival opportunity in the symbiotic interaction. Since the main actions in the
natural selection perform successively then it needs to be run the GA, PSO and SOS algorithms
consecutively to simulate this process. In each operating cycle, the process is begun with GA algorithm
with the initial population (Lifecycle) and initial size (Lifecyclesize). Selection operator is applied to the
combination of population created by GA Mutation/Crossover operators (Lifecyclem, Lifecyclec) and
previous survived population. The selection operator selects the best population with the previous size
and Obest (global best) is also chosen from a selected population. Then GA output is the population
compound of successful parents and their offspring that inherit their parent’s experiences. Each offspring
consists of five parameters with name of velocity, position, cost, best experience (which itself consists of
two fields position and cost). Next step is the time of gaining a better experiences by PSO phase. In this
phase, if moving cause a greater position for the organism, updating best experience is applied for it,
otherwise nothing change. If the best experience for organisms is better than Obest, then Obest is also
updated. So PSO checks the area by using the velocity equation and store the best experiences for each
organism and update the global best. Since the best experience has gained for each organism, now it is
time to use it in having better symbiotic interaction (Mutualism, Commensalism, Parasitism) which causes
survival and benefit in SOS algorithm. In SOS phase, if the specific interaction causes better fitness value,
Organism position is updated by SOS interaction phases otherwise position does not change. It can be say
that only SOS and GA modify the position and PSO just updates the best experiences (personal best) and
Obest. The mutualism phase has been modified to use in some problems which are explained in following
subsection. The iteration best is Obest and the algorithm stops if the criterion is acceptable otherwise,
the next iteration starts for generating offspring and passing another cycle. Fig. 1 depicts the schematic
view of the proposed hybrid GA-PSO-SOS (HPG-SOS). As it can be seen, this method consists of 3 main
phases (GA, PSO and SOS) which are executed in consecutive form.

53
Brain Tumor Detection

Figure 4.23 HPG-SOS schematic view

4.8.1 Basic structure


The HPG-SOS pseudo algorithm is defined as follows:

HPG-SOS pseudo algorithm

1: Input: objective function f, constraints and the dimensions of the problem (D)

2: \\Initialization

3: Initial parameters Lifecyclesize (population

size), Pm, Pc , w, c1, c2 and wdamp

4: Let Lifecycle be the set of organism 1, 2, ..., Lifecyclesize

5: for each of organism do

6: Assign random real number between [varmin , varmax] to the organism position

7: Calculate fitness (cost) for assigned position

8: Set velocity = 0

9: Set calculated position and cost as best experience (Op) position and cost too.

10: end for

11: \\iterations

12: while (the stopping criterion is not met) do

54
Brain Tumor Detection

13: Apply crossover and create Lifecyclec with size of [Pc . Lifecyclesize] Eq. (14)

14: Apply mutation and create Lifecyclem with size of [Pm . Lifecyclesize] Eq. (3)

15: Combine Lifecyclec, Lifecyclem and Lifecycle and select best population

16: Check experiences for any new minimum solution and set as best organism (Obest)

17: for each of Organism i (Oi) do

18: Calculate Oinewfor Oi with PSO update operator Eqs. (4) and (5)

19: if Oinew fitter than Oi experience then

20: Update Oi experience with Oinew

21: if Oi experience better than Obest then

22: Update Obest with Oi experience

23: end if

24: end if

25: end for

26: for each of Organism j (Oj) do

27: Mutualism: Calculate Ojnew & Ornew (Or is randomly selected) Eqs. (11) and (12)

28: if Ojnew fitter than Oj then

29: Update Oj position with Ojnew

30: end if

31: if Ornew fitter than Or then

32: Update Or position with Ornew

33: end if

34: Commensalism: Calculate Ojnew Eq. (10)

35: if Ojnew fitter than Oj then

36: Update Oj position with Ojnew

37: end if

38: Parasitism: Calculate parasite-vector from Oj

39: if parasite-vector fitter than Or then

40: Update Or position with parasite-vector (mentioned in SOS algorithm)

41: end if

55
Brain Tumor Detection

42: end for

43: decrease the inertia weight (w . wdamp)

44: end while

45: \\the final stage( output the minimum value found)

Figure 4.24 Flowchart of HPG-SOS algorithm

56
Brain Tumor Detection

4.9 Image Metrics


4.9.1 Peak signal-to-noise ratio (PSNR)

Two of the error metrics used to compare the various image compression techniques are the Mean
Square Error (MSE) and the Peak Signal to Noise Ratio (PSNR). The MSE is the cumulative
squared error between the compressed and the original image, whereas PSNR is a measure of the
peak error. The mathematical formulae for the two are

𝑀
1 𝑁
MSE = 𝑀𝑁 ∑ ∑𝑥=0[I(x, y) − I′(x, y)]2
𝑦=1

PSNR = 20 * log10 (255⁄𝑠𝑞𝑟𝑡(𝑀𝑆𝐸))

where I(x,y) is the original image, I'(x,y) is the approximated version (which is actually the
decompressed image) and M,N are the dimensions of the images. A lower value for MSE means
lesser error, and as seen from the inverse relation between the MSE and PSNR, this translates to a
high value of PSNR. Logically, a higher value of PSNR is good because it means that the ratio of
Signal to Noise is higher. Here, the 'signal' is the original image, and the 'noise' is the error in
reconstruction. So, if you find a compression scheme having a lower MSE (and a high PSNR), you
can recognize that it is a better one.

57

You might also like