Deep-Neural Network for Brain Tumor Classification in Pediatric Patients
DIPG
- Diffuse Intrinsic Pontine GliomaEP
- EpendymomasMB
- MedulloblastomaPILO
- PilocyticNormal
- Healthy Brain
Package Name | Version |
---|---|
python |
3.6 |
tensorflow |
1.12 |
keras |
2.1.5 |
keras-applications |
1.0.7 |
keras-preprocessing |
1.0.9 |
matplotlib |
3.0.2 |
imageio |
2.4.1 |
Pillow * |
5.4.1 |
scikit-learn |
0.20.2 |
scikit-image |
0.14.1 |
numpy |
1.15.4 |
pandas |
0.24.1 |
pydicom* |
1.2.2 |
nibabel |
2.3.3 |
progressbar |
2.5 |
*
- See note below regarding OpenJPEG prerequisite
To install the above packages -
- if
python
is symlink topython 3.x
-->pip install --user <Package Name>
- if
python
is symlink topython 2.x
-->pip3 install --user <Package Name>
Transfer Learning Model | Model Key |
---|---|
ResNet 50 | resnet |
Inception V3 | inception |
InceptionResNet V2 | inceptionresnet |
Xception | xception |
DenseNet 121 | densenet |
VGG 19 | vgg |
-
Install the above packages and dependencies.
-
git clone https://github.com/aman-chauhan/brain-tumor-classification.git
-
Set up
source
directory as shown below in Folder section. -
python preprocessing.py
--> generates thedata
directory, which contains the cleaned, resized and partitioned data to train and evaluate the models. Also generates themeta
directory, which contains the list of files required for reading the a particular partition. -
Train the AutoEncoders - There are 6 types of models, each using specific kinds of Transfer Learning layers. Refer Model Key from the Transfer Learning Layers section. The models are configured with EarlyStopping and can continue training over multiple runs. Train all these models. The command to train the models is -->
python train.py autoencoder <Model Key> <Batch Size>
. Examples -python train.py autoencoder vgg 48
python train.py autoencoder densenet 48
-
Train the Classifiers - Train the Classifiers associated with each type of Model (Model Key). The code also tunes the dropout hyper-parameter for the Fully Connected Layers between 0.1 and 0.5 inclusive. The command to train the models is -->
python train.py classifier <Model Key> <Batch Size>
. Examples -python train.py classifier vgg 48
python train.py classifier densenet 48
-
python vectorization.py
- Generate the vectors required for training the Paraclassifiers. Also identifies and stores the best hyperparameters for each type of Model. This will create theparaclassifier
subdirectory insidedata
directory andpara_*.csv
insidemeta
directory. -
Train the Paraclassifiers - Train the Classifiers associated with each type of Model (Model Key). This code can also train an ensemble model using the average vectors from all the models. The command to train the models is -->
python train.py paraclassifier <Model Key> <Batch Size>
. Examples -python train.py paraclassifier vgg 32
python train.py paraclassifier densenet 32
python train.py paraclassifier ensemble 32
-
Evaluate the Classifiers - Evaluate the accuracy of the classifiers on test dataset.
python test.py classifier
--> This generates theclf_results.csv
table inlogs
directory. -
Evaluate the Paraclassifiers - Evaluate the accuracy of the paraclassifiers on test dataset.
python test.py paraclassifier
--> This generates thepara_results.csv
table inlogs
directory. This is the final accuracy of our models.
- Switch to root of repository.
jupyter notebook
--> Start the Jupyter Notebook environment.- Open
Tumor Classifier.ipynb
. - Put in the path to your MRI scan in the path variable.
- Execute all the cells in the Notebook.
Tumor Classifier.ipynb
- Notebook for using our model to predict class of tumor, ie Inference using our Model.Exploring Data.ipynb
- Notebook for visualizing the different types of MRI scans present in the Data set.Visualization - AutoEncoder.ipynb
- Notebook for visualizing the results from training the AutoEncoder.Visualization - Classifier.ipynb
- Notebook for visualizing the results from training the Classifier.Visualization - Paraclassifier.ipynb
- Notebook for visualizing the results from training the Paraclassifier.
preprocessing.py
- Code to clean data and preprocess.vectorization.py
- Code to generate vectors for each plane in brain.generator.py
- Code for Generator classes to train the models.train.py
- Code for training the Models using training and validation datasets.test.py
- Code for evaluating the Models against the test dataset, and generating the overall statistics.
-
source
- Folder for storing the raw DICOM/NII imagesDIPG
Seattle
Stanford
PILO
Stanford
MB
Seattle
Stanford
EP
Seattle
Stanford
katie_annotated_metadata
- metadata for the Tumor datasetNormal
- Healthy Children Brain Scansflipped_clinical_NormalPedBrainAge_StanfordCohort.csv
- metadata for healthy brainsTask01_Brain Tumor
- From the BRATS 2018 dataset. Download from hereimagesTr
- Training imagesimagesTs
- Testing imageslabelTr
- Labels for Training images (For segmentation)(ignored)dataset.json
- metadata for this dataset
-
data
- Folder to store cleaned data (generated bypreprocessing.py
)autoencode
- Folder for cleaned files for AutoEncodertrain
- Folder for cleaned train filesvalid
- Folder for cleaned validation files
classifier
- Folder for cleaned files for Classifiertrain
- Folder for cleaned train filesvalid
- Folder for cleaned validation filestest
- Folder for cleaned test files
paraclassifier
- Folder for cleaned files for Paraclassifiertrain
- Folder for cleaned train filesvalid
- Folder for cleaned validation filestest
- Folder for cleaned test files
-
docs
- Folder for storing static content and documentsautoencoder
- Images and Graphs related to Autoencoder Visualizationsclassifier
- Images and Graphs related to Classifier Visualizationsparaclassifier
- Images and Graphs related to Paraclassifier Visualizationsreference
- Reference implementation plots of the Model in Object Oriented Fashiondensenet
- Reference implementation plots of the Model in with DenseNet 121inception
- Reference implementation plots of the Model in with Inception V3inceptionresnet
- Reference implementation plots of the Model in with InceptionResNet V2resnet
- Reference implementation plots of the Model in with ResNet 50vgg
- Reference implementation plots of the Model in with VGG 19xception
- Reference implementation plots of the Model in with Xception
-
weights
- Folder to store all model weights -
models
- Folder to store all model codes -
logs
- Folder to store all logs -
meta
- Folder to store all the training metadata
Pillow needs to be installed with support for JPEG2000 lossless compression, which is the compression used in some the MRI DICOM scans. In order to do that, install OpenJPEG before installing Pillow. The steps to install OpenJPEG are -
- Install cmake to build OpenJPEG --> see this for local user installation and avoiding sudo in step 8 and 9
git clone https://github.com/uclouvain/openjpeg.git
cd openjpeg
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install
sudo make clean
Restart the session. Now install Pillow, followed by pydicom