Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

🧠 Brain Tumor MRI RAG Database (Part 2)

A specialized Retrieval-Augmented Generation (RAG) database for brain tumor MRI image analysis, built using DenseNet-121 deep learning model and FAISS vector search.

Developed by: Gaston Software Solutions LLP
Location: Ntinda, Kampala, Uganda
Contact: info@gss-tec.com
Website: www.gss-tec.com


πŸ“Š Database Overview

Statistics

  • Total Images: 7,200 brain MRI scans
  • Embedding Dimension: 1,024 features per image
  • Model: DenseNet-121 (pretrained on ImageNet)
  • Vector Index: FAISS (GPU-accelerated)
  • Dataset: Brain Tumor MRI Dataset

Dataset Distribution

Tumor Type Images Percentage Description
Glioma 1,800 25% Malignant brain tumor from glial cells
Pituitary 1,800 25% Tumor in the pituitary gland
No Tumor 1,800 25% Healthy brain MRI scans
Meningioma 1,800 25% Tumor in the meninges
Total 7,200 100% Balanced brain tumor dataset

πŸ”¬ Brain Tumor Classes

1. Glioma (1,800 images)

  • Type: Malignant brain tumor
  • Origin: Glial cells (supporting cells of the brain)
  • Characteristics: Most common primary brain tumor in adults
  • Severity: Can be aggressive and fast-growing

2. Pituitary Tumor (1,800 images)

  • Type: Usually benign tumor
  • Location: Pituitary gland at the base of the brain
  • Characteristics: Affects hormone production
  • Severity: Generally treatable with surgery or medication

3. No Tumor (1,800 images)

  • Type: Healthy brain scans
  • Purpose: Baseline for comparison
  • Characteristics: Normal brain structure
  • Use: Control group for classification

4. Meningioma (1,800 images)

  • Type: Usually benign tumor
  • Location: Meninges (membranes surrounding brain and spinal cord)
  • Characteristics: Slow-growing, most common benign brain tumor
  • Severity: Often treatable with surgery

πŸ“ Database Files

The RAG database consists of three essential files:

1. embeddings.npy (~28 MB)

  • Format: NumPy array
  • Shape: (7200, 1024)
  • Content: DenseNet-121 feature vectors for all MRI images
  • Purpose: Dense vector representations for similarity search

2. metadata.json (~1.8 MB)

  • Format: JSON
  • Content: Image metadata including:
    • image_path: Original file path
    • class: Tumor classification (glioma, pituitary, notumor, meningioma)
    • dataset: Source dataset name (brain_tumor)
    • filename: Image filename
  • Purpose: Linking search results back to original MRI scans

3. faiss_index.bin (~28 MB)

  • Format: FAISS binary index
  • Type: IndexFlatIP (Inner Product)
  • Content: Optimized vector search index
  • Purpose: Fast similarity search across 7,200 MRI scans

πŸš€ Usage

Loading the Database

import numpy as np
import faiss
import json
from pathlib import Path

# Load embeddings
embeddings = np.load('embeddings.npy')

# Load metadata
with open('metadata.json', 'r') as f:
    metadata = json.load(f)

# Load FAISS index
index = faiss.read_index('faiss_index.bin')

print(f"Loaded {index.ntotal} brain MRI vectors")
print(f"Classes: {set(m['class'] for m in metadata)}")

Performing Similarity Search

from PIL import Image
import torchvision.transforms as transforms
import torchvision.models as models
import torch

# Load DenseNet-121 model
model = models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1)
model.classifier = torch.nn.Identity()
model.eval()

# Image preprocessing
transform = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], 
                       std=[0.229, 0.224, 0.225])
])

# Extract features from query MRI scan
def extract_features(image_path):
    img = Image.open(image_path).convert('RGB')
    img_tensor = transform(img).unsqueeze(0)
    
    with torch.no_grad():
        features = model(img_tensor).numpy()
        # Normalize
        features = features / np.linalg.norm(features)
    return features

# Search for similar brain MRI scans
query_features = extract_features('patient_mri.jpg')
k = 5  # Number of similar scans to retrieve

distances, indices = index.search(query_features, k)

