Skip to content

ghostcoder911/BoneAgeAssessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Pediatric Bone Age Assessment Using Deep Convolutional Neural Networks

A comprehensive deep learning solution for automated bone age assessment from pediatric X-ray images using Convolutional Neural Networks (CNN).

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Introduction

Bone and skeletal age assessment is a common clinical practice to check the effectiveness of treatment for diagnosed endocrine abnormalities in a child's development. This project implements a fully automated deep learning approach to bone age assessment using data from the 2017 Pediatric Bone Age Challenge organized by the Radiological Society of North America.

The dataset consists of 12,600 radiographs of the left hand and wrist, which are the most frequently used images for bone age determination. Deep learning-based methods have shown significant performance improvements compared to traditional machine learning approaches.

โœจ Features

  • Modular Architecture: Clean, organized codebase with separate modules for different functionalities
  • Multiple Model Architectures: Standard and advanced CNN architectures
  • Comprehensive Evaluation: Detailed metrics and visualization tools
  • Batch Processing: Support for single image and batch predictions
  • Data Augmentation: Advanced image preprocessing and augmentation
  • Visualization Tools: Rich plotting and analysis utilities
  • Command-line Interface: Easy-to-use CLI for training and prediction
  • Configuration Management: Centralized configuration system

๐Ÿš€ Installation

Prerequisites

  • Python 3.8 or higher
  • CUDA-compatible GPU (recommended for training)
  • 8GB+ RAM (16GB+ recommended)

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd Predict-Bone-Age
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Verify installation:

    python -c "import tensorflow as tf; print('TensorFlow version:', tf.__version__)"

๐Ÿ“ Project Structure

Predict-Bone-Age/
โ”œโ”€โ”€ bone_age_prediction.py    # Main training and evaluation script
โ”œโ”€โ”€ model.py                  # CNN model definitions
โ”œโ”€โ”€ utils.py                  # Utility functions and visualization
โ”œโ”€โ”€ config.py                 # Configuration management
โ”œโ”€โ”€ predict.py                # Prediction script for inference
โ”œโ”€โ”€ train.py                  # Simple training interface
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ README.md                 # This file
โ”œโ”€โ”€ FINALL PROJECT.ipynb      # Original Jupyter notebook
โ””โ”€โ”€ outputs/                  # Generated outputs (created during training)
    โ”œโ”€โ”€ models/               # Saved models
    โ”œโ”€โ”€ plots/                # Generated plots
    โ””โ”€โ”€ results/              # Training results

๐ŸŽฎ Usage

Training a Model

Using the Simple Training Script:

python train.py --csv boneage-training-dataset.csv --images images/train --epochs 50

Using the Main Script:

python bone_age_prediction.py

Advanced Training Options:

python train.py \
    --csv boneage-training-dataset.csv \
    --images images/train \
    --model-type advanced \
    --epochs 100 \
    --batch-size 64 \
    --output-dir results/experiment_1

Making Predictions

Single Image Prediction:

python predict.py --model outputs/bone_age_model_standard.h5 --image path/to/image.png --visualize

Batch Prediction:

python predict.py --model outputs/bone_age_model_standard.h5 --directory path/to/images/ --output predictions.json

Using the Python API:

from predict import BoneAgePredictor

# Initialize predictor
predictor = BoneAgePredictor(model_path='outputs/bone_age_model_standard.h5')

# Predict single image
result = predictor.predict_single_image('path/to/image.png')
print(f"Predicted age: {result['predicted_age_years']:.1f} years")

# Batch prediction
results = predictor.predict_from_directory('path/to/images/')

Data Analysis and Visualization

from utils import plot_bone_age_distribution, analyze_dataset
import pandas as pd

# Load data
df = pd.read_csv('boneage-training-dataset.csv')

# Analyze dataset
mean_age, std_age = analyze_dataset(df)

# Plot distributions
plot_bone_age_distribution(df, save_path='data_analysis.png')

๐Ÿ—๏ธ Model Architecture

Standard CNN Architecture

  • Input: 385x385x3 RGB images
  • Convolutional Layers: 4 blocks with 16, 32, 64, 128 filters
  • Pooling: MaxPooling2D after each conv block
  • Regularization: Dropout layers (0.2, 0.2, 0.3)
  • Dense Layers: 64 โ†’ 128 โ†’ 1 neurons
  • Output: Linear regression for age prediction

Advanced CNN Architecture

  • Input: 385x385x3 RGB images
  • Convolutional Layers: 8 blocks with double conv layers
  • Filters: 32, 32, 64, 64, 128, 128, 256, 256
  • Regularization: Enhanced dropout and batch normalization
  • Dense Layers: 512 โ†’ 256 โ†’ 128 โ†’ 1 neurons
  • Optimizer: Adam with learning rate scheduling

๐Ÿ“Š Data

Dataset Information

  • Source: RSNA Bone Age Challenge 2017
  • Total Images: 12,600 radiographs
  • Age Range: 1-228 months (0.08-19 years)
  • Gender Distribution: ~50% male, ~50% female
  • Image Format: PNG, 1653x1334 pixels (resized to 385x385)

Data Preprocessing

  • Normalization: Pixel values scaled to [0, 1]
  • Augmentation: Rotation, zoom, shift, flip
  • Z-score Normalization: Age values normalized using mean and std
  • Train/Validation Split: 90/10 split

๐Ÿ“ˆ Results

Performance Metrics

  • Mean Absolute Error: ~23-27 months
  • Predictions within 6 months: ~40-50%
  • Predictions within 12 months: ~70-80%
  • Predictions within 24 months: ~90-95%

Sample Predictions

The model shows good performance across different age groups, with slightly better accuracy for older children.

๐Ÿ”ง API Reference

BoneAgePredictor Class

Main class for training and evaluation.

predictor = BoneAgePredictor(batch_size=32)
train_gen, val_gen, test_data = predictor.load_and_preprocess_data(csv_path, image_dir)
predictor.create_model()
predictor.train_model(train_gen, val_gen, epochs=50)

BoneAgeCNN Class

CNN model definition and management.

cnn = BoneAgeCNN()
model = cnn.create_model()
cnn.save_model('model.h5')

Utility Functions

  • analyze_dataset(df): Dataset analysis and statistics
  • plot_bone_age_distribution(df): Age distribution visualization
  • evaluate_predictions(y_true, y_pred): Comprehensive evaluation metrics
  • plot_training_history(history): Training progress visualization

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“š References

  1. RSNA Bone Age Challenge 2017
  2. Deep Learning for Bone Age Assessment
  3. Radiological Society of North America (RSNA)

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • RSNA for providing the bone age dataset
  • The deep learning community for open-source tools and frameworks
  • Contributors and researchers in medical imaging and AI

Note: This is a research project for educational purposes. For clinical use, please consult with medical professionals and ensure proper validation and regulatory approval.

About

This repo contains package for bone age assessment using xray images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors