content on brain-tumor-detection contain:
- requirements for installation
- journal
- brain tumor detection using convolutional networks
- tensorflow and pytorch implementation on brain tumor detection
- reference
brain tumor and survival prediction - Arfy slowy
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
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
the data split in the following
- 70% of the data for training
- 15% of the data for validation
- 15% of the data for testing
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 = 4
ands = 4
- a max pooling layer with
f = 4
ands = 4
same as before - a flatten layer in order to flatten the
3-dimensional matrix
into 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
the model was trained for 24 epochs and these are the loss and accuracy plots
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
.model
they 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
yes
andno
.
brain complete 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.
pytorch/models/unet.py
pytorch/models/pspnet.py
pytorch/models/deeplab.py
information:
- flair = channel0 is background
- T1 = channel1 is necrotic and non-enhancing tumor
- T1c = channel2 is edema
- T2 = channel3 is enhancing tumor
running code
pytorch/preproces.py
pytorch/dataset.py
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.
on dataset.py
code for preparing dataset and dataloader for pytorch modules
dice coefficient loss information here
adam optimizer information here stochastic gradient descent here
learning rate = 1e-4
maximum number of epochs = 100
weights init : normal distribution (mean : 0, std: 0.01)
bias init : initialized as 0
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
brain complete tumor segmentation
brain core tumor segmentation