Train a brain tumor segmentation deep learning model for under $10

Diya S
4 min readJul 26, 2023

--

Original MRI Image credit: TCIA

Medical image segmentation refers to the demarcation of specific regions in a patient’s scan (such as a CT or MRI scan) to show the extent and intensity of the disease, so accurate diagnosis and treatment can be prescribed. Expert radiologists have typically done this manually, which is quite intensive and potentially subject to observer bias. The use of Deep Neural networks for medical image segmentation has come a long way over the last decade, with significant increases in sophistication and accuracy.

When I started on an internship project to segment Meningioma brain tumors using DNNs, I was very new to this area and went through a long learning process. Here, I am sharing my journey in a series of posts that walks you through the entire project on a similar, publicly available dataset, step by step.

In this series, we will train a DNN using the nnU-Net framework to perform automated segmentation of de-identified Glioblastoma brain tumor MRI scans. Glioblastoma is an aggressive, malignant brain tumor with a very low (<6%) survival rate. Using deep learning to accurately segment these tumors may reduce observer bias, augment expert segmentation, and enable better treatment planning.

Given that most students and data science enthusiasts who want to learn about this subject may not have access to a large compute cluster in a university lab, I wanted to run this project on Google Colab/Drive so it is easily accessible to all. The only cost for the project was the upgrade to Google Colab Pro during the model training and inference stages, which cost me $9.99, and I still had some compute units left over after the project was complete.

Please keep in mind that this is purely for knowledge sharing, and the model is trained on a very small cohort of images. It is not applicable for clinical diagnosis. However, it gives a good flavor of the end-to-end process and I hope you follow along.

All the code for this project is available on my Github page here.

Part 1 — Getting the Data: We start of with how to navigate the TCIA website and download the de-identified Glioblastoma MRI scans, along with the associated patients’ clinical dataset. You will learn which MRI format to download. I also provide a description of the folder structure and what subset of the data we will be using for our project.

Part 2 — Exploratory Data Analysis: We take a deeper look at the de-identified patients’ clinical data and run some basic exploratory analysis to understand the data profiles and distribution. I also describe the fields in the dataset.

Part 3 — Preparing your Training Environment: Now that we understand the data better, let’s set up our Google Colab and Google Drive environment to begin writing the code. To keep costs down, we will use the free version of Colab until we begin the actual model training.

Part 4 — Training and Test Data Setup: Here, we split the dataset randomly into training and test cohorts (80/20 proportion) and use Python code to move the MRI scans to the appropriate folders for preprocessing, training and inference.

Part 5 — Data Preprocessing: Before training the model, we need to preprocess the MRI scans to normalize shape, intensity and other characteristics. We do that here using the nnUNet package. We also write some code to process the ground truth segmentation labels for use during training.

Part 6 — Neural Network Model Training: Finally, all the setup and configuration is complete, and we can begin training the DNN. This stage will require more compute resources than what’s available in the free Colab version. I signed up for Google’s Colab Pro “Pay as you go” plan that gave me 100 compute units for $9.99, which was sufficient for this project.

Part 7 — Inference: Once the DNN is trained, we use the trained model to make predictions on demarcating the tumor region segments in each of the MRI scans in the test cohort. We also learn how to evaluate model performance.

I hope you enjoy the series and learn how to use deep learning for medical image segmentation. Thank you.

A Message from InsiderFinance

Thanks for being a part of our community! Before you go:

--

--

Diya S
Diya S

Written by Diya S

I am a high school student on a journey to understand how disruptive technologies can transform and democratize healthcare in the coming decade D.S

No responses yet