brain-tumor-detection
brain-tumor-detection copied to clipboard
brain tumor detection
brain tumor detection
content on brain-tumor-detection contain:
- requirements for installation
- journal
- brain tumor detection using convolutional networks
- about the data
- data split
- neural network architecture
- training the model
- convolutional networks test result
- tensorflow and pytorch implementation on brain tumor detection
- overview with keras & torch implementation
- UNet testing
- PSPNet testing
- deeplab testing
- dataset
- data augmentation
- preprocess
- train
- result
- reference
requirements:
paper:
brain tumor and survival prediction - Arfy slowy
about the data
the datasets contain 2 folders : yes and no wich contains 253 brain MRI images. the folder yes contains 155 brain MRI images that are tumorous and the folder no contains 98 Brain MRI images that are non tumorous
data preprocessing
For every image, the following preprocessing steps were applied:
- crop the part of the image that contains only the brain (which is the most important part of the image)
- resize the image to have shape of (240, 240, 3) = (image_width, image_height, number_of_channels) beause images in the datasets come in different size. so, all images should have the same shape to feed it as an input to the neural network
- apply normalization to scale pixel value to the range 0-1
data split
the data split in the following
- 70% of the data for training
- 15% of the data for validation
- 15% of the data for testing
neural network architecture
Each input x (image) has a shape of (240, 240, 3) and is fed into the neural network. and, it goes through the following layers
- a zero padding layer with a pool size of (2, 2)
- a convolutional layer with 32 filter, with filter size of (7, 7) and stride equal to 1
- a batch normalization layer to normalize pixel values to speed up computation
- a ReLu activation layer
- a max pooling layer with
f = 4ands = 4 - a max pooling layer with
f = 4ands = 4same as before - a flatten layer in order to flatten the
3-dimensional matrixinto aone-dimensional vector - a dense (output unit) fully connected layer with one neuron with a sigmoid activation (since this is a binary classification task)
why this architecture
i applied transfer learning using ResNet and vgg-16 but these models were too complex to data size and were overfitting, of course, you may get good result applying transfer learning with these models using data augmentation, i'm using training on computer with 8 core of CPU AMD ryzen 7 4800H and 16GB memory. so, i had to take into consideration computational complexity and memory limitations
(my)specs for testing
training the model
the model was trained for 24 epochs and these are the loss and accuracy plots
convolutional networks test result
88.7% accuracy on the test set 0.88 f1 score on the test set
| Validation set | Test set | |
|---|---|---|
| Accuracy | 91% | 98% |
| F1 score | 0.91 | 0.88 |
- the code in the ipython notebooks
- the weights for all the models. the best model is named as
cnn-parameters-improvement-23-0.91.model - the model are stored as
.modelthey can be restored by:
from tensorflow.keras.models import load_model
best_model = load_model(filepath='models/cnn-parameters-improvement-23-0.91.model')
- the original data in folder named
yesandno.
overview with keras and torch implementation
with keras implementation on brain tumor detection

brain complete tumor segmentation
core predicition:

brain core tumor segmentation
brain-tumor-detection focusing on the evaluation of state-of-the-art methods for segmentation of brain tumors in multimodal magnetic resonance imaging (MRI) scans. brain-tumor-detection utilizes multi-institutional pre-operative MRI and focuses on the segementation of intrinsically heterogenerous (in appearance, shape, and histology) brain tumors, namely gliomas. Furthermore, to pinpoint the clinical relevance of this segmentation task, brain-tumor-detection also focuses on the prediction of patient overall survival, via integrative analyses of radiomic features and artificial intelligence (machine learning) algorithms.
unet test
pytorch/models/unet.py
pspnet test
pytorch/models/pspnet.py
deeplab test
pytorch/models/deeplab.py
datasets
information:
- flair = channel0 is background
- T1 = channel1 is necrotic and non-enhancing tumor
- T1c = channel2 is edema
- T2 = channel3 is enhancing tumor
data augmentation
running code
pytorch/preproces.py
pytorch/dataset.py
preprocess
on preprocess.py code for data pre-processing. using this, the original image (240 x 240 x 155 x 4) can be divided into 155 image pieces (240 x 240) of the spesific mode. also, original label (240 x 240 x 155) can be divided into 155 label pieces.
dataset
on dataset.py code for preparing dataset and dataloader for pytorch modules
train
Loss function
dice coefficient loss information here
optimizer
adam optimizer information here stochastic gradient descent here
Hyperparameter
learning rate = 1e-4
maximum number of epochs = 100
weights init : normal distribution (mean : 0, std: 0.01)
bias init : initialized as 0
train test
pytorch/train.py
pytorch/utils.py
on train.py code for training model and getting several inputs
on utils.py code for loss function, utlis function, ui functions, and etc
testing
pytorch/test.py
running code for testing MRI inputs
Result
prediction

brain complete tumor segmentation
brain core tumor segmentation