help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
medical-imaging
RSK World
medical-imaging
Medical Imaging Dataset - X-ray CT Scan MRI + Disease Detection + Computer-Aided Diagnosis + Medical AI
medical-imaging
  • __pycache__
  • data
  • scripts
  • .gitignore475 B
  • CONTRIBUTING.md1.7 KB
  • CT_MRI_LOCATION.md6 KB
  • DATASET_SUMMARY.md4.1 KB
  • DISCLAIMER.md2.1 KB
  • DOWNLOAD_INSTRUCTIONS.md7.5 KB
  • ERROR_CHECK_REPORT.md4.2 KB
  • FINAL_DATASET_SUMMARY.md5.8 KB
  • LICENSE784 B
  • PROJECT_IMAGE_NOTE.md1.2 KB
  • PROJECT_SUMMARY.md3.9 KB
  • QUICK_START.md2.9 KB
  • README.md4.3 KB
  • RELEASE_NOTES.md5 KB
  • create_directories.py1.5 KB
  • download_all_ct_mri.py12.2 KB
  • download_all_datasets.py8.9 KB
  • download_ct_mri_datasets.py10.1 KB
  • download_ct_mri_kaggle.bat1.5 KB
  • download_from_github.py8.1 KB
  • download_helper.py4.4 KB
  • download_kaggle_datasets.bat2.1 KB
  • download_public_datasets.py16.7 KB
  • download_summary.json211 B
  • example_usage.py2.7 KB
  • generate_sample_data.py15.9 KB
  • index.html43.2 KB
  • medical-imaging.zip2.1 MB
  • organize_medmnist.py1.3 KB
  • organize_mri_data.py584 B
  • project_info.json1.4 KB
  • requirements.txt492 B
  • setup.py2 KB
download_helper.py
download_helper.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Medical Imaging Dataset - Download Helper
==========================================

Project: Medical Imaging Dataset
Website: https://rskworld.in
Contact: help@rskworld.in, support@rskworld.in
Phone: +91 93305 39277
Founder: Molla Samser
Designer & Tester: Rima Khatun

Helper script to download and organize public medical imaging datasets.
"""

import os
import sys
import zipfile
import shutil
from pathlib import Path


def check_kaggle_installed():
    """Check if Kaggle API is installed."""
    try:
        import kaggle
        return True
    except ImportError:
        print("Kaggle API not found. Installing...")
        os.system("pip install kaggle")
        try:
            import kaggle
            return True
        except ImportError:
            print("Failed to install Kaggle API. Please install manually:")
            print("  pip install kaggle")
            return False


def download_kaggle_dataset(dataset_name, output_dir="data/temp"):
    """Download a dataset from Kaggle."""
    if not check_kaggle_installed():
        return False
    
    try:
        from kaggle.api.kaggle_api_extended import KaggleApi
        api = KaggleApi()
        api.authenticate()
        
        print(f"Downloading {dataset_name}...")
        api.dataset_download_files(dataset_name, path=output_dir, unzip=True)
        print(f"Downloaded to {output_dir}")
        return True
    except Exception as e:
        print(f"Error downloading dataset: {e}")
        print("Make sure you have:")
        print("1. Kaggle account")
        print("2. API token in ~/.kaggle/kaggle.json (or C:\\Users\\YourUsername\\.kaggle\\kaggle.json)")
        return False


def organize_chest_xray_data(source_dir, target_dir="data/xray"):
    """Organize chest X-ray data into project structure."""
    source = Path(source_dir)
    target_images = Path(target_dir) / "images"
    target_labels = Path(target_dir) / "labels"
    
    target_images.mkdir(parents=True, exist_ok=True)
    target_labels.mkdir(parents=True, exist_ok=True)
    
    # Find all image files
    image_extensions = ['.png', '.jpg', '.jpeg', '.dcm']
    image_count = 0
    
    for ext in image_extensions:
        for img_file in source.rglob(f'*{ext}'):
            if img_file.is_file():
                # Copy to images directory
                dest = target_images / img_file.name
                shutil.copy2(img_file, dest)
                image_count += 1
                
                # Create a basic label file
                label_file = target_labels / f"{img_file.stem}.json"
                if not label_file.exists():
                    label_data = {
                        "diagnosis": "Unknown",
                        "source": "Public Dataset",
                        "modality": "X-ray",
                        "body_part": "Chest",
                        "annotations": {
                            "findings": ["From public dataset"],
                            "recommendations": ["Educational use only"]
                        }
                    }
                    import json
                    with open(label_file, 'w') as f:
                        json.dump(label_data, f, indent=4)
    
    print(f"Organized {image_count} images to {target_dir}")
    return image_count


def main():
    """Main function."""
    print("=" * 60)
    print("Medical Imaging Dataset - Download Helper")
    print("=" * 60)
    print()
    print("Available datasets:")
    print("1. Chest X-Ray Images (Pneumonia)")
    print("2. Brain MRI Images for Brain Tumor Detection")
    print("3. Medical MNIST")
    print()
    
    choice = input("Enter dataset number (1-3) or 'q' to quit: ").strip()
    
    datasets = {
        "1": ("paultimothymooney/chest-xray-pneumonia", "xray"),
        "2": ("navoneel/brain-mri-images-for-brain-tumor-detection", "mri"),
        "3": ("andrewmvd/medical-mnist", "mixed")
    }
    
    if choice in datasets:
        dataset_name, data_type = datasets[choice]
        if download_kaggle_dataset(dataset_name):
            print("\nDownload complete!")
            print("Please organize the data manually or use the organize functions.")
    elif choice.lower() == 'q':
        print("Exiting...")
    else:
        print("Invalid choice.")


if __name__ == '__main__':
    main()
137 lines•4.4 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer