# Incremental Dilations Using CNN for Brain Tumor Classification
## 2 Materials and Methods
### Dataset  
No humans were directly involved in this study, the data is anonymous or generated synthetically from simulators. We have selected slices from various MRI scans and applied necessary preprocessing techniques to convert the images into a common JPEG format to maintain consistency throughout the dataset. The data is split into two categories namely \"Normal\" and \"Tumour\". The model is trained and tested on images curated from a number of publicly available sources. Kaggle provides an open dataset curated and maintained by [PERSON] [31] which collects MRI images in 2 folders (tumor detected--\"yes\" and \"no\"), containing a total of 253 Brain MRI images. As MRI images contain personal information and require the assistance of specialized doctors for labeling, we have also made use of simulated brain images. The Brain wave [32; 33; 34; 35] brain simulator provides a 3D simulation of the brain based on a range of user-defined parameters. The data is in 3D slices, and we can select a particular series of slices (top-down view) to add to the dataset. As these simulations are based on the anatomical model of a healthy brain, they serve as the ground truth for any analysis procedure. Another resource used is the Harvard Brain simulator [36], which provides many simulated brain MRI images that have been carefully selected and added to the dataset. The next step consists of image pre-processing. We aim to remove additional data present around the main MRI brain scan, making sure that all the images are of the same type, and the focus is only on the central part of the brain. To carry out the mentioned preprocessing, we have used a relatively common method of using the extreme points of a contour. The simple step by step approach illustrated in Figure 2, combined with a few image processing methods such as converting the image to Grayscale, Thresholding, and Opening (Erosion followed by Dilation), as mentioned below in Algorithm 1, makes sure that the brain is in focus in each image. Finally, using the extreme points as a mask, it is a fairly simple task to crop out the parts of the image that do not add any value to the classifier model. When preparing the data for training, we need to create a generalized dataset as deep learning algorithms are highly data-driven. This means that imbalanced sets and other skewed image properties in a particular class will create a bias in the model and results in improper classification. The Brain MRI dataset suffers from two main issues, firstly the size of the dataset and secondly, there is no single correct structural shape of a human brain. Each human brain is shaped uniquely and slightly different from the other. Using the Keras Image Data Generator [37], we augment the images over a set of parameters, and this adds a slight degree of randomness to the images. In terms of the entire training process, the model learns on a generalized dataset. The applied augmentation techniques include _Rescaling_ the image between a range of \([0,1]\), _Rotation_ randomly between \([-15^{\circ},+15^{\circ}]\), _Shifts_ in height and width to a maximum 10% of image dimensions, _Shear_ range of 0.1 and a _Brightness_ range between the bounds \([0.5,1.5]\). As the brain MRI images are vertically aligned, it is not feasible to use a vertical flip. Preferably a _Horizontal flip_ is used to create symmetrical data about the vertical axis. Figure 3 depicts the degree of randomness introduced by using the above mentioned image augmentation on a single sample MRI image. ```
Input Raw Image Output Cropped Image
1:for\(iteration=1,2,\ldots,N_{images}\)do
2:\(Image_{Gray}\ \leftarrow\ Grayscale(Image_{Input})\)
3:\(Image_{Binary}\gets Binary(Image_{Gray},threshold[45-255])\)
4:Opening
5:\(Image_{Binary}\gets Erosion(Image_{Binary})\)
6:\(Image_{Binary}\gets Dilation(Image_{Binary})\)
7:\(Image_{Contour}\gets Contour(Image_{Binary})\)
8:\(Image_{Mask}\gets Extremes(Image_{Contour})\)
9:\(Image_{Output}\gets Crop(Image_{Binary},Image_{Mask})\)
10:endfor
```  
**Algorithm 1** Image Pre-processing.