/brain-tumor-mri-dataset

Utilities to download and load an MRI brain tumor dataset with Python, providing 2D slices, tumor masks and tumor classes.

Primary LanguageJupyter NotebookMIT LicenseMIT

brain-tumor-mri-dataset

Utilities to:

  • download (using a few command lines) an MRI brain tumor dataset providing 2D slices, tumor masks and tumor classes.
  • load the dataset in Python.

The dataset can be used for different tasks like image classification, object detection or semantic / instance segmentation.

It was originally published here in Matlab v7.3 format.

3064 T1-weighted contrast-inhanced images with three kinds of brain tumor are provided.

dataset-overview

Download the dataset

# create a directory
mkdir brain_tumor_dataset
cd brain_tumor_dataset

# download the dataset
wget https://ndownloader.figshare.com/articles/1512427/versions/5

# unzip the dataset and delete the zip
unzip 5 && rm 5

# concatenate the multiple zipped data in a single zip
cat brainTumorDataPublic_* > brainTumorDataPublic_temp.zip
zip -FF brainTumorDataPublic_temp.zip --out data.zip

# remove the temporary files
rm brainTumorDataPublic_*

# unzip the full archive and delete it 
unzip data.zip -d data && rm data.zip

# check that "data" contains 3064 files
ls data | wc -l

Load the dataset with Python

Requirements
- numpy
- cv2
- hdf5storage
Usage

Execute the script matlab_to_numpy.py with the dataset path as parameter.

python matlab_to_numpy.py ~/brain_tumor_dataset

Optional: set the image dimension with --image-dimension or -d (default is 512).

Visualization of the dataset

Notebook to visualize:

  • the repartition of classes
  • the 2D slices with the tumor mask
  • the tumors

References

@article{Cheng2017,
author = "Jun Cheng",
title = "{brain tumor dataset}",
year = "2017",
month = "4",
url = "https://figshare.com/articles/brain_tumor_dataset/1512427",
doi = "10.6084/m9.figshare.1512427.v5"
}