Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Privacy-Preserving Brain Tumor Analysis with Federated Learning & Explainable AI

A research project exploring privacy-preserving medical image analysis using Federated Learning, Byzantine-robust aggregation, and Explainable AI (Grad-CAM) for trustworthy brain tumor detection from MRI scans.


📖 Overview

Medical imaging datasets contain highly sensitive patient information, making centralized model training difficult due to privacy regulations. Federated Learning (FL) enables multiple healthcare institutions to collaboratively train a shared model while keeping patient data local.

This repository presents a two-stage project:

  1. Brain Tumor Detection with CNN & Grad-CAM – a centralized deep learning model for MRI classification with visual explainability.
  2. Privacy-Preserving Brain Tumor Analysis – an extension of the baseline model into a federated learning framework that simulates distributed hospital training and evaluates robust aggregation methods against malicious clients.

Together, these projects demonstrate how explainable and privacy-preserving AI can be combined for trustworthy medical image analysis.


✨ Features

  • 🧠 Brain tumor detection from MRI images
  • 🏥 Federated Learning across simulated hospital clients
  • 🔒 Privacy-preserving distributed training
  • 🛡️ Byzantine-robust aggregation using Trimmed Mean
  • 📊 FedAvg vs. Trimmed Mean comparison
  • 🔥 Grad-CAM explainability for MRI interpretation
  • 📈 Performance evaluation under centralized and federated settings
  • 🤖 Built with TensorFlow/Keras

📂 Repository Structure

Privacy-Preserving-Brain-Tumor-Analysis/
│
├── Brain_Tumor_Detection.ipynb
│   ├── CNN Model
│   ├── MRI Classification
│   └── Grad-CAM Visualization
│
├── BrainTumor_Federated_Byzantine.ipynb
│   ├── Federated Learning Simulation
│   ├── FedAvg Aggregation
│   ├── Trimmed Mean Aggregation
│   ├── Byzantine Client Simulation
│   └── Performance Evaluation
│
├── images/
│   ├── gradcam_example.png
│   ├── federated_setup.png
│   └── results.png
│
├── requirements.txt
├── LICENSE
└── README.md

🚀 Project Workflow

Brain MRI Dataset
        │
        ▼
Brain_Tumor_Detection.ipynb
        │
        ├── CNN Training
        ├── Model Evaluation
        ├── MRI Classification
        └── Grad-CAM Explainability
        │
        ▼
BrainTumor_Federated_Byzantine.ipynb
        │
        ├── Simulated Hospital Clients
        ├── Local Training
        ├── FedAvg Aggregation
        ├── Trimmed Mean Aggregation
        ├── Byzantine Attack Simulation
        └── Federated Model Evaluation

🧠 Dataset

Source

  • Kaggle – Brain MRI Images for Brain Tumor Detection
Property Value
Total Images 253
Tumor Images 155
Healthy Images 98
Classes 2
Image Type Brain MRI

📚 Project 1 — Brain Tumor Detection

This notebook implements a CNN-based classifier for detecting brain tumors from MRI scans.

Model Architecture

Input (128×128×3)
        │
Conv2D (32)
        │
MaxPooling
        │
Conv2D (64)
        │
MaxPooling
        │
Flatten
        │
Dense (128)
        │
Dropout
        │
Dense (2)

Training Configuration

Parameter Value
Optimizer Adam
Loss Categorical Crossentropy
Epochs 10
Batch Size 32
Image Size 128×128
Train/Test Split 80/20

Data Augmentation

  • Random Rotation
  • Zoom
  • Width Shift
  • Height Shift
  • Horizontal Flip

🔥 Explainable AI with Grad-CAM

To improve model transparency, Grad-CAM is used to visualize which regions of an MRI most influenced the prediction.

The Grad-CAM pipeline:

  1. Extract feature maps from the final convolutional layer.
  2. Compute gradients of the predicted class.
  3. Weight feature maps using pooled gradients.
  4. Generate a heatmap.
  5. Overlay the heatmap on the original MRI.

This helps clinicians verify whether predictions are based on medically meaningful regions.

Example implementation:

with tf.GradientTape() as tape:
    conv_outputs, predictions = grad_model(img_array)
    loss = predictions[:, tf.argmax(predictions[0])]

grads = tape.gradient(loss, conv_outputs)
pooled_grads = tf.reduce_mean(grads, axis=(0,1,2))
heatmap = conv_outputs[0] @ pooled_grads[..., tf.newaxis]

🏥 Project 2 — Privacy-Preserving Federated Learning

The second notebook extends the centralized model into a federated learning framework.

Instead of pooling MRI scans into one dataset, multiple simulated hospitals collaboratively train a shared model while keeping patient data local.

Federated Learning Setup

Hospital A
      │
Hospital B
      │
Hospital C
      │
Hospital D
      │
      ▼
 Federated Server
      │
      ▼
 Global Model

Each hospital:

  • Trains the model locally
  • Never shares patient MRI images
  • Sends only model updates to the central server

🛡️ Robust Aggregation

Two aggregation strategies are evaluated.

FedAvg

Standard Federated Averaging.

Advantages

  • Simple
  • Efficient
  • Widely used

Limitations

  • Sensitive to malicious or poisoned client updates

Trimmed Mean

A Byzantine-robust aggregation algorithm that removes extreme client updates before averaging.

Advantages

  • Resistant to malicious updates
  • More stable under adversarial settings
  • Better suited for safety-critical applications

📊 Results

Centralized CNN

Metric Value
Test Accuracy ~70.6%

The relatively small dataset limits performance, providing opportunities for improvement through larger datasets or transfer learning.


Federated Learning

The federated learning experiments compare:

  • FedAvg
  • Trimmed Mean

Evaluation focuses on:

  • Classification performance
  • Privacy-preserving distributed learning
  • Robustness against malicious clients
  • Explainability using Grad-CAM

💻 Technologies Used

  • Python
  • TensorFlow / Keras
  • NumPy
  • OpenCV
  • Scikit-learn
  • Matplotlib

🚀 Future Work

Potential extensions include:

  • Differential Privacy
  • Secure Aggregation
  • Vision Transformers (ViT)
  • Flower or FedML frameworks
  • Larger medical imaging datasets (BraTS)
  • Multi-class brain tumor classification
  • Self-supervised medical vision models

📖 Acknowledgements

  • Dataset: Brain MRI Images for Brain Tumor Detection (Kaggle)
  • Grad-CAM: Selvaraju et al., Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization, ICCV 2017.

📄 License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages