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.
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:
- Brain Tumor Detection with CNN & Grad-CAM – a centralized deep learning model for MRI classification with visual explainability.
- 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.
- 🧠 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
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
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
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 |
This notebook implements a CNN-based classifier for detecting brain tumors from MRI scans.
Input (128×128×3)
│
Conv2D (32)
│
MaxPooling
│
Conv2D (64)
│
MaxPooling
│
Flatten
│
Dense (128)
│
Dropout
│
Dense (2)
| Parameter | Value |
|---|---|
| Optimizer | Adam |
| Loss | Categorical Crossentropy |
| Epochs | 10 |
| Batch Size | 32 |
| Image Size | 128×128 |
| Train/Test Split | 80/20 |
- Random Rotation
- Zoom
- Width Shift
- Height Shift
- Horizontal Flip
To improve model transparency, Grad-CAM is used to visualize which regions of an MRI most influenced the prediction.
The Grad-CAM pipeline:
- Extract feature maps from the final convolutional layer.
- Compute gradients of the predicted class.
- Weight feature maps using pooled gradients.
- Generate a heatmap.
- 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]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.
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
Two aggregation strategies are evaluated.
Standard Federated Averaging.
Advantages
- Simple
- Efficient
- Widely used
Limitations
- Sensitive to malicious or poisoned client updates
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
| Metric | Value |
|---|---|
| Test Accuracy | ~70.6% |
The relatively small dataset limits performance, providing opportunities for improvement through larger datasets or transfer 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
- Python
- TensorFlow / Keras
- NumPy
- OpenCV
- Scikit-learn
- Matplotlib
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
- 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.
This project is licensed under the MIT License.