# Get results
print("Similar brain MRI scans:")
for i, idx in enumerate(indices[0]):
    result = metadata[idx]
    tumor_type = result['class'].replace('brain_tumor_', '')
    print(f"{i+1}. {tumor_type.upper()} - {result['filename']}")
    print(f"   Similarity: {distances[0][i]:.4f}")

Filter by Tumor Type

def search_by_tumor_type(query_features, tumor_type, k=5):
    """Search for similar scans of a specific tumor type"""
    # Get all indices for the tumor type
    tumor_indices = [i for i, m in enumerate(metadata) 
                    if tumor_type in m['class']]
    
    # Create subset index
    subset_embeddings = embeddings[tumor_indices]
    subset_index = faiss.IndexFlatIP(1024)
    faiss.normalize_L2(subset_embeddings)
    subset_index.add(subset_embeddings)
    
    # Search
    distances, indices = subset_index.search(query_features, k)
    
    # Map back to original indices
    results = []
    for idx in indices[0]:
        original_idx = tumor_indices[idx]
        results.append(metadata[original_idx])
    
    return results, distances[0]

# Example: Find similar glioma cases
results, scores = search_by_tumor_type(query_features, 'glioma', k=5)

🧠 Model Architecture

DenseNet-121

  • Architecture: Dense Convolutional Network
  • Layers: 121 layers with dense connections
  • Feature Dimension: 1,024
  • Pretrained: ImageNet-1K
  • Medical Imaging Advantages:
    • Excellent feature extraction for MRI scans
    • Dense connections preserve fine-grained details
    • Proven performance on medical imaging tasks
    • Efficient parameter usage

πŸ“ˆ Performance Characteristics

Search Performance

  • Index Type: Flat (exact search)
  • Distance Metric: Inner Product (cosine similarity)
  • Search Speed: <1ms per query (GPU)
  • Accuracy: 100% (exact nearest neighbors)

Memory Requirements

  • Total Size: ~58 MB (all three files)
  • RAM for Loading: ~100 MB
  • GPU Memory: ~500 MB (for model inference)

Class Balance

  • Perfect Balance: 1,800 images per class
  • Advantages:
    • No class imbalance issues
    • Fair representation of all tumor types
    • Reliable similarity search across all classes

πŸ”§ Technical Details

Feature Extraction Pipeline

  1. Input: Brain MRI scans (grayscale or RGB)
  2. Preprocessing:
    • Convert to RGB if grayscale
    • Resize to 256Γ—256
    • Center crop to 224Γ—224
    • Normalize with ImageNet statistics
  3. Model: DenseNet-121 (without classification layer)
  4. Output: 1,024-dimensional feature vector
  5. Normalization: L2 normalization for cosine similarity

Vector Index

  • Algorithm: FAISS IndexFlatIP
  • Normalization: L2-normalized vectors
  • Similarity: Cosine similarity via inner product
  • GPU Support: Yes (for faster search)

πŸ“š Use Cases

1. Clinical Decision Support

  • Find similar historical cases for reference
  • Compare patient scans with known tumor types
  • Support differential diagnosis
  • Identify rare or unusual presentations

2. Medical Education

  • Create teaching collections of tumor types
  • Demonstrate tumor variations
  • Build case study libraries
  • Train medical students and residents

3. Research Applications

  • Analyze tumor patterns across large datasets
  • Study morphological similarities
  • Build training datasets for AI models
  • Validate diagnostic algorithms

4. Second Opinion Systems

  • Provide visual references for radiologists
  • Support peer review processes
  • Quality assurance for diagnoses
  • Reduce diagnostic errors

πŸ”’ Data Privacy & Ethics

Important Considerations

  • Public Dataset: From publicly available Kaggle dataset
  • De-identification: Ensure patient privacy in deployment
  • Clinical Use: Research tool only, not for clinical diagnosis
  • Validation: Always validate with qualified radiologists
  • Regulatory: Requires appropriate medical device approval for clinical use
  • Bias: Be aware of dataset limitations and biases

πŸ› οΈ Building the Database

The database was built using:

  • Notebook: Health_Imaging_RAG_Colab_Part2.ipynb
  • Platform: Google Colab with T4 GPU
  • Processing Time: ~10-15 minutes
  • Framework: PyTorch + FAISS
  • Model: DenseNet-121 (torchvision)

Dataset Source

  • Kaggle: masoudnickparvar/brain-tumor-mri-dataset
  • Original Size: 7,200 MRI scans
  • Format: JPEG images
  • Classes: 4 balanced classes

πŸ“Š Dataset Statistics

Image Distribution

Glioma:      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,800 (25%)
Pituitary:   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,800 (25%)
No Tumor:    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,800 (25%)
Meningioma:  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,800 (25%)

Quality Metrics

  • Balance: Perfect 25% per class
  • Consistency: Uniform image quality
  • Coverage: Comprehensive tumor type representation
  • Reliability: Suitable for training and evaluation

πŸ“– Citation

If you use this database in your research, please cite:

@software{brain_tumor_rag_2026,
  author = {{Gaston Software Solutions LLP}},
  title = {Brain Tumor MRI RAG Database},
  year = {2026},
  publisher = {GSS-LLP},
  address = {Ntinda, Kampala, Uganda},
  url = {https://www.gss-tec.com},
  note = {Brain tumor MRI retrieval system using DenseNet-121 and FAISS}
}

Please also cite the original dataset:

@dataset{brain_tumor_mri,
  author = {Masoud Nickparvar},
  title = {Brain Tumor MRI Dataset},
  year = {2021},
  publisher = {Kaggle},
  url = {https://www.kaggle.com/datasets/masoudnickparvar/brain-tumor-mri-dataset}
}

πŸ“ž Contact & Support

Gaston Software Solutions LLP

For technical support, questions, or collaboration opportunities, please contact us via email.

βš–οΈ License

MIT License

Copyright (c) 2026 Gaston Software Solutions LLP

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Intellectual Property Notice

This Brain Tumor MRI RAG Database is provided by Gaston Software Solutions LLP (GSS-LLP) under the MIT License for open-source use.

While the software is open-source and freely available for use, modification, and distribution under the MIT License terms, the intellectual property rights, including the database architecture, processing pipeline, and implementation methodology, remain the property of Gaston Software Solutions LLP.

Key Points:

  • βœ… Free to use, modify, and distribute under MIT License
  • βœ… Open-source for research and commercial applications
  • βœ… No warranty or liability from GSS-LLP
  • ⚠️ Intellectual property and methodology rights retained by GSS-LLP
  • ⚠️ Original dataset subject to its respective license
  • ⚠️ Medical use requires appropriate validation and regulatory compliance
  • ⚠️ Not approved for clinical diagnosis without proper medical device certification

Dataset License

The underlying brain tumor MRI dataset is sourced from Kaggle and is subject to its respective license. Users must comply with the original dataset license when using this RAG database. Please refer to:


🌟 About Gaston Software Solutions LLP

Gaston Software Solutions LLP (GSS-LLP) is a technology company based in Ntinda, Kampala, Uganda, specializing in AI/ML solutions, software development, and data science applications for healthcare and other industries.

Our Mission: Leveraging cutting-edge technology to solve real-world problems and improve lives through innovative software solutions.

Healthcare AI Services:

  • Medical Image Analysis Systems
  • RAG Databases for Healthcare
  • Clinical Decision Support Tools
  • AI-Powered Diagnostic Assistance
  • Custom Healthcare ML Solutions

Visit us at www.gss-tec.com or contact info@gss-tec.com for more information.


πŸ”— Related Databases

This is Part 2 of the Health Imaging RAG Database series:

  • Part 1: Pneumonia + Malaria (66,828 images)
  • Part 2: Brain Tumor MRI (7,200 images) ← You are here
  • Part 3: Skin Disease + Tuberculosis (Coming soon)

Combined Total: 74,028+ medical images across multiple conditions


Last Updated: June 2026
Version: 1.0
Total Images: 7,200
Model: DenseNet-121
Developed by: Gaston Software Solutions LLP
License: MIT

Downloads last month
27

Space using ugahost991/BRAIN_TUMOR 1