AI / Machine Learning
January 29, 2024

Inside the Brain: A Simplified Guide for Crafting an Alzheimer’s Detector from MRIs Using Machine Learning

⚠️ IMPORTANT: This is a non-technical and simplified blog. If you want a more complete and more technical step by step for building this model using python please refer to this blog. ⚠️

Introduction: The Quest to Understand Alzheimer’s

Welcome to our journey into the fascinating world of medical imaging and its role in detecting Alzheimer’s disease. Alzheimer’s is a condition that affects millions worldwide, and early detection is crucial for better care and treatment. We’ll explore how MRI scans, a common tool in hospitals, can be used to identify signs of Alzheimer’s and other related conditions. We’ll walk through the journey of preparing MRI images for analysis and building a model that can classify these images into three categories: Alzheimer’s Disease (AD), Mild Cognitive Impairment (MCI), and Control (CN).

What is Alzheimer’s Disease?

Alzheimer’s disease is a progressive brain disorder that gradually destroys memory and thinking skills. It’s crucial to detect it early, which is where MRI scans come in.


  1. The Data
  2. Preprocessing
  3. Building Classifier
  4. Streamlit Demo
  5. Conclusion

1. The Data: Understanding MRI Scans

What is an MRI Scan?

MRI, or Magnetic Resonance Imaging, is a technique used in hospitals to get detailed images of the inside of your body, including the brain. These images are crucial for doctors to understand what happens in the brain of someone who might have Alzheimer’s.

Where Do We Get the Data?

We use data from a project called the Alzheimer’s Disease Neuroimaging Initiative (ADNI). This project collects MRI scans’ details from people across the globe to help researchers understand Alzheimer’s better.

2. Preprocessing: Cleaning Up the Data

Why Preprocess?

Imagine you have a photo, but it’s a bit blurry and has things you don’t need. Preprocessing is like cleaning up that photo. We do this to make sure the MRI scans are clear and focused only on the brain, which is what we need to study Alzheimer’s.

Steps We Take

  1. Organizing the Scans: Sorting the MRI scans into categories— control, mild cognitive impairment, and Alzheimer’s.
  2. Affine Registration: Aligning the images so they match a standard format.
  3. Skull Stripping: Removing non-brain elements, such as the skull or the eyes, to focus solely on brain structures.
  4. Bias Correction: Improving the image quality by rectifying biases, to make sure we see everything clearly.

Final result

After all the preprocessing steps are done this is the difference between the original and the processed file:

Unprocessed MRI
Processed MRI

3. Building the Classifier: Teaching the Computer

What is a Classifier?

A classifier is like a highly specialized detective. It looks at the MRI scans and tries to find patterns that tell us whether the person is healthy, has mild cognitive impairment, or has Alzheimer’s.

How We Build It

We use something called a DenseNet 121 model. This sophisticated tool specializes in analyzing 3D images, mimicking the human brain’s ability to recognize and understand visual patterns. Through extensive exposure to a multitude of MRI images, this model learns to distinguish subtle nuances characteristic of each category: Control, Mild Cognitive Impairment, and Alzheimer’s. It’s a fancy way of saying that we use a very smart algorithm that can look at 3D images and understand them :)

Training the Model

We train this classifier with lots of MRI images which we already knew the class it belongs: Control, Mild Cognitive Impairment and Alzheimer’s. The more it sees, the better it gets at identifying the patterns of each category.

4. See It in Action!

You can see how this all works and try it yourself in the following link. You can look at MRI scans, see how we process them, and then see how the classifier makes its predictions.

5. Conclusion: The Bigger Picture

In this journey, we’ve seen how technology can help in the fight against Alzheimer’s. By using MRI scans and smart algorithms, we can detect Alzheimer’s early, which is crucial for treatment. This is just the beginning, though. As technology gets better, we’ll get even better at understanding and fighting this disease